ChemicalFilters { public synchronized void sortResultsByStereoAndBondMatch() throws CDKException { Map<Integer, Map<Integer, Integer>> allStereoMCS = new HashMap<Integer, Map<Integer, Integer>>(); Map<Integer, Map<IAtom, IAtom>> allStereoAtomMCS = new HashMap<Integer, Map<IAtom, IAtom>>(); Map<Integer, Integer> fragmentScoreMap = new TreeMap<Integer, Integer>(); Map<Integer, Double> energyScoreMap = new TreeMap<Integer, Double>(); Map<Integer, Double> stereoScoreMap = new HashMap<Integer, Double>(); initializeMaps(allStereoMCS, allStereoAtomMCS, stereoScoreMap, fragmentScoreMap, energyScoreMap); boolean stereoMatchFlag = getStereoBondChargeMatch(stereoScoreMap, allStereoMCS, allStereoAtomMCS); boolean flag = false; if (stereoMatchFlag) { stereoScoreMap = sortMapByValueInDecendingOrder(stereoScoreMap); double higestStereoScore = stereoScoreMap.isEmpty() ? 0 : stereoScoreMap.values().iterator().next(); double secondhigestStereoScore = higestStereoScore; for (Integer key : stereoScoreMap.keySet()) { if (secondhigestStereoScore < higestStereoScore && stereoScoreMap.get(key) > secondhigestStereoScore) { secondhigestStereoScore = stereoScoreMap.get(key); } else if (secondhigestStereoScore == higestStereoScore && stereoScoreMap.get(key) < secondhigestStereoScore) { secondhigestStereoScore = stereoScoreMap.get(key); } } if (!stereoScoreMap.isEmpty()) { flag = true; clear(); } int counter = 0; for (Integer i : stereoScoreMap.keySet()) { if (higestStereoScore == stereoScoreMap.get(i).doubleValue()) { addSolution(counter, i, allStereoAtomMCS, allStereoMCS, stereoScoreMap, energyScoreMap, fragmentScoreMap); counter++; } } if (flag) { firstSolution.putAll(allMCS.get(0)); firstAtomMCS.putAll(allAtomMCS.get(0)); clear(allStereoMCS, allStereoAtomMCS, 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 testSortResultsByStereoAndBondMatch() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer target = sp.parseSmiles("C\\C=C/OCC=C"); IAtomContainer queryac = sp.parseSmiles("CCCOCC(C)=C"); Isomorphism smsd = new Isomorphism(Algorithm.DEFAULT, false); smsd.init(queryac, target, true, true); smsd.setChemFilters(false, false, false); assertEquals(4, smsd.getAllAtomMapping().size()); Isomorphism smsd1 = new Isomorphism(Algorithm.DEFAULT, false); smsd1.init(queryac, target, true, true); smsd1.setChemFilters(true, false, false); assertEquals(1, smsd1.getAllAtomMapping().size()); }