ChemicalFilters { public synchronized void sortResultsByEnergies() throws CDKException { Map<Integer, Map<Integer, Integer>> allEnergyMCS = new TreeMap<Integer, Map<Integer, Integer>>(); Map<Integer, Map<IAtom, IAtom>> allEnergyAtomMCS = new TreeMap<Integer, Map<IAtom, IAtom>>(); Map<Integer, Double> stereoScoreMap = new TreeMap<Integer, Double>(); Map<Integer, Integer> fragmentScoreMap = new TreeMap<Integer, Integer>(); Map<Integer, Double> energySelectionMap = new TreeMap<Integer, Double>(); initializeMaps(allEnergyMCS, allEnergyAtomMCS, stereoScoreMap, fragmentScoreMap, energySelectionMap); for (Integer key : allEnergyMCS.keySet()) { Map<Integer, Integer> mcsAtom = allEnergyMCS.get(key); Double energies = getMappedMoleculeEnergies(mcsAtom); energySelectionMap.put(key, energies); } energySelectionMap = sortMapByValueInAccendingOrder(energySelectionMap); boolean flag = false; double lowestEnergyScore = 99999999.99; for (Integer key : energySelectionMap.keySet()) { lowestEnergyScore = energySelectionMap.get(key).doubleValue(); flag = true; clear(); break; } int counter = 0; for (Map.Entry<Integer, Double> map : energySelectionMap.entrySet()) { if (lowestEnergyScore == map.getValue().doubleValue()) { addSolution(counter, map.getKey(), allEnergyAtomMCS, allEnergyMCS, stereoScoreMap, energySelectionMap, fragmentScoreMap); counter++; } } if (flag) { firstSolution.putAll(allMCS.get(0)); firstAtomMCS.putAll(allAtomMCS.get(0)); clear(allEnergyMCS, allEnergyAtomMCS, stereoScoreMap, fragmentScoreMap, energySelectionMap); } } 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 testSortResultsByEnergies() throws Exception { 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.DEFAULT, true); smsd.init(queryac, target, true, true); smsd.setChemFilters(false, false, false); assertEquals(4, smsd.getAllAtomMapping().size()); Isomorphism smsd1 = new Isomorphism(Algorithm.DEFAULT, true); smsd1.init(queryac, target, true, true); smsd1.setChemFilters(false, false, true); assertEquals(2, smsd1.getAllAtomMapping().size()); }