[Rdkit-discuss] Building a molecule from scratch
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: Noel O'B. <bao...@gm...> - 2008-04-15 10:41:35
|
I am running into trouble building a molecule from scratch. Let's say the molecule represented by "F/C=C/F" (taken from the Daylight SMILES tutorial). Here's the code to build it (according to me): import Chem # Set some lookups _bondtypes = {1: Chem.BondType.SINGLE, 2: Chem.BondType.DOUBLE, 3: Chem.BondType.TRIPLE} _bondstereo = {0: Chem.rdchem.BondStereo.STEREONONE, 1: Chem.rdchem.BondStereo.STEREOE, 2: Chem.rdchem.BondStereo.STEREOZ} # Build F/C=C/F rdmol = Chem.Mol() rdedmol = Chem.EditableMol(rdmol) for atomnum in [9, 6, 6, 9]: rdatom = Chem.Atom(atomnum) rdedmol.AddAtom(rdatom) for bond in [(0,1,1), (1,2,2), (2,3,1)]: rdedmol.AddBond(bond[0], bond[1], _bondtypes[bond[2]]) rdmol = rdedmol.GetMol() for stereoID, newbond in zip([0, 1, 0], rdmol.GetBonds()): newbond.SetStereo(_bondstereo[stereoID]) Chem.SanitizeMol(rdmol) # Gets here fine # Print the result print Chem.MolToSmiles(rdmol, isomericSmiles=True) # RuntimeError: Pre-condition Violation What am I missing? It works fine if I use [0, 0, 0] for stereoID, so it's something to do with the way I handle the stereoisomer. Noel |