private static Map<Integer, Integer> getIndexMapping(AtomAtomMapping aam) { Map<IAtom, IAtom> mappings = aam.getMappingsByAtoms(); Map<Integer, Integer> mapping = new TreeMap<>(); mappings.keySet().stream().forEach((keys) -> { mapping.put(aam.getQueryIndex(keys), aam.getTargetIndex(mappings.get(keys))); }); return mapping; } }
/** * Returns common mapped fragment in the target molecule. * * @return common mapped fragment in the target molecule * @throws CloneNotSupportedException */ public synchronized IAtomContainer getMapCommonFragmentOnTarget() throws CloneNotSupportedException { IAtomContainer ac = getTarget().clone(); List<IAtom> uniqueAtoms = Collections.synchronizedList(new ArrayList<>()); for (IAtom atom : getTarget().atoms()) { if (!mapping.containsValue(atom)) { uniqueAtoms.add(ac.getAtom(getTargetIndex(atom))); } } uniqueAtoms.stream().forEach((atom) -> { ac.removeAtom(atom); }); return ac; }
/** * Returns common mapped fragment in the target molecule. * * @return common mapped fragment in the target molecule * @throws CloneNotSupportedException */ public synchronized IAtomContainer getMapCommonFragmentOnTarget() throws CloneNotSupportedException { IAtomContainer ac = getTarget().clone(); List<IAtom> uniqueAtoms = Collections.synchronizedList(new ArrayList<IAtom>()); for (IAtom atom : getTarget().atoms()) { if (!mapping.containsValue(atom)) { uniqueAtoms.add(ac.getAtom(getTargetIndex(atom))); } } uniqueAtoms.stream().forEach((atom) -> { ac.removeAtomAndConnectedElectronContainers(atom); }); return ac; }
/** * Returns common mapped fragment in the target molecule. * * @return common mapped fragment in the target molecule * @throws CloneNotSupportedException */ public synchronized IAtomContainer getMapCommonFragmentOnTarget() throws CloneNotSupportedException { IAtomContainer ac = getTarget().clone(); List<IAtom> uniqueAtoms = Collections.synchronizedList(new ArrayList<>()); for (IAtom atom : getTarget().atoms()) { if (!mapping.containsValue(atom)) { uniqueAtoms.add(ac.getAtom(getTargetIndex(atom))); } } uniqueAtoms.stream().forEach((atom) -> { ac.removeAtom(atom); }); return ac; }
private static Image generateImage(IAtomContainer query, IAtomContainer target, Isomorphism smsd) throws Exception { ImageGenerator imageGenerator = new ImageGenerator(); ////set the format right for the Tanimoto score (only two digits printed) NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); System.out.println("Output of the final Mappings: "); int counter = 1; for (AtomAtomMapping aam : smsd.getAllAtomMapping()) { Map<IAtom, IAtom> mappings = aam.getMappingsByAtoms(); Map<Integer, Integer> mapping = new TreeMap<>(); for (IAtom keys : mappings.keySet()) { mapping.put(aam.getQueryIndex(keys), aam.getTargetIndex(mappings.get(keys))); } String tanimoto = nf.format(smsd.getTanimotoSimilarity()); String stereo = "NA"; if (smsd.getStereoScore(counter - 1) != null) { stereo = nf.format(smsd.getStereoScore(counter - 1)); } String label = "Scores [" + "Tanimoto: " + tanimoto + ", Stereo: " + stereo + "]"; imageGenerator.addImages(query, target, label, mapping); counter++; } return (Image) imageGenerator.createImage(); }