ChemicalFilters { public synchronized void sortResultsByFragments() { Map<Integer, Map<Integer, Integer>> allFragmentMCS = new TreeMap<Integer, Map<Integer, Integer>>(); Map<Integer, Map<IAtom, IAtom>> allFragmentAtomMCS = new TreeMap<Integer, Map<IAtom, IAtom>>(); Map<Integer, Double> stereoScoreMap = new TreeMap<Integer, Double>(); Map<Integer, Double> energyScoreMap = new TreeMap<Integer, Double>(); Map<Integer, Integer> fragmentScoreMap = new TreeMap<Integer, Integer>(); initializeMaps(allFragmentMCS, allFragmentAtomMCS, stereoScoreMap, fragmentScoreMap, energyScoreMap); int minFragmentScore = 9999; for (Integer key : allFragmentAtomMCS.keySet()) { Map<IAtom, IAtom> mcsAtom = allFragmentAtomMCS.get(key); int fragmentCount = getMappedMoleculeFragmentSize(mcsAtom); fragmentScoreMap.put(key, fragmentCount); if (minFragmentScore > fragmentCount) { minFragmentScore = fragmentCount; } } boolean flag = false; if (minFragmentScore < 9999) { flag = true; clear(); } int counter = 0; for (Map.Entry<Integer, Integer> map : fragmentScoreMap.entrySet()) { if (minFragmentScore == map.getValue().intValue()) { addSolution(counter, map.getKey(), allFragmentAtomMCS, allFragmentMCS, stereoScoreMap, energyScoreMap, fragmentScoreMap); counter++; } } if (flag) { firstSolution.putAll(allMCS.get(0)); firstAtomMCS.putAll(allAtomMCS.get(0)); clear(allFragmentMCS, allFragmentAtomMCS, stereoScoreMap, fragmentScoreMap, energyScoreMap); } } ChemicalFilters(List<Map<Integer, Integer>> allMCS, List<Map<IAtom, IAtom>> allAtomMCS,
            Map<Integer, Integer> firstSolution, Map<IAtom, IAtom> firstAtomMCS, IAtomContainer sourceMol,
            IAtomContainer targetMol); synchronized void sortResultsByStereoAndBondMatch(); synchronized void sortResultsByFragments(); synchronized void sortResultsByEnergies(); List<Double> getSortedEnergy(); List<Integer> getSortedFragment(); List<Double> getStereoMatches(); static IBond.Order convertOrder(double srcOrder); static int convertBondOrder(IBond bond); static int convertBondStereo(IBond bond); static IBond.Stereo convertStereo(int stereoValue);  }
@Test public void testSortResultsByFragments() throws InvalidSmilesException, CDKException { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C"); IAtomContainer queryac = sp.parseSmiles("Nc1ccccc1"); Isomorphism smsd = new Isomorphism(Algorithm.CDKMCS, false); smsd.init(queryac, target, true, true); smsd.setChemFilters(false, false, false); assertEquals(4, smsd.getAllAtomMapping().size()); Isomorphism smsd1 = new Isomorphism(Algorithm.CDKMCS, false); smsd1.init(queryac, target, true, true); smsd1.setChemFilters(false, true, false); assertEquals(2, smsd1.getAllAtomMapping().size()); }