Tanimoto { public static double method1(ICountFingerprint fp1, ICountFingerprint fp2) { long xy = 0, x = 0, y = 0; for (int i = 0; i < fp1.numOfPopulatedbins(); i++) { int hash = fp1.getHash(i); for (int j = 0; j < fp2.numOfPopulatedbins(); j++) { if (hash == fp2.getHash(j)) { xy += fp1.getCount(i) * fp2.getCount(j); } } x += fp1.getCount(i) * fp1.getCount(i); } for (int j = 0; j < fp2.numOfPopulatedbins(); j++) { y += fp2.getCount(j) * fp2.getCount(j); } return ((double) xy / (x + y - xy)); } private  Tanimoto(); static float calculate(BitSet bitset1, BitSet bitset2); static double calculate(IBitFingerprint fingerprint1, IBitFingerprint fingerprint2); static float calculate(double[] features1, double[] features2); static float calculate(Map<String, Integer> features1, Map<String, Integer> features2); static double calculate(ICountFingerprint fp1, ICountFingerprint fp2); static double method1(ICountFingerprint fp1, ICountFingerprint fp2); static double method2(ICountFingerprint fp1, ICountFingerprint fp2);  }
@Test public void method1() throws CDKException { ICountFingerprint fp1 = new IntArrayCountFingerprint(new HashMap<String, Integer>() { { put("A", 3); } }); ICountFingerprint fp2 = new IntArrayCountFingerprint(new HashMap<String, Integer>() { { put("A", 4); } }); Assert.assertEquals(0.923, Tanimoto.method1(fp1, fp2), 0.001); }