JP, On Mon, May 14, 2012 at 12:57 PM, JP <[email protected]> wrote: > > > I create a molecule without sanitization (red flag) - because, oh well, I > downloaded this sd file from the web so it must be perfectly curated and > what not. > > When I try Chem.AddHs, I get > > <rdkit.Chem.rdchem.Mol object at 0x140a3d0> > [11:47:00] > > **** > Pre-condition Violation > getNumImplicitHs() called without preceding call to calcImplicitValence() > Violation occurred on line 167 in file > /opt/RDKit_trunk/Code/GraphMol/Atom.cpp > Failed Expression: d_implicitValence>-1 > **** > > Traceback (most recent call last): > File "./test.py", line 107, in <module> > Chem.AddHs(m, addCoords=True) > RuntimeError: Pre-condition Violation > > I understand that this may be related to having sanitization switched off > (in fact if I turn it on it works), but my question is - is this the correct > error message? > Perhaps calcImplicitValence() should be called regardless of sanitization?
In order for the code to add coordinates for the added Hs, it needs to calculate the valence at each atom. You don't need to sanitize the molecules to work around this, the following snippet should work just fine: m = Chem.MolFromMolBlock(mol_block, sanitize=False) m.UpdatePropertyCache(strict=False) mh=Chem.AddHs(m, addCoords=True) Best, -greg ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Rdkit-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

