Lomap MCS throws ValueError if rdkit.Mol created from SMILES

Open
#4 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
tooling

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.

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

Dominant language
Python
Stars
45
Forks
15
Avg merge
18h 11m
Merged PRs (30d)
4

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenFreeEnergy/Lomap

All issues in OpenFreeEnergy/Lomap

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.