[Rdkit-discuss] Problem getting valence
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
From: Lewis J M. <lew...@gm...> - 2018-07-26 08:42:59
|
Hi all, I have generated a molecule that I can both visualize and export as SMILES, but I can't Sanitize it. Creating a new molecule from that SMILES fails due to something to do with the valence. It seems to me that it has the correct amount of bonds. Code to reproduce and 'debugging' that Ive tried: -------------------------------------- #sanitize=False or it won't load this SMILES mol = Chem.MolFromSmiles('[CH3:0][CH2:1][CH2:2][CH2:3][CH2:4][nH:5]1[c:6]([CH:14](=[O:15])[*:16])[n:7][c:8]2[cH:9][cH:10][cH:11][cH:12][c:13]12',sanitize=False) #print atom indices and atomic number: for i in mol.GetAtoms(): print(i, i.GetIdx(), i.GetAtomicNum()) #display bonds relating to index 7. Seems correct for a carbon. for i in mol.GetBonds(): if i.GetBeginAtomIdx()==7 or i.GetEndAtomIdx()==7: print(i.GetBeginAtomIdx(), i.GetEndAtomIdx(), i.GetBondType()) #print valences. Fails on index 7. for i in mol.GetAtoms(): print(i.GetIdx(), i.GetExplicitValence()) -------------------------------------- Can anyone please offer some advice as to what the problem is? Much appreciated! Lewis PS. here is the output I get: <rdkit.Chem.rdchem.Atom object at 0x11a440c10> 0 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c60> 1 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c10> 2 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c60> 3 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c10> 4 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c60> 5 7 <rdkit.Chem.rdchem.Atom object at 0x11a440c10> 6 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c60> 7 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c10> 8 8 <rdkit.Chem.rdchem.Atom object at 0x11a440c60> 9 0 <rdkit.Chem.rdchem.Atom object at 0x11a440c10> 10 7 <rdkit.Chem.rdchem.Atom object at 0x11a440c60> 11 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c10> 12 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c60> 13 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c10> 14 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c60> 15 6 <rdkit.Chem.rdchem.Atom object at 0x11a440c10> 16 6 6 7 SINGLE 7 8 DOUBLE 7 9 SINGLE 0 4 1 4 2 4 3 4 4 4 5 3 6 4 --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) <ipython-input-24-62fd51819686> in<module>() 7 8 for iin mol.GetAtoms(): ----> 9print(i.GetIdx(), i.GetExplicitValence()) 10 #valence = oneMol.GetAtomWithIdx(7).GetExplicitValence() 11 #print(valence) RuntimeError: Pre-condition Violation getExplicitValence() called without call to calcExplicitValence() Violation occurred on line 162 in file Code/GraphMol/Atom.cpp Failed Expression: d_explicitValence > -1 RDKIT: 2018.03.3 BOOST: 1_65_1 |