-ofpt means use the fpt output format. -xs means set the "s" output
option. Pybel however does not support options like this, so we need
to use the underlying library.

import pybel

# Set up converter
conv = pybel.ob.OBConversion()
conv.SetOutFormat("fpt")
conv.SetOptions("s", conv.OUTOPTIONS)

# Get a molecule
mol = pybel.readstring("smi", "CCC")

#Write it using the converter
output = conv.WriteString(mol.OBMol)
print output

...gives
>
0 6 1 6 <670>
0 6 1 6 1 6 <260>

HTH,
   Noel

On 28 March 2012 21:50, ke wu <wkcoke.w...@gmail.com> wrote:
> Hi Noel
>
> My question is, in the command line we can use obabel -:"CCC" -ofpt -xs to
> generate the chemical fragment. But is there any possible way to make it
> happen in python using either pybel or openbabel?
>
> I tried calcfp(), but it can just generate another type of sequence(I don't
> know how to name it), or if using calcfp().bits, it will give the hex
> number. I realize that in openbabel there is a Getfingerprint function. I
> tried to use it but I can hardly understand the C code on the website.
>
> Generally I assume that we can realize everything in python with
> openbabel.py just as we do with command line.
>
> If I have to use the command line first to generate the chemical fragments
> and then save it to a file, read it by python and do the following work, it
> will be rather time-consuming.
>
> Best
>
> --
> Wu Ke
> Civil and Environmental Engineering
> Rensselaer Polytechnic Institute
> Tel:+15189515917
> wkcoke.w...@gmail.com
>
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to