@Test public void testCalculateOverlapsAndReduce() throws Exception { IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); SmilesParser sp = new SmilesParser(builder); IAtomContainer Molecule1 = sp.parseSmiles("O1C=CC=C1"); IAtomContainer Molecule2 = sp.parseSmiles("C1CCCC1"); CDKRMapHandler instance = new CDKRMapHandler(); instance.calculateOverlapsAndReduce(Molecule1, Molecule2, true, false,false); Assert.assertNotNull(instance.getMappings().size()); }
public synchronized List<Map<Integer, Integer>> calculateOverlapsAndReduce(IAtomContainer molecule1, IAtomContainer molecule2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType) throws CDKException { setSource(molecule1); setTarget(molecule2); List<Map<Integer, Integer>> solution = new ArrayList<>(); setMappings(solution); if ((getSource().getAtomCount() == 1) || (getTarget().getAtomCount() == 1)) { List<CDKRMap> overlaps = CDKMCS.checkSingleAtomCases(getSource(), getTarget()); this.setTimeout(CDKMCS.isTimeout()); int nAtomsMatched = overlaps.size(); nAtomsMatched = (nAtomsMatched > 0) ? 1 : 0; if (nAtomsMatched > 0) { identifySingleAtomsMatchedParts(overlaps, getSource(), getTarget()); } } else { List<List<CDKRMap>> overlaps = CDKMCS.search(getSource(), getTarget(), new BitSet(), new BitSet(), true, true, shouldMatchBonds, shouldMatchRings, matchAtomType); this.setTimeout(CDKMCS.isTimeout()); List<List<CDKRMap>> reducedList = removeSubGraph(overlaps); Stack<List<CDKRMap>> allMaxOverlaps = getAllMaximum(reducedList); while (!allMaxOverlaps.empty()) { List<List<CDKRMap>> maxOverlapsAtoms = makeAtomsMapOfBondsMap(allMaxOverlaps.peek(), getSource(), getTarget()); identifyMatchedParts(maxOverlapsAtoms, getSource(), getTarget()); allMaxOverlaps.pop(); } } return solution; }
CDKRMapHandler { public synchronized List<Map<Integer, Integer>> calculateOverlapsAndReduce(IAtomContainer molecule1, IAtomContainer molecule2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType) throws CDKException { setSource(molecule1); setTarget(molecule2); List<Map<Integer, Integer>> solution = new ArrayList<>(); setMappings(solution); if ((getSource().getAtomCount() == 1) || (getTarget().getAtomCount() == 1)) { List<CDKRMap> overlaps = CDKMCS.checkSingleAtomCases(getSource(), getTarget()); this.setTimeout(CDKMCS.isTimeout()); int nAtomsMatched = overlaps.size(); nAtomsMatched = (nAtomsMatched > 0) ? 1 : 0; if (nAtomsMatched > 0) { identifySingleAtomsMatchedParts(overlaps, getSource(), getTarget()); } } else { List<List<CDKRMap>> overlaps = CDKMCS.search(getSource(), getTarget(), new BitSet(), new BitSet(), true, true, shouldMatchBonds, shouldMatchRings, matchAtomType); this.setTimeout(CDKMCS.isTimeout()); List<List<CDKRMap>> reducedList = removeSubGraph(overlaps); Stack<List<CDKRMap>> allMaxOverlaps = getAllMaximum(reducedList); while (!allMaxOverlaps.empty()) { List<List<CDKRMap>> maxOverlapsAtoms = makeAtomsMapOfBondsMap(allMaxOverlaps.peek(), getSource(), getTarget()); identifyMatchedParts(maxOverlapsAtoms, getSource(), getTarget()); allMaxOverlaps.pop(); } } return solution; } }
CDKRMapHandler { public synchronized List<Map<Integer, Integer>> calculateOverlapsAndReduce(IAtomContainer molecule1, IAtomContainer molecule2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType) throws CDKException { setSource(molecule1); setTarget(molecule2); List<Map<Integer, Integer>> solution = new ArrayList<>(); setMappings(solution); if ((getSource().getAtomCount() == 1) || (getTarget().getAtomCount() == 1)) { List<CDKRMap> overlaps = CDKMCS.checkSingleAtomCases(getSource(), getTarget()); this.setTimeout(CDKMCS.isTimeout()); int nAtomsMatched = overlaps.size(); nAtomsMatched = (nAtomsMatched > 0) ? 1 : 0; if (nAtomsMatched > 0) { identifySingleAtomsMatchedParts(overlaps, getSource(), getTarget()); } } else { List<List<CDKRMap>> overlaps = CDKMCS.search(getSource(), getTarget(), new BitSet(), new BitSet(), true, true, shouldMatchBonds, shouldMatchRings, matchAtomType); this.setTimeout(CDKMCS.isTimeout()); List<List<CDKRMap>> reducedList = removeSubGraph(overlaps); Stack<List<CDKRMap>> allMaxOverlaps = getAllMaximum(reducedList); while (!allMaxOverlaps.empty()) { List<List<CDKRMap>> maxOverlapsAtoms = makeAtomsMapOfBondsMap(allMaxOverlaps.peek(), getSource(), getTarget()); identifyMatchedParts(maxOverlapsAtoms, getSource(), getTarget()); allMaxOverlaps.pop(); } } return solution; } CDKRMapHandler(); }
CDKRMapHandler { public synchronized List<Map<Integer, Integer>> calculateOverlapsAndReduce(IAtomContainer molecule1, IAtomContainer molecule2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType) throws CDKException { setSource(molecule1); setTarget(molecule2); List<Map<Integer, Integer>> solution = new ArrayList<>(); setMappings(solution); if ((getSource().getAtomCount() == 1) || (getTarget().getAtomCount() == 1)) { List<CDKRMap> overlaps = CDKMCS.checkSingleAtomCases(getSource(), getTarget()); this.setTimeout(CDKMCS.isTimeout()); int nAtomsMatched = overlaps.size(); nAtomsMatched = (nAtomsMatched > 0) ? 1 : 0; if (nAtomsMatched > 0) { identifySingleAtomsMatchedParts(overlaps, getSource(), getTarget()); } } else { List<List<CDKRMap>> overlaps = CDKMCS.search(getSource(), getTarget(), new BitSet(), new BitSet(), true, true, shouldMatchBonds, shouldMatchRings, matchAtomType); this.setTimeout(CDKMCS.isTimeout()); List<List<CDKRMap>> reducedList = removeSubGraph(overlaps); Stack<List<CDKRMap>> allMaxOverlaps = getAllMaximum(reducedList); while (!allMaxOverlaps.empty()) { List<List<CDKRMap>> maxOverlapsAtoms = makeAtomsMapOfBondsMap(allMaxOverlaps.peek(), getSource(), getTarget()); identifyMatchedParts(maxOverlapsAtoms, getSource(), getTarget()); allMaxOverlaps.pop(); } } return solution; } CDKRMapHandler(); synchronized IAtomContainer getSource(); synchronized void setSource(IAtomContainer aSource); synchronized IAtomContainer getTarget(); synchronized void setTarget(IAtomContainer aTarget); synchronized List<Map<Integer, Integer>> calculateOverlapsAndReduce(IAtomContainer molecule1,
            IAtomContainer molecule2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); synchronized List<Map<Integer, Integer>> calculateOverlapsAndReduce(IAtomContainer molecule1,
            IQueryAtomContainer molecule2); synchronized void calculateOverlapsAndReduceExactMatch(
            IAtomContainer Molecule1,
            IAtomContainer Molecule2,
            boolean shouldMatchBonds,
            boolean shouldMatchRings,
            boolean matchAtomType); synchronized List<Map<Integer, Integer>> calculateSubGraphs(IAtomContainer Molecule1,
            IAtomContainer Molecule2,
            boolean shouldMatchBonds,
            boolean shouldMatchRings,
            boolean matchAtomType); synchronized List<Map<Integer, Integer>> calculateIsomorphs(IAtomContainer Molecule1,
            IAtomContainer Molecule2,
            boolean shouldMatchBonds,
            boolean shouldMatchRings,
            boolean matchAtomType); synchronized List<Map<Integer, Integer>> getMappings(); synchronized void setMappings(List<Map<Integer, Integer>> mappings); boolean isTimeout(); void setTimeout(boolean timeout); }
CDKRMapHandler { public synchronized List<Map<Integer, Integer>> calculateOverlapsAndReduce(IAtomContainer molecule1, IAtomContainer molecule2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType) throws CDKException { setSource(molecule1); setTarget(molecule2); List<Map<Integer, Integer>> solution = new ArrayList<>(); setMappings(solution); if ((getSource().getAtomCount() == 1) || (getTarget().getAtomCount() == 1)) { List<CDKRMap> overlaps = CDKMCS.checkSingleAtomCases(getSource(), getTarget()); this.setTimeout(CDKMCS.isTimeout()); int nAtomsMatched = overlaps.size(); nAtomsMatched = (nAtomsMatched > 0) ? 1 : 0; if (nAtomsMatched > 0) { identifySingleAtomsMatchedParts(overlaps, getSource(), getTarget()); } } else { List<List<CDKRMap>> overlaps = CDKMCS.search(getSource(), getTarget(), new BitSet(), new BitSet(), true, true, shouldMatchBonds, shouldMatchRings, matchAtomType); this.setTimeout(CDKMCS.isTimeout()); List<List<CDKRMap>> reducedList = removeSubGraph(overlaps); Stack<List<CDKRMap>> allMaxOverlaps = getAllMaximum(reducedList); while (!allMaxOverlaps.empty()) { List<List<CDKRMap>> maxOverlapsAtoms = makeAtomsMapOfBondsMap(allMaxOverlaps.peek(), getSource(), getTarget()); identifyMatchedParts(maxOverlapsAtoms, getSource(), getTarget()); allMaxOverlaps.pop(); } } return solution; } CDKRMapHandler(); synchronized IAtomContainer getSource(); synchronized void setSource(IAtomContainer aSource); synchronized IAtomContainer getTarget(); synchronized void setTarget(IAtomContainer aTarget); synchronized List<Map<Integer, Integer>> calculateOverlapsAndReduce(IAtomContainer molecule1,
            IAtomContainer molecule2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); synchronized List<Map<Integer, Integer>> calculateOverlapsAndReduce(IAtomContainer molecule1,
            IQueryAtomContainer molecule2); synchronized void calculateOverlapsAndReduceExactMatch(
            IAtomContainer Molecule1,
            IAtomContainer Molecule2,
            boolean shouldMatchBonds,
            boolean shouldMatchRings,
            boolean matchAtomType); synchronized List<Map<Integer, Integer>> calculateSubGraphs(IAtomContainer Molecule1,
            IAtomContainer Molecule2,
            boolean shouldMatchBonds,
            boolean shouldMatchRings,
            boolean matchAtomType); synchronized List<Map<Integer, Integer>> calculateIsomorphs(IAtomContainer Molecule1,
            IAtomContainer Molecule2,
            boolean shouldMatchBonds,
            boolean shouldMatchRings,
            boolean matchAtomType); synchronized List<Map<Integer, Integer>> getMappings(); synchronized void setMappings(List<Map<Integer, Integer>> mappings); boolean isTimeout(); void setTimeout(boolean timeout);  }