private void setSourceSingleAtomMap(IQueryAtomContainer source, boolean removeHydrogen) throws CDKException { int counter = 0; BondEnergies be = BondEnergies.getInstance(); for (IAtom sourceAtom : source.atoms()) { IQueryAtom smartAtom = (IQueryAtom) sourceAtom; if ((removeHydrogen && !smartAtom.getSymbol().equals("H")) || (!removeHydrogen)) { for (IAtom targetAtom : target.atoms()) { Map<IAtom, IAtom> mapAtoms = new HashMap<IAtom, IAtom>(); if (smartAtom.matches(targetAtom)) { mapAtoms.put(sourceAtom, targetAtom); List<IBond> bonds = target.getConnectedBondsList(targetAtom); double totalOrder = 0; for (IBond bond : bonds) { Order order = bond.getOrder(); totalOrder += order.numeric() + be.getEnergies(bond); } if (!Objects.equals(targetAtom.getFormalCharge(), sourceAtom.getFormalCharge())) { totalOrder += 0.5; } connectedBondOrder.put(counter, totalOrder); mappings.add(counter++, mapAtoms); } } } else { System.err.println("Skippping Hydrogen mapping or This is not a single mapping case!"); } } }
private IQuery build(IQueryAtomContainer queryMolecule) { VFQueryBuilder result = new VFQueryBuilder(); for (IAtom atoms : queryMolecule.atoms()) { IQueryAtom atom = (IQueryAtom) atoms; VFAtomMatcher matcher = createAtomMatcher(atom, queryMolecule); if (matcher != null) { result.addNode(matcher, atom); } } for (int i = 0; i < queryMolecule.getBondCount(); i++) { IBond bond = queryMolecule.getBond(i); IQueryAtom atomI = (IQueryAtom) bond.getBegin(); IQueryAtom atomJ = (IQueryAtom) bond.getEnd(); result.connect(result.getNode(atomI), result.getNode(atomJ), createBondMatcher((IQueryBond) bond)); } return result; }
@Test public void testReadPcoreDef() throws Exception { String filename = "data/pcore/pcore.xml"; InputStream ins = PharmacophoreUtilityTest.class.getClassLoader().getResourceAsStream(filename); List<PharmacophoreQuery> defs = PharmacophoreUtils.readPharmacophoreDefinitions(ins); Assert.assertEquals(2, defs.size()); IQueryAtomContainer def1 = defs.get(0); Assert.assertEquals(4, def1.getAtomCount()); Assert.assertEquals(2, def1.getBondCount()); Assert.assertEquals("An imaginary pharmacophore definition", def1.getProperty("description")); Assert.assertEquals("Imaginary", def1.getTitle()); IQueryAtomContainer def2 = defs.get(1); Assert.assertEquals(3, def2.getAtomCount()); Assert.assertEquals(3, def2.getBondCount()); Assert.assertNull(def2.getTitle()); String[] ids = {"Aromatic", "Hydroxyl", "BasicAmine"}; for (IAtom atom : def2.atoms()) { String sym = atom.getSymbol(); boolean found = false; for (String s : ids) { if (sym.equals(s)) { found = true; break; } } Assert.assertTrue("'" + sym + "' in pcore.xml is invalid", found); } }
for (IAtom atom : def1.atoms()) { String sym = atom.getSymbol(); boolean found = false;