Skip to content

Commit 7771164

Browse files
authoredJan 19, 2024
Merge pull request #503 from datamol-io/ordered_true
MAJOR-BUG for node/edge predictions: Added ordered=True to `to_mol`
2 parents f698df4 + 17861c9 commit 7771164

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed
 

‎graphium/data/smiles_transform.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def smiles_to_unique_mol_id(smiles: str) -> Optional[str]:
2727
mol_id: a string unique ID
2828
"""
2929
try:
30-
mol = dm.to_mol(mol=smiles)
30+
mol = dm.to_mol(
31+
mol=smiles
32+
) # Doesn't need `ordered=True` because the unique_id doesn't depend on the atom order
3133
mol_id = dm.unique_id(mol)
3234
except:
3335
mol_id = ""

‎graphium/features/featurizer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ def mol_to_adj_and_features(
743743
"""
744744

745745
if isinstance(mol, str):
746-
mol = dm.to_mol(mol)
746+
mol = dm.to_mol(mol, ordered=True)
747747

748748
# Add or remove explicit hydrogens
749749
if explicit_H:
@@ -1071,7 +1071,7 @@ def mol_to_graph_dict(
10711071
input_mol = mol
10721072
try:
10731073
if isinstance(mol, str):
1074-
mol = dm.to_mol(mol)
1074+
mol = dm.to_mol(mol, ordered=True)
10751075
if explicit_H:
10761076
mol = Chem.AddHs(mol)
10771077
else:

‎graphium/features/properties.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import datamol as dm
1919

2020
from rdkit.Chem import rdMolDescriptors as rdMD
21+
from loguru import logger
2122

2223

2324
def get_prop_or_none(
@@ -33,6 +34,7 @@ def get_prop_or_none(
3334
Returns:
3435
The property or a list of `None` with lenght `n`.
3536
"""
37+
logger.warning("get_prop_or_none is deprecated. Use `datamol.to_fp` instead.")
3638
try:
3739
return prop(*args, **kwargs)
3840
except RuntimeError:
@@ -75,8 +77,12 @@ def get_props_from_mol(
7577
7678
"""
7779

80+
logger.warning("get_props_from_mol is deprecated. Use `datamol.to_fp` instead.")
81+
7882
if isinstance(mol, str):
79-
mol = dm.to_mol(mol)
83+
mol = dm.to_mol(
84+
mol
85+
) # Doesn't need `ordered=True` because the fingerprints don't depend on the atom order
8086

8187
if isinstance(properties, str):
8288
properties = [properties]

‎profiling/profile_mol_to_graph.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def main():
6767

6868
graphs = []
6969
for s in tqdm(smiles):
70-
mol = dm.to_mol(s)
70+
mol = dm.to_mol(
71+
s
72+
) # Doesn't need `ordered=True` because this is just to test the speed of the featurizer
7173
graphs.append(mol_to_graph_dict(mol, **featurizer))
7274

7375
print(graphs[0])

0 commit comments

Comments
 (0)
Please sign in to comment.