@Test public void testBasicQueryAtomContainer() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer atomContainer = sp.parseSmiles("CC(=O)OC(=O)C"); IAtomContainer SMILESquery = sp.parseSmiles("CC"); QueryAtomContainer query = QueryAtomContainerCreator.createBasicQueryContainer(SMILESquery); Assert.assertTrue(CDKMCS.isSubgraph(atomContainer, query, true, true, true)); }
public static boolean isSubgraph(IAtomContainer g1, IAtomContainer g2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType) throws CDKException { if (g1 instanceof IQueryAtomContainer) { throw new CDKException( "The first IAtomContainer must not be an IQueryAtomContainer"); } if (g2.getAtomCount() > g1.getAtomCount()) { return false; } if (g2.getAtomCount() == 1) { IAtom atom = g2.getAtom(0); for (int i = 0; i < g1.getAtomCount(); i++) { IAtom atom2 = g1.getAtom(i); if (atom instanceof IQueryAtom) { IQueryAtom qAtom = (IQueryAtom) atom; if (qAtom.matches(atom2)) { return true; } } else if (atom2 instanceof IQueryAtom) { IQueryAtom qAtom = (IQueryAtom) atom2; if (qAtom.matches(atom)) { return true; } } else { return atom2.getSymbol().equals(atom.getSymbol()); } } return false; } if (!testSubgraphHeuristics(g1, g2)) { return false; } return (getSubgraphMap(g1, g2, shouldMatchBonds, shouldMatchRings, matchAtomType) != null); }
CDKMCS { public static boolean isSubgraph(IAtomContainer g1, IAtomContainer g2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType) throws CDKException { if (g1 instanceof IQueryAtomContainer) { throw new CDKException( "The first IAtomContainer must not be an IQueryAtomContainer"); } if (g2.getAtomCount() > g1.getAtomCount()) { return false; } if (g2.getAtomCount() == 1) { IAtom atom = g2.getAtom(0); for (int i = 0; i < g1.getAtomCount(); i++) { IAtom atom2 = g1.getAtom(i); if (atom instanceof IQueryAtom) { IQueryAtom qAtom = (IQueryAtom) atom; if (qAtom.matches(atom2)) { return true; } } else if (atom2 instanceof IQueryAtom) { IQueryAtom qAtom = (IQueryAtom) atom2; if (qAtom.matches(atom)) { return true; } } else { return atom2.getSymbol().equals(atom.getSymbol()); } } return false; } if (!testSubgraphHeuristics(g1, g2)) { return false; } return (getSubgraphMap(g1, g2, shouldMatchBonds, shouldMatchRings, matchAtomType) != null); } }
CDKMCS { public static boolean isSubgraph(IAtomContainer g1, IAtomContainer g2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType) throws CDKException { if (g1 instanceof IQueryAtomContainer) { throw new CDKException( "The first IAtomContainer must not be an IQueryAtomContainer"); } if (g2.getAtomCount() > g1.getAtomCount()) { return false; } if (g2.getAtomCount() == 1) { IAtom atom = g2.getAtom(0); for (int i = 0; i < g1.getAtomCount(); i++) { IAtom atom2 = g1.getAtom(i); if (atom instanceof IQueryAtom) { IQueryAtom qAtom = (IQueryAtom) atom; if (qAtom.matches(atom2)) { return true; } } else if (atom2 instanceof IQueryAtom) { IQueryAtom qAtom = (IQueryAtom) atom2; if (qAtom.matches(atom)) { return true; } } else { return atom2.getSymbol().equals(atom.getSymbol()); } } return false; } if (!testSubgraphHeuristics(g1, g2)) { return false; } return (getSubgraphMap(g1, g2, shouldMatchBonds, shouldMatchRings, matchAtomType) != null); }  }
CDKMCS { public static boolean isSubgraph(IAtomContainer g1, IAtomContainer g2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType) throws CDKException { if (g1 instanceof IQueryAtomContainer) { throw new CDKException( "The first IAtomContainer must not be an IQueryAtomContainer"); } if (g2.getAtomCount() > g1.getAtomCount()) { return false; } if (g2.getAtomCount() == 1) { IAtom atom = g2.getAtom(0); for (int i = 0; i < g1.getAtomCount(); i++) { IAtom atom2 = g1.getAtom(i); if (atom instanceof IQueryAtom) { IQueryAtom qAtom = (IQueryAtom) atom; if (qAtom.matches(atom2)) { return true; } } else if (atom2 instanceof IQueryAtom) { IQueryAtom qAtom = (IQueryAtom) atom2; if (qAtom.matches(atom)) { return true; } } else { return atom2.getSymbol().equals(atom.getSymbol()); } } return false; } if (!testSubgraphHeuristics(g1, g2)) { return false; } return (getSubgraphMap(g1, g2, shouldMatchBonds, shouldMatchRings, matchAtomType) != null); }  static boolean isIsomorph(IAtomContainer g1, IAtomContainer g2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<List<CDKRMap>> getIsomorphMaps(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<List<CDKRMap>> getSubgraphMaps(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<CDKRMap> getSubgraphMap(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<List<CDKRMap>> getSubgraphAtomsMaps(IAtomContainer g1,
            IAtomContainer g2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static boolean isSubgraph(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<IAtomContainer> getOverlaps(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static BitSet getBitSet(IAtomContainer ac); static CDKRGraph buildRGraph(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<List<CDKRMap>> search(IAtomContainer g1, IAtomContainer g2, BitSet c1,
            BitSet c2, boolean findAllStructure, boolean findAllMap,
            boolean shouldMatchBonds, boolean shouldMatchRings,
            boolean matchAtomType); static boolean isTimeout(); }
CDKMCS { public static boolean isSubgraph(IAtomContainer g1, IAtomContainer g2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType) throws CDKException { if (g1 instanceof IQueryAtomContainer) { throw new CDKException( "The first IAtomContainer must not be an IQueryAtomContainer"); } if (g2.getAtomCount() > g1.getAtomCount()) { return false; } if (g2.getAtomCount() == 1) { IAtom atom = g2.getAtom(0); for (int i = 0; i < g1.getAtomCount(); i++) { IAtom atom2 = g1.getAtom(i); if (atom instanceof IQueryAtom) { IQueryAtom qAtom = (IQueryAtom) atom; if (qAtom.matches(atom2)) { return true; } } else if (atom2 instanceof IQueryAtom) { IQueryAtom qAtom = (IQueryAtom) atom2; if (qAtom.matches(atom)) { return true; } } else { return atom2.getSymbol().equals(atom.getSymbol()); } } return false; } if (!testSubgraphHeuristics(g1, g2)) { return false; } return (getSubgraphMap(g1, g2, shouldMatchBonds, shouldMatchRings, matchAtomType) != null); }  static boolean isIsomorph(IAtomContainer g1, IAtomContainer g2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<List<CDKRMap>> getIsomorphMaps(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<List<CDKRMap>> getSubgraphMaps(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<CDKRMap> getSubgraphMap(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<List<CDKRMap>> getSubgraphAtomsMaps(IAtomContainer g1,
            IAtomContainer g2, boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static boolean isSubgraph(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<IAtomContainer> getOverlaps(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static BitSet getBitSet(IAtomContainer ac); static CDKRGraph buildRGraph(IAtomContainer g1, IAtomContainer g2,
            boolean shouldMatchBonds, boolean shouldMatchRings, boolean matchAtomType); static List<List<CDKRMap>> search(IAtomContainer g1, IAtomContainer g2, BitSet c1,
            BitSet c2, boolean findAllStructure, boolean findAllMap,
            boolean shouldMatchBonds, boolean shouldMatchRings,
            boolean matchAtomType); static boolean isTimeout();  }