Hello all, I tried to extend this method to whole QM9 database. For few molecules including 'CC12CCC1CC2' and 'CC12CC3C1OC32', however, GetNumConformers() shows zero conformations on the molecule. Is there a way to generalize computing bond length to include such molecules?
Thanks! Navid On Wed, Sep 4, 2019 at 7:28 PM Navid Shervani-Tabar <nshe...@gmail.com> wrote: > Thanks Omar, That indeed fix the problem. > > Navid > > On Wed, Sep 4, 2019 at 7:15 PM Omar H94 <omar8...@gmail.com> wrote: > >> Dear Navid, >> You need to embed your molecule to have a 3D conformation. >> Try: >> >> from rdkit.Chem import AllChem >> mol = Chem.MolFromSmiles('O=CC1OC12CC1OC12') >> AllChem.EmbedMolecule(mol) >> conf = mol.GetConformer() >> at1Coords = np.array(conf.GetAtomPosition(1)) >> at2Coords = np.array(conf.GetAtomPosition(2)) >> print(np.linalg.norm(at2Coords - at1Coords)) >> >> I hope this works for you. >> Best regards, >> Omar >> >> On Thu, Sep 5, 2019 at 1:59 AM Navid Shervani-Tabar <nshe...@gmail.com> >> wrote: >> >>> Hello, >>> >>> I'm trying to find the Euclidean distance between two atoms in the >>> molecule with SMILES representation `O=CC1OC12CC1OC12` using the `rdkit` >>> package. Looking online, I have converged to the following code. >>> >>> import numpy as np >>> from rdkit import Chem >>> >>> mol = Chem.MolFromSmiles('O=CC1OC12CC1OC12') >>> >>> conf = mol.GetConformer() >>> at1Coords = np.array(conf.GetAtomPosition(bond_i.GetBeginAtomIdx())) >>> at2Coords = np.array(conf.GetAtomPosition(bond_i.GetEndAtomIdx())) >>> print(np.linalg.norm(at2Coords - at1Coords)) >>> >>> But I get the error >>> >>> conf = mol.GetConformer() >>> ValueError: Bad Conformer Id >>> >>> I was wondering how to fix the issue. >>> >>> Thanks! >>> Navid >>> >>> _______________________________________________ >>> Rdkit-discuss mailing list >>> Rdkit-discuss@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >>> >> _______________________________________________ >> Rdkit-discuss mailing list >> Rdkit-discuss@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >> >
_______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss