DistanceMoment { public static float calculate(IAtomContainer query, IAtomContainer target) throws CDKException { float[] mom1 = generateMoments(query); float[] mom2 = generateMoments(target); float sum = 0; for (int i = 0; i < mom1.length; i++) { sum += Math.abs(mom1[i] - mom2[i]); } return (float) (1.0 / (1.0 + sum / 12.0)); }  static float[] generateMoments(IAtomContainer atomContainer); static float calculate(IAtomContainer query, IAtomContainer target);  }
@Test public void test3DSim1() throws Exception { String filename = "data/mdl/sim3d1.sdf"; IAtomContainer ac = loadMolecule(filename); float sim = DistanceMoment.calculate(ac, ac); Assert.assertEquals(1.0000, sim, 0.00001); }
@Test public void test3DSim2() throws Exception { IAtomContainer ac1 = loadMolecule("data/mdl/sim3d1.sdf"); IAtomContainer ac2 = loadMolecule("data/mdl/sim3d2.sdf"); float sim = DistanceMoment.calculate(ac1, ac2); Assert.assertEquals(0.24962, sim, 0.00001); }