From c315e505898a22da4fcd3b1ee7666d5823f596a0 Mon Sep 17 00:00:00 2001 From: dominique Date: Thu, 18 Jan 2024 18:03:22 -0500 Subject: [PATCH 1/6] Added ordered=True to `to_mol` --- graphium/features/featurizer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/graphium/features/featurizer.py b/graphium/features/featurizer.py index 7c6afda4c..8d8e18159 100644 --- a/graphium/features/featurizer.py +++ b/graphium/features/featurizer.py @@ -743,7 +743,7 @@ def mol_to_adj_and_features( """ if isinstance(mol, str): - mol = dm.to_mol(mol) + mol = dm.to_mol(mol, ordered=True) # Add or remove explicit hydrogens if explicit_H: @@ -1071,7 +1071,7 @@ def mol_to_graph_dict( input_mol = mol try: if isinstance(mol, str): - mol = dm.to_mol(mol) + mol = dm.to_mol(mol, ordered=True) if explicit_H: mol = Chem.AddHs(mol) else: From df8d1930e2440d86f71c66415f2d538e53c1f52e Mon Sep 17 00:00:00 2001 From: DomInvivo Date: Fri, 19 Jan 2024 09:36:14 -0500 Subject: [PATCH 2/6] Added comments explaining why `ordered=True` is not needed --- graphium/data/smiles_transform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphium/data/smiles_transform.py b/graphium/data/smiles_transform.py index e498b405f..02c22c0eb 100644 --- a/graphium/data/smiles_transform.py +++ b/graphium/data/smiles_transform.py @@ -27,7 +27,7 @@ def smiles_to_unique_mol_id(smiles: str) -> Optional[str]: mol_id: a string unique ID """ try: - mol = dm.to_mol(mol=smiles) + mol = dm.to_mol(mol=smiles) # Doesn't need `ordered=True` because the unique_id doesn't depend on the atom order mol_id = dm.unique_id(mol) except: mol_id = "" From 19055b2ce4a1fb187430fbf843bb85ece60634eb Mon Sep 17 00:00:00 2001 From: DomInvivo Date: Fri, 19 Jan 2024 09:36:29 -0500 Subject: [PATCH 3/6] Depreciating the `properties.py` file --- graphium/features/properties.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphium/features/properties.py b/graphium/features/properties.py index ad4ff5e5e..6fb3f5440 100644 --- a/graphium/features/properties.py +++ b/graphium/features/properties.py @@ -18,6 +18,7 @@ import datamol as dm from rdkit.Chem import rdMolDescriptors as rdMD +from loguru import logger def get_prop_or_none( @@ -33,6 +34,7 @@ def get_prop_or_none( Returns: The property or a list of `None` with lenght `n`. """ + logger.warning("get_prop_or_none is deprecated. Use `datamol.to_fp` instead.") try: return prop(*args, **kwargs) except RuntimeError: @@ -75,8 +77,10 @@ def get_props_from_mol( """ + logger.warning("get_props_from_mol is deprecated. Use `datamol.to_fp` instead.") + if isinstance(mol, str): - mol = dm.to_mol(mol) + mol = dm.to_mol(mol) # Doesn't need `ordered=True` because the fingerprints don't depend on the atom order if isinstance(properties, str): properties = [properties] From 7fd861cdf81052bdf3e0d6134878e341434a1fca Mon Sep 17 00:00:00 2001 From: DomInvivo Date: Fri, 19 Jan 2024 09:37:04 -0500 Subject: [PATCH 4/6] Black linting --- graphium/data/smiles_transform.py | 4 +++- graphium/features/properties.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/graphium/data/smiles_transform.py b/graphium/data/smiles_transform.py index 02c22c0eb..d6f22fbdc 100644 --- a/graphium/data/smiles_transform.py +++ b/graphium/data/smiles_transform.py @@ -27,7 +27,9 @@ def smiles_to_unique_mol_id(smiles: str) -> Optional[str]: mol_id: a string unique ID """ try: - mol = dm.to_mol(mol=smiles) # Doesn't need `ordered=True` because the unique_id doesn't depend on the atom order + mol = dm.to_mol( + mol=smiles + ) # Doesn't need `ordered=True` because the unique_id doesn't depend on the atom order mol_id = dm.unique_id(mol) except: mol_id = "" diff --git a/graphium/features/properties.py b/graphium/features/properties.py index 6fb3f5440..89a90ffee 100644 --- a/graphium/features/properties.py +++ b/graphium/features/properties.py @@ -80,7 +80,9 @@ def get_props_from_mol( logger.warning("get_props_from_mol is deprecated. Use `datamol.to_fp` instead.") if isinstance(mol, str): - mol = dm.to_mol(mol) # Doesn't need `ordered=True` because the fingerprints don't depend on the atom order + mol = dm.to_mol( + mol + ) # Doesn't need `ordered=True` because the fingerprints don't depend on the atom order if isinstance(properties, str): properties = [properties] From 4c19068b3d3383de2794ef050889cb6c24c8cb80 Mon Sep 17 00:00:00 2001 From: DomInvivo Date: Fri, 19 Jan 2024 09:38:34 -0500 Subject: [PATCH 5/6] Documented why `profile_mol_to_graph` doesn't need ordered --- profiling/profile_mol_to_graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiling/profile_mol_to_graph.py b/profiling/profile_mol_to_graph.py index a3ee1dbf1..63f6ba472 100644 --- a/profiling/profile_mol_to_graph.py +++ b/profiling/profile_mol_to_graph.py @@ -67,7 +67,7 @@ def main(): graphs = [] for s in tqdm(smiles): - mol = dm.to_mol(s) + mol = dm.to_mol(s) # Doesn't need `ordered=True` because this is just to test the speed of the featurizer graphs.append(mol_to_graph_dict(mol, **featurizer)) print(graphs[0]) From 17861c96f848b0f6b5ddca43b680b1148b3f7aaa Mon Sep 17 00:00:00 2001 From: DomInvivo Date: Fri, 19 Jan 2024 09:39:21 -0500 Subject: [PATCH 6/6] black linting --- profiling/profile_mol_to_graph.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/profiling/profile_mol_to_graph.py b/profiling/profile_mol_to_graph.py index 63f6ba472..423f487cf 100644 --- a/profiling/profile_mol_to_graph.py +++ b/profiling/profile_mol_to_graph.py @@ -67,7 +67,9 @@ def main(): graphs = [] for s in tqdm(smiles): - mol = dm.to_mol(s) # Doesn't need `ordered=True` because this is just to test the speed of the featurizer + mol = dm.to_mol( + s + ) # Doesn't need `ordered=True` because this is just to test the speed of the featurizer graphs.append(mol_to_graph_dict(mol, **featurizer)) print(graphs[0])