PharmacophoreMatcher { public boolean matches(IAtomContainer atomContainer) throws CDKException { return matches(atomContainer, true); } PharmacophoreMatcher();  PharmacophoreMatcher(PharmacophoreQuery pharmacophoreQuery); boolean matches(IAtomContainer atomContainer); boolean matches(IAtomContainer atomContainer, boolean initializeTarget); List<List<IBond>> getMatchingPharmacophoreBonds(); List<HashMap<IBond, IBond>> getTargetQueryBondMappings(); List<List<PharmacophoreAtom>> getMatchingPharmacophoreAtoms(); List<List<PharmacophoreAtom>> getUniqueMatchingPharmacophoreAtoms(); PharmacophoreQuery getPharmacophoreQuery(); void setPharmacophoreQuery(PharmacophoreQuery query);  }
@Test public void testMatcherQuery1() throws Exception { Assert.assertNotNull(conformers); PharmacophoreQuery query = new PharmacophoreQuery(); PharmacophoreQueryAtom o = new PharmacophoreQueryAtom("D", "[OX1]"); PharmacophoreQueryAtom n1 = new PharmacophoreQueryAtom("A", "[N]"); PharmacophoreQueryAtom n2 = new PharmacophoreQueryAtom("A", "[N]"); query.addAtom(o); query.addAtom(n1); query.addAtom(n2); PharmacophoreQueryBond b1 = new PharmacophoreQueryBond(o, n1, 4.0, 4.5); PharmacophoreQueryBond b2 = new PharmacophoreQueryBond(o, n2, 4.0, 5.0); PharmacophoreQueryBond b3 = new PharmacophoreQueryBond(n1, n2, 5.4, 5.8); query.addBond(b1); query.addBond(b2); query.addBond(b3); PharmacophoreMatcher matcher = new PharmacophoreMatcher(query); boolean firstTime = true; int i = 0; boolean[] statuses = new boolean[100]; for (IAtomContainer conf : conformers) { if (firstTime) { statuses[i] = matcher.matches(conf, true); firstTime = false; } else statuses[i] = matcher.matches(conf, false); i++; } int[] hits = new int[18]; int idx = 0; for (i = 0; i < statuses.length; i++) { if (statuses[i]) hits[idx++] = i; } int[] expected = {0, 1, 2, 5, 6, 7, 8, 9, 10, 20, 23, 48, 62, 64, 66, 70, 76, 87}; for (i = 0; i < expected.length; i++) { Assert.assertEquals("Hit " + i + " didn't match", expected[i], hits[i]); } }
@Test(expected = CDKException.class) public void testInvalidQuery() throws CDKException { PharmacophoreQuery query = new PharmacophoreQuery(); PharmacophoreQueryAtom o = new PharmacophoreQueryAtom("D", "[OX1]"); PharmacophoreQueryAtom n1 = new PharmacophoreQueryAtom("A", "[N]"); PharmacophoreQueryAtom n2 = new PharmacophoreQueryAtom("A", "[NX3]"); query.addAtom(o); query.addAtom(n1); query.addAtom(n2); PharmacophoreQueryBond b1 = new PharmacophoreQueryBond(o, n1, 4.0, 4.5); PharmacophoreQueryBond b2 = new PharmacophoreQueryBond(o, n2, 4.0, 5.0); PharmacophoreQueryBond b3 = new PharmacophoreQueryBond(n1, n2, 5.4, 5.8); query.addBond(b1); query.addBond(b2); query.addBond(b3); PharmacophoreMatcher matcher = new PharmacophoreMatcher(query); matcher.matches(conformers.get(0)); }
@Test public void testAngleMatch1() throws Exception { String filename = "data/mdl/cnssmarts.sdf"; InputStream ins = PharmacophoreMatcherTest.class.getClassLoader().getResourceAsStream(filename); IteratingSDFReader reader = new IteratingSDFReader(ins, SilentChemObjectBuilder.getInstance()); PharmacophoreQuery query = new PharmacophoreQuery(); PharmacophoreQueryAtom n1 = new PharmacophoreQueryAtom("BasicAmine", "[NX3;h2,h1,H1,H2;!$(NC=O)]"); PharmacophoreQueryAtom n2 = new PharmacophoreQueryAtom("BasicAmine", "[NX3;h2,h1,H1,H2;!$(NC=O)]"); PharmacophoreQueryAtom n3 = new PharmacophoreQueryAtom("BasicAmine", "[NX3;h2,h1,H1,H2;!$(NC=O)]"); PharmacophoreQueryAngleBond b1 = new PharmacophoreQueryAngleBond(n1, n2, n3, 85, 90); query.addAtom(n1); query.addAtom(n2); query.addAtom(n3); query.addBond(b1); reader.hasNext(); IAtomContainer mol = (IAtomContainer) reader.next(); reader.close(); PharmacophoreMatcher matcher = new PharmacophoreMatcher(query); boolean status = matcher.matches(mol); Assert.assertTrue(status); }
@Test public void testAngleMatch2() throws Exception { String filename = "data/mdl/cnssmarts.sdf"; InputStream ins = PharmacophoreMatcherTest.class.getClassLoader().getResourceAsStream(filename); IteratingSDFReader reader = new IteratingSDFReader(ins, SilentChemObjectBuilder.getInstance()); PharmacophoreQuery query = new PharmacophoreQuery(); PharmacophoreQueryAtom n1 = new PharmacophoreQueryAtom("BasicAmine", "[NX3;h2,h1,H1,H2;!$(NC=O)]"); PharmacophoreQueryAtom n2 = new PharmacophoreQueryAtom("BasicAmine", "[NX3;h2,h1,H1,H2;!$(NC=O)]"); PharmacophoreQueryAtom n3 = new PharmacophoreQueryAtom("BasicAmine", "[NX3;h2,h1,H1,H2;!$(NC=O)]"); PharmacophoreQueryAngleBond b1 = new PharmacophoreQueryAngleBond(n1, n2, n3, 89.14); query.addAtom(n1); query.addAtom(n2); query.addAtom(n3); query.addBond(b1); reader.hasNext(); IAtomContainer mol = (IAtomContainer) reader.next(); reader.close(); PharmacophoreMatcher matcher = new PharmacophoreMatcher(query); boolean status = matcher.matches(mol); Assert.assertTrue(status); }
@Test public void testAngleMatch3() throws Exception { Assert.assertNotNull(conformers); PharmacophoreQuery query = new PharmacophoreQuery(); PharmacophoreQueryAtom o = new PharmacophoreQueryAtom("D", "[OX1]"); PharmacophoreQueryAtom n1 = new PharmacophoreQueryAtom("A", "[N]"); PharmacophoreQueryAtom n2 = new PharmacophoreQueryAtom("A", "[N]"); query.addAtom(o); query.addAtom(n1); query.addAtom(n2); PharmacophoreQueryAngleBond b1 = new PharmacophoreQueryAngleBond(o, n1, n2, 43, 47); query.addBond(b1); PharmacophoreMatcher matcher = new PharmacophoreMatcher(query); boolean firstTime = true; int i = 0; boolean[] statuses = new boolean[100]; for (IAtomContainer conf : conformers) { if (firstTime) { statuses[i] = matcher.matches(conf, true); firstTime = false; } else statuses[i] = matcher.matches(conf, false); i++; } Assert.assertEquals(100, statuses.length); int[] hits = new int[9]; int idx = 0; for (i = 0; i < statuses.length; i++) { if (statuses[i]) hits[idx++] = i; } int[] expected = {0, 6, 32, 33, 48, 54, 60, 62, 69}; for (i = 0; i < expected.length; i++) { Assert.assertEquals("Hit " + i + " didn't match", expected[i], hits[i]); } }