On Jan 25, 2011, at 4:01 PM, Pascal Muller wrote:
> Using pybel, I would like to generate a smarts with explicit H before
> doing a substructure search.
...
> scaffoldSmiles = mol.write("can")
> scaffoldSmarts = pybel.Smarts(scaffoldSmiles)
The problem is this the write("can") step. It converts explicit H:s into
implicit
>>> mol = pybel.readstring("smi", "C([H])([H])[H]")
>>> len(mol.atoms)
4
>>> mol.write("can")
'C\t\n'
>>>
I don't know if there's another pybel SMILES output option which prevents this
unification, but I have a trick up my sleeve. If I tag all atoms with an
isotope number then they must be written with []s, which means the SMILES will
also include the hydrogen counts.
>>> mol = pybel.readstring("smi", "OCN")
>>> mol.OBMol.DeleteAtom(mol.atoms[-1].OBAtom)
True
>>> for atom in mol.atoms:
... atom.OBAtom.SetIsotope(99)
...
>>> mol.write("can")
'[99CH3][99OH]\t\n'
>>> mol.write("can").replace("[99", "[")
'[CH3][OH]\t\n'
>>>
(If some of the atoms have an isotope then you'll have to be a bit more clever
and find a isotope number which isn't in use. After all, no real molecule has
all isotopes of all elements present.)
You should be able to use that SMILES as your SMARTS.
Andrew
[email protected]
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
OpenBabel-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss