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 query molecule. * * @return common mapped fragment in the query molecule * @throws CloneNotSupportedException */ public synchronized IAtomContainer getMapCommonFragmentOnQuery() throws CloneNotSupportedException { IAtomContainer ac = getQuery().clone(); List<IAtom> uniqueAtoms = Collections.synchronizedList(new ArrayList<>()); for (IAtom atom : getQuery().atoms()) { if (!mapping.containsKey(atom)) { uniqueAtoms.add(ac.getAtom(getQueryIndex(atom))); } } uniqueAtoms.stream().forEach((atom) -> { ac.removeAtom(atom); }); return ac; }
/** * Returns common mapped fragment in the query molecule. * * @return common mapped fragment in the query molecule * @throws CloneNotSupportedException */ public synchronized IAtomContainer getMapCommonFragmentOnQuery() throws CloneNotSupportedException { IAtomContainer ac = getQuery().clone(); List<IAtom> uniqueAtoms = Collections.synchronizedList(new ArrayList<IAtom>()); for (IAtom atom : getQuery().atoms()) { if (!mapping.containsKey(atom)) { uniqueAtoms.add(ac.getAtom(getQueryIndex(atom))); } } uniqueAtoms.stream().forEach((atom) -> { ac.removeAtomAndConnectedElectronContainers(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(); }
for (IAtom atom : getQuery().atoms()) { if (!mapping.containsKey(atom)) { uniqueAtoms.add(ac.getAtom(getQueryIndex(atom)));
for (IAtom atom : getQuery().atoms()) { if (!mapping.containsKey(atom)) { uniqueAtoms.add(ac.getAtom(getQueryIndex(atom))); IBond bondInTarget = getTarget().getBond(atom1ForBondInTarget, atom2ForBondInTarget); if (bondInTarget == null) { IAtom atom1InCommonContainer = ac.getAtom(getQueryIndex(bond.getAtom(0))); IAtom atom2InCommonContainer = ac.getAtom(getQueryIndex(bond.getAtom(1))); ac.removeBond(ac.getBond(atom1InCommonContainer, atom2InCommonContainer));
for (IAtom atom : getQuery().atoms()) { if (!mapping.containsKey(atom)) { uniqueAtoms.add(ac.getAtom(getQueryIndex(atom))); IBond bondInTarget = getTarget().getBond(atom1ForBondInTarget, atom2ForBondInTarget); if (bondInTarget == null) { IAtom atom1InCommonContainer = ac.getAtom(getQueryIndex(bond.getAtom(0))); IAtom atom2InCommonContainer = ac.getAtom(getQueryIndex(bond.getAtom(1))); ac.removeBond(ac.getBond(atom1InCommonContainer, atom2InCommonContainer));
IAtom qAtom = aMaps.getKey(); IAtom tAtom = aMaps.getValue(); qAtom.setID(valueOf(maxac.getQueryIndex(qAtom))); tAtom.setID(valueOf(maxac.getQueryIndex(tAtom))); n1.add(qAtom); n2.add(tAtom);
for (IAtom atom : getQuery().atoms()) { if (!mapping.containsKey(atom)) { uniqueAtoms.add(ac.getAtom(getQueryIndex(atom))); IAtom atom1InCommonContainer = ac.getAtom(getQueryIndex(bond.getAtom(0))); IAtom atom2InCommonContainer = ac.getAtom(getQueryIndex(bond.getAtom(1))); ac.removeBond(ac.getBond(atom1InCommonContainer, atom2InCommonContainer));