On Thu, May 1, 2014 at 4:07 PM, Nicholas Firth <nicholas.fi...@icr.ac.uk>wrote:

> Thanks Greg,
>
> That clears up how to go about fixing that. I'm left with a bit of
> confusion though, I should be able to add explicit hydrogens to my SMILES
> to get the result, but I did a simple case and this didn't work:
>
> >>> p = Chem.MolFromSmarts('[#7]-[#1]')
> >>> m = Chem.MolFromSmiles('c1cc[nH]c1')
> >>> m.HasSubstructMatch(p)
> False
> >>> for atom in m.GetAtoms(): print atom.GetNumExplicitHs()
> ...
> 0
> 0
> 0
> 1
> 0
>
> Is this a distinction between the naming of hydrogens and the occurrence
> of an atom on the molecular graph?
>

The [nH] notation just adds an explicit H, it doesn't actually add it to
the graph. In order to have the Hs present, you need to call AddHs():

In [46]: p = Chem.MolFromSmarts('[#7]-[#1]')
In [47]: m = Chem.MolFromSmiles('c1cc[nH]c1')
In [48]: mh = Chem.AddHs(m)
In [49]: mh.HasSubstructMatch(p)
Out[49]: True


-greg
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.  Get 
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to