OpenFreeEnergy / OpenFreeEnergy/Lomap
Lomap MCS throws ValueError if rdkit.Mol created from SMILES
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 45
- Forks
- 16
- Avg merge
- 55m
- Merged PRs (30d)
- 1
Description
from rdkit import Chem
from lomap import mcs
test_dir = "/Users/dwhs/omsf/src/openfe/openfe/tests/data/lomap_basic/"
toluene = Chem.MolFromMol2File(test_dir + "toluene.mol2")
methylcyclohexane = Chem.MolFromMol2File(test_dir + "methylcyclohexane.mol2")
mapping = mcs.MCS(toluene, methylcyclohexane)
# behaves as desired
toluene2 = Chem.MolFromSmiles(Chem.MolToSmiles(toluene))
methylcyclohexane2 = Chem.MolFromSmiles(Chem.MolToSmiles(methylcyclohexane))
mapping = mcs.MCS(toluene2, methylcyclohexane2)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
~/mambaforge/envs/openfe/lib/python3.9/site-packages/lomap/mcs.py in __init__(self, moli, molj, time, verbose, max3d, threed)
586 try:
--> 587 trim_mcs_mol(max_deviation=max3d)
588 except Exception as e:
~/mambaforge/envs/openfe/lib/python3.9/site-packages/lomap/mcs.py in trim_mcs_mol(max_deviation)
156 while True:
--> 157 (mapi,mapj) = best_substruct_match_to_mcs(self._moli_noh, self._molj_noh, by_rmsd=True)
158 # Compute the translation to bring molj's centre over moli
~/mambaforge/envs/openfe/lib/python3.9/site-packages/lomap/mcs.py in best_substruct_match_to_mcs(moli, molj, by_rmsd)
121 if by_rmsd:
--> 122 coord_delta = (substructure_centre(moli,mapi)
123 - substructure_centre(molj,mapj))
~/mambaforge/envs/openfe/lib/python3.9/site-packages/lomap/mcs.py in substructure_centre(mol, mol_sub)
90 for i in mol_sub:
---> 91 sum += mol.GetConformer().GetAtomPosition(i)
92 return sum / len(mol_sub)
ValueError: Bad Conformer Id
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
/var/folders/vj/28c107496sq5z4y10rjz5gdm0000gn/T/ipykernel_30741/2330220248.py in <module>
1 toluene2 = Chem.MolFromSmiles(Chem.MolToSmiles(toluene))
2 methylcyclohexane2 = Chem.MolFromSmiles(Chem.MolToSmiles(methylcyclohexane))
----> 3 mapping = mcs.MCS(toluene2, methylcyclohexane2)
~/mambaforge/envs/openfe/lib/python3.9/site-packages/lomap/mcs.py in __init__(self, moli, molj, time, verbose, max3d, threed)
587 trim_mcs_mol(max_deviation=max3d)
588 except Exception as e:
--> 589 raise ValueError(str(e))
590
591 # Trim the MCS further to remove chirality mismatches
ValueError: Bad Conformer Id
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lomap/mcs.py at trim_mcs_mol, best_substruct_match_to_mcs, and substructure_centre, following the reported Bad Conformer Id path. Reproduce the issue with RDKit molecules created from SMILES and compare it with the Mol2-based example. Done means MCS accepts the SMILES-created molecules and returns a mapping without raising ValueError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100