private synchronized void mcsBuilder(IQueryAtomContainer mol1, IAtomContainer mol2) { int rBondCount = mol1.getBondCount(); int pBondCount = mol2.getBondCount(); int rAtomCount = mol1.getAtomCount(); int pAtomCount = mol2.getAtomCount(); if ((rBondCount == 0 && rAtomCount > 0) || (pBondCount == 0 && pAtomCount > 0)) { singleMapping(); } else { chooseAlgorithm(); } }
private boolean hasAngleConstraints(IQueryAtomContainer query) { for (IBond bond : query.bonds()) { if (bond instanceof PharmacophoreQueryAngleBond) return true; } return false; }
private boolean checkQuery(IQueryAtomContainer query) { if (!(query instanceof PharmacophoreQuery)) return false; HashMap<String, String> map = new HashMap<String, String>(); for (int i = 0; i < query.getAtomCount(); i++) { IQueryAtom atom = (IQueryAtom) query.getAtom(i); if (!(atom instanceof PharmacophoreQueryAtom)) return false; PharmacophoreQueryAtom pqatom = (PharmacophoreQueryAtom) atom; String label = pqatom.getSymbol(); String smarts = pqatom.getSmarts(); if (!map.containsKey(label)) map.put(label, smarts); else { if (!map.get(label).equals(smarts)) return false; } } return true; }
for (int atomIndex = 0; atomIndex < query.getBondCount(); atomIndex++) { Integer indexI = query.indexOf(query.getBond(atomIndex).getAtom(0)); Integer indexJ = query.indexOf(query.getBond(atomIndex).getAtom(1)); Integer order = 0; if (query.getBond(atomIndex).getOrder() != null) { order = query.getBond(atomIndex).getOrder().numeric();
Assert.assertEquals(3, def1.getAtomCount()); Assert.assertEquals(2, def1.getBondCount()); Assert.assertEquals("A modified definition for the D1 receptor", def1.getProperty("description")); for (IAtom atom : def1.atoms()) { String sym = atom.getSymbol(); boolean found = false; for (IBond bond : def1.bonds()) { if (bond instanceof PharmacophoreQueryBond) { PharmacophoreQueryBond cons = (PharmacophoreQueryBond) bond;
/** * Constructor for the McGregor algorithm. * * @param source * @param target * @param mappings */ public McGregor(IQueryAtomContainer source, IAtomContainer target, List<List<Integer>> mappings) { this.shouldMatchRings = true; this.bondMatch = true; this.matchAtomType = true; this.target = target; this.mappings = Collections.synchronizedList(mappings); this.bestarcsleft = 0; setIterationManager(new IterationManager((source.getAtomCount() + this.target.getAtomCount()) * 1000)); if (!mappings.isEmpty()) { this.globalMCSSize = mappings.get(0).size(); } else { this.globalMCSSize = 0; } this.modifiedARCS = Collections.synchronizedList(new ArrayList<Integer>()); this.bestARCS = new Stack<>(); this.newMatrix = false; }
neighbors.get(prev).add(atom); query.addBond(bond); bond = null; query.addAtom(atom); if (tetrahedral.get(query.getAtomCount() - 1)) { List<IAtom> localNeighbors = new ArrayList<IAtom>(query.getConnectedAtomsList(atom)); localNeighbors.add(atom); neighbors.put(atom, localNeighbors); query.addBond(bond); query.addAtom(newAtom); if (tetrahedral.get(query.getAtomCount() - 1)) { List<IAtom> localNeighbors = new ArrayList<IAtom>(query.getConnectedAtomsList(newAtom)); localNeighbors.add(newAtom); neighbors.put(newAtom, localNeighbors);
@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); } }
IQueryAtomContainer clone = (IQueryAtomContainer) super.clone(); clone.removeAllElements(); clone.addAtom((IAtom) getAtom(f).clone()); newAtoms = new IAtom[bond.getAtomCount()]; for (int j = 0; j < bond.getAtomCount(); ++j) { newAtoms[j] = clone.getAtom(getAtomNumber(bond.getAtom(j))); clone.addBond(newBond); newLp = (ILonePair) lp.clone(); if (lp.getAtom() != null) { newLp.setAtom(clone.getAtom(getAtomNumber(lp.getAtom()))); clone.addLonePair(newLp); newSe = (ISingleElectron) se.clone(); if (se.getAtom() != null) { newSe.setAtom(clone.getAtom(getAtomNumber(se.getAtom()))); clone.addSingleElectron(newSe);
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; }
for (int atomIndex = 0; atomIndex < query.getBondCount(); atomIndex++) { Integer indexI = query.getAtomNumber(query.getBond(atomIndex).getAtom(0)); Integer indexJ = query.getAtomNumber(query.getBond(atomIndex).getAtom(1)); Integer order = 0; if (query.getBond(atomIndex).getOrder() != null) { order = query.getBond(atomIndex).getOrder().numeric();
DfState(IQueryAtomContainer query) { IChemObjectBuilder builder = query.getBuilder(); if (builder == null) { builder = findBuilder(); if (builder == null) throw new IllegalArgumentException("Please ensure query molecule" + "has a IChemObjectBuilder set!"); } IAtomContainer tmp = builder.newAtomContainer(); tmp.add(query); this.qbonds = new IQueryBond[tmp.getBondCount()]; this.amap = new int[query.getAtomCount()]; int stackSize = 0; for (IAtom atom : tmp.atoms()) { if (atom instanceof IQueryAtom) { if (amap[atom.getIndex()] == 0) { stackSize += prepare(atom, null) + 1; } } else throw new IllegalArgumentException( "All atoms must be IQueryAtoms!"); } this.stack = new StackFrame[stackSize + 2]; for (int i = 0; i < stack.length; i++) this.stack[i] = new StackFrame(); this.numAtoms = amap.length; this.query = tmp; }
if (cTab1Copy.get(atomIndex * 4 + 3).compareToIgnoreCase("X") == 0) { step1(atomIndex, counter); McGregorChecks.changeCharBonds(indexJ, signs[counter], query.getBondCount(), (IQueryAtomContainer) query, cTab1Copy); int cor_atom = searchCorrespondingAtom(newNeighborNumA, indexJ, 1, mapped_atoms); McGregorChecks.changeCharBonds(cor_atom, signs[counter], target.getBondCount(), target, cTab2Copy); if (cTab1Copy.get(atomIndex * 4 + 2).compareToIgnoreCase("X") == 0) { step3(atomIndex, counter); McGregorChecks.changeCharBonds(indexI, signs[counter], query.getBondCount(), (IQueryAtomContainer) query, cTab1Copy); int cor_atom = searchCorrespondingAtom(newNeighborNumA, indexI, 1, mapped_atoms); McGregorChecks.changeCharBonds(cor_atom, signs[counter], target.getBondCount(), target, cTab2Copy);
query.addBond((IBond) ringBond);
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!"); } } }
/** * Returns single mapping solutions. * * @param source * @param target * @return Mappings * @throws CDKException */ protected synchronized List<Map<IAtom, IAtom>> getOverLaps( IQueryAtomContainer source, IAtomContainer target, AtomMatcher am) throws CDKException { List<Map<IAtom, IAtom>> mappings = new ArrayList<>(); this.source = source; this.target = target; if (source.getAtomCount() > 0) { setSingleAtomMap(mappings, am); } return postFilter(mappings); }
for (int atomIndex = 0; atomIndex < query.getBondCount(); atomIndex++) { Integer indexI = query.indexOf(query.getBond(atomIndex).getBegin()); Integer indexJ = query.indexOf(query.getBond(atomIndex).getEnd()); Integer order = 0; if (query.getBond(atomIndex).getOrder() != null) { order = query.getBond(atomIndex).getOrder().numeric();
if (cTab1Copy.get(atomIndex * 4 + 3).compareToIgnoreCase("X") == 0) { step1(atomIndex, counter); McGregorChecks.changeCharBonds(indexJ, signs[counter], query.getBondCount(), (IQueryAtomContainer) query, cTab1Copy); int cor_atom = searchCorrespondingAtom(newNeighborNumA, indexJ, 1, mapped_atoms); McGregorChecks.changeCharBonds(cor_atom, signs[counter], target.getBondCount(), target, cTab2Copy); if (cTab1Copy.get(atomIndex * 4 + 2).compareToIgnoreCase("X") == 0) { step3(atomIndex, counter); McGregorChecks.changeCharBonds(indexI, signs[counter], query.getBondCount(), (IQueryAtomContainer) query, cTab1Copy); int cor_atom = searchCorrespondingAtom(newNeighborNumA, indexI, 1, mapped_atoms); McGregorChecks.changeCharBonds(cor_atom, signs[counter], target.getBondCount(), target, cTab2Copy);