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();
cfps.setLength(1024);
cfps.setBondCount(6);
cfps.setBitCount(2);
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);
cf1.clear();
cf2.clear();
// Then loop to the next compounds. Can I reuse the ChemicalFingerprint objects or do I need to create new
// objects?
Thanks.
-&