On 26/01/2011 01:16, Craig A. James wrote:
On 1/25/11 3:33 PM, Andrew Dalke wrote:
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 ...
I don't know about pybel, but for babel(1) there's a command-line option that 
may do what you need.  It doesn't keep the explicit H atoms as separate atoms, 
but it does produce a SMARTS that has the correct H count:

     babel -Hcan
       ...
       h  Output explicit hydrogens as such

     echo "[CH3]C" | babel -i smi -o can -xh
     C[CH3]
     1 molecule converted

In C++, you do it like this:

   OBConversion *pconv = new OBConversion;
   pconv->SetInAndOutFormats("smi", "can");
   pconv->SetOptions("h", OBCONVERSONI::OUTOPTIONS);
As may have been discussed here earlier, maybe this option should output explicit hydrogen as [H] rather than a hydrogen count on another atom. SMARTS [CH2] matches a C with/exactly/ two Hs; SMARTS [H]C[H] will match a carbon with/at least/ two Hs and is more versatile in substructure searches. Would there be any objections to me changing it in the development code?

Chris
------------------------------------------------------------------------------
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

Reply via email to