CDKMCSHandler extends AbstractMCSAlgorithm implements IMCSBase { @Override public void searchMCS(boolean shouldMatchBonds) { CDKRMapHandler rmap = new CDKRMapHandler(); try { if ((source.getAtomCount() == target.getAtomCount()) && source.getBondCount() == target.getBondCount()) { rOnPFlag = true; rmap.calculateOverlapsAndReduceExactMatch(source, target, shouldMatchBonds); } else if (source.getAtomCount() > target.getAtomCount() && source.getBondCount() != target.getBondCount()) { rOnPFlag = true; rmap.calculateOverlapsAndReduce(source, target, shouldMatchBonds); } else { rOnPFlag = false; rmap.calculateOverlapsAndReduce(target, source, shouldMatchBonds); } setAllMapping(); setAllAtomMapping(); setFirstMapping(); setFirstAtomMapping(); } catch (CDKException e) { rmap = null; } } CDKMCSHandler(); @Override void set(MolHandler source, MolHandler target); @Override void set(IQueryAtomContainer source, IAtomContainer target); @Override void searchMCS(boolean shouldMatchBonds); @Override List<Map<Integer, Integer>> getAllMapping(); @Override Map<Integer, Integer> getFirstMapping(); @Override List<Map<IAtom, IAtom>> getAllAtomMapping(); @Override Map<IAtom, IAtom> getFirstAtomMapping();  }
@Test @Override public void testSearchMCS() { try { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = null; target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); IAtomContainer queryac = null; queryac = sp.parseSmiles("Nc1ccccc1"); CDKMCSHandler smsd1 = new CDKMCSHandler(); MolHandler mol1 = new MolHandler(queryac, true, true); MolHandler mol2 = new MolHandler(target, true, true); smsd1.set(mol1, mol2); smsd1.searchMCS(true); assertNotNull(smsd1.getFirstMapping()); } catch (InvalidSmilesException ex) { Logger.getLogger(CDKMCSHandlerTest.class.getName()).log(Level.SEVERE, null, ex); } }