use of ambit2.similarity.measure.AtomEnvironmentsDistance in project ambit-mirror by ideaconsult.
the class AtomEnvironmentHammingDistanceTest method testGetDistance.
/**
* Test method for {@link ambit2.similarity.AtomEnvironmentHammingDistance#getDistance(ambit2.data.descriptors.AtomEnvironmentList, ambit2.data.descriptors.AtomEnvironmentList)}.
*/
@Test
public void testGetDistance() throws Exception {
IAtomContainer mol = MoleculeFactory.makeAlkane(3);
IAtomContainer mol1 = MoleculeFactory.makeAlkane(3);
SmilesParserWrapper p = SmilesParserWrapper.getInstance();
IAtomContainer mol2 = p.parseSmiles("CCCC");
AtomEnvironmentGenerator g = new AtomEnvironmentGenerator();
g.setUseHydrogens(true);
g.setMaxLevels(3);
AtomEnvironmentList ae = g.generateProperty(mol);
AtomEnvironmentList ae1 = g.generateProperty(mol1);
AtomEnvironmentList ae2 = g.generateProperty(mol2);
AtomEnvironmentsDistance hd = new AtomEnvironmentsDistance();
Assert.assertEquals(1.0, hd.getDistance(ae, ae1), 1E-10);
Assert.assertEquals(hd.getDistance(ae1, ae), hd.getDistance(ae, ae1), 1E-10);
System.out.println(ae);
System.out.println(ae2);
float d = hd.getDistance(ae, ae2);
// System.out.println(d);
Assert.assertTrue(d < 1.0);
Assert.assertEquals(hd.getDistance(ae2, ae), hd.getDistance(ae1, ae2), 1E-10);
}
use of ambit2.similarity.measure.AtomEnvironmentsDistance in project ambit-mirror by ideaconsult.
the class MySelector method testCH3difference.
public void testCH3difference(boolean display) throws Exception {
IMolecularDescriptor descriptor = new AtomEnvironmentDescriptor();
int maxLevel = 3;
Object[] params = { null, new Integer(maxLevel), new Boolean(true), new Boolean(true) };
SmilesParserWrapper sp = SmilesParserWrapper.getInstance();
// IAtomContainer mol = sp.parseSmiles("O=N(=O)c1ccc(O)c(N)c1");
// Amino-2nitro-3.4-5 hydroxy-methyl benzene (ANMB)
// IAtomContainer mol1 = sp.parseSmiles("Cc1c(C)c(cc(N)c1(O))N(=O)=O");
IAtomContainer molecule1 = sp.parseSmiles("Nc1c(C)cccc1");
// Amino-2nitro-3.4-5 hydroxy-methyl benzene (ANMB)
IAtomContainer molecule2 = sp.parseSmiles("Nc1c(O)cccc1");
// Amino-2nitro-3.4-5 hydroxy-methyl benzene (ANMB)
AtomEnvironmentGenerator g = new AtomEnvironmentGenerator();
g.setNoDuplicates(false);
g.setUseHydrogens(true);
g.setMaxLevels(maxLevel);
AtomEnvironmentList ae = g.generateProperty(molecule1);
AtomEnvironmentList ae1 = g.generateProperty(molecule2);
Collections.sort(ae);
Collections.sort(ae1);
AtomEnvironmentsDistance d = new AtomEnvironmentsDistance();
System.out.println("distance " + d.getDistance(ae, ae1));
Set<AtomEnvironment> set = new TreeSet<AtomEnvironment>();
Set<AtomEnvironment> set1 = new TreeSet<AtomEnvironment>();
for (int i = 0; i < ae.size(); i++) set.add(ae.get(i));
for (int i = 0; i < ae1.size(); i++) set1.add(ae1.get(i));
System.out.println(set);
System.out.println();
System.out.println(set1);
Assert.assertNotSame(set, set1);
Set intersection = (Set) ((TreeSet) set1).clone();
intersection.retainAll(set);
System.out.println("Intersection\t" + intersection.size());
System.out.println(intersection);
if (display)
displayAE(molecule1, ae, molecule2, ae1);
Assert.assertNotNull(ae);
Assert.assertNotNull(ae1);
}
Aggregations