Calculating Tanimoto Coefficients

User 2347372188

19-04-2013 16:25:12

Hello.  I am trying to calculate Tanimoto coefficients between Molecules in a small set.  Unfortunately, I can't seem to find the right incantation of JChem classes and methods to get a proper Tanimoto computed between two Molecule objects.  I noticed others trying to do something similar.  However, I haven't seen any code examples on how to do so.  Below I've listed my latest attempt to compute a Tanimoto coefficient.  Please correct my code.  Thanks!

// get Molecule objects from somewhere

Molecule m1

Molecule m2

        CFParameters cfps = new CFParameters();




        ChemicalFingerprint cf1 = new ChemicalFingerprint(cfps);

        ChemicalFingerprint cf2 = new ChemicalFingerprint(cfps);

        CFGenerator cfgs = new CFGenerator();

        String[] fp1 = cfgs.generate(m1.molecule, cf1);

        byte[] ba1 = cf1.toData();

        String[] fp2 = cfgs.generate(pc2.molecule, cf2);

        byte[] ba2 = cf2.toData();

        Double tan = Similarity.getTanimoto(ba1, ba2);



// Then loop to the next compounds.  Can I reuse the ChemicalFingerprint objects or do I need to create new

// objects?  



ChemAxon 1b9e90b2e7

19-04-2013 18:43:05

Hi Steve,

please find a code example here:

Hope this helps, but if you need more specific example, please let me know.

Kind regards,