3
$\begingroup$

I am trying to compute the bond angles of all the pairs of bond in a set of molecule from Colontrix dataset. Some of the molecules are showing up error when I am implementing the following.The error says:

Example: Isosorbide 5-nitrate [C1[C@@H]([C@@H]2[C@H](O1)[C@@H](CO2)O[N+](=O)[O-])O]

Error:

Value Error: Bad Conformer id.

Code:

from rdkit.Chem import AllChem as Chem

mol_obj = Chem.MolFromSmiles(mol["smiles"])
Chem.EmbedMolecule(mol_obj, randomSeed=42)
conf = mol3d.GetConformer()
$\endgroup$
2
  • $\begingroup$ Is there a longer stack trace that goes along with the error. That will point to which line in your code (and probably more importantly which line in rdkit) is raising this error. $\endgroup$
    – Tyberius
    Commented Apr 23, 2023 at 0:08
  • $\begingroup$ @Formal_this I hope my answer solves your question. If yes, please click on the tick mark next to it. $\endgroup$ Commented Apr 24, 2023 at 7:41

1 Answer 1

1
$\begingroup$

Please avoid renaming modules with existing module names.

For example, in your imports you have renamed AllChem as Chem. However there is already an existing library called Chem in rdkit. There is a high chance that this will cause problems for you if you need to use something from the actual "Chem" module.

Also it looks like you perhaps have the wrong SMILES for isosorbide-5-mononitrate. I got the SMILES from this website.

Here is a working code that will resolve your conformer id error:

from rdkit import Chem
from rdkit.Chem import AllChem

isosorbide_5_mononitrate_smiles = 'O=[N+]([O-])O[C@H]1[C@](OC[C@@H]2O)([H])[C@]2([H])OC1'
mol = Chem.MolFromSmiles(isosorbide_5_mononitrate_smiles)
mol = Chem.AddHs(mol)
AllChem.EmbedMolecule(mol, randomSeed=42)
conf = mol.GetConformer()
$\endgroup$
2
  • $\begingroup$ As you mentioned, the SMILES is garbled. In this case, it's the initial '[' and trailing ']' characters - the SMILES syntax expects [ ] to reflect an individual atom environment. The "import AllChem as Chem" is considered okay - Greg uses it in the RDKit cookbook after all. $\endgroup$ Commented Apr 25, 2023 at 18:56
  • 1
    $\begingroup$ In my opinion aliasing modules with names of already existing modules creates unnecessary confusion. It also has adds possibility of problems in case one needs to use one of the existing libraries. $\endgroup$ Commented Apr 25, 2023 at 20:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .