>From Python, it goes something like this...

>>> import openbabel as ob
>>> conv = ob.OBConversion()
>>> mol = ob.OBMol()
>>> conv.SetInFormat("smi")
True
>>> conv.ReadString(mol, "CC(=O)Cl")
True
>>> fingerprinter = ob.OBFingerprint.FindFingerprint("FP2")
>>> print fingerprinter
<openbabel.OBFingerprint; proxy of <Swig Object of type 'OpenBabel::OBFingerprin
t *' at 0x0039F368> >
>>> fp = ob.vectorUnsignedInt()
>>> fingerprinter.GetFingerprint(mol, fp)
True
>>> print [x for x in fp]
[131072, 0, 0, 0, 0, 0, 134217728, 0, 0, 0, 768, 0, 0, 0, 0, 0, 0, 0, 0, 32768,
1073741824, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> print ob.OBFingerprint.Tanimoto(fp, fp)
1.0
>>>

Hope this helps,
   Noel

On 11 January 2012 14:06, alvin <alvin.past...@gmail.com> wrote:
> Hi everybody.
> I'm trying to use Java implementation of open babel to solve a problem.
> The problem is pretty simple. I have to convert some molecules in smiles
> format in fingerprints in order to calculate after the tanimoto score.
> I took a look at the documentation and I found that in pybel exists a method
> called calcfp() which does perfectly what I need to be done.
>
> http://openbabel.org/docs/current/UseTheLibrary/Python_Pybel.html#fingerprints
>
> Now, in Java I'm trying to do the same but I'm finding myself stuck because
> the method calcfp() does not exist.
>
> Here's my Java code
>
> OBMol myMol = new OBMol();
> OBConversion c = new OBConversion();
> // Is it correct to use FTP format? Do I have to use the FP2 instead?
> c.SetInAndOutFormats("SMI", "FPT");
>
> c.ReadString(myMol, "CCC");
> System.out.println(c.WriteString(myMol));
>
> c.Convert();
> System.out.println(c.WriteString(mol));
>
> Thanks for any help.
> Alvin
>
> --
> View this message in context: 
> http://forums.openbabel.org/Java-implementation-of-pybel-s-calcfp-to-convert-smiles-into-fingerprint-tp4285497p4285497.html
> Sent from the General discussion mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to