private static Map<Integer, Integer> getIndexMapping(AtomAtomMapping aam) { return aam.isEmpty() ? new TreeMap<>() : aam.getMappingsByIndex(); } }
private synchronized void setAllAtomMapping() { int counter = 0; for (Map<Integer, Integer> final_solution : allMCS) { AtomAtomMapping atomMappings = new AtomAtomMapping(source, target); final_solution.keySet().stream().forEach((indexI) -> { IAtom sourceAtom = source.getAtom(indexI); IAtom targetAtom = target.getAtom(final_solution.get(indexI)); if (sourceAtom != null && targetAtom != null) { atomMappings.put(sourceAtom, targetAtom); } }); if (!allAtomMCS.contains(atomMappings)) { if (!atomMappings.isEmpty()) { allAtomMCS.add(counter, atomMappings); counter += 1; } } } }
private synchronized void setAllAtomMapping() { int counter = 0; for (Map<Integer, Integer> final_solution : allMCS) { AtomAtomMapping atomMappings = new AtomAtomMapping(source, target); final_solution.keySet().forEach((indexI) -> { IAtom sourceAtom = source.getAtom(indexI); IAtom targetAtom = target.getAtom(final_solution.get(indexI)); if (sourceAtom != null && targetAtom != null) { atomMappings.put(sourceAtom, targetAtom); } }); if (!allAtomMCS.contains(atomMappings)) { if (!atomMappings.isEmpty()) { allAtomMCS.add(counter, atomMappings); counter += 1; } } } }
private synchronized void setAllAtomMapping() { int counter = 0; for (Map<Integer, Integer> final_solution : allMCS) { AtomAtomMapping atomMappings = new AtomAtomMapping(source, target); for (Integer indexI : final_solution.keySet()) { IAtom sourceAtom = source.getAtom(indexI); IAtom targetAtom = target.getAtom(final_solution.get(indexI)); if (sourceAtom != null && targetAtom != null) { atomMappings.put(sourceAtom, targetAtom); } } if (!allAtomMCS.contains(atomMappings)) { if (!atomMappings.isEmpty()) { allAtomMCS.add(counter, atomMappings); counter += 1; } } } }
/** * {@inheritDoc} */ @Override public synchronized double getTanimotoSimilarity() { int decimalPlaces = 4; double rAtomCount; double pAtomCount; double tanimotoAtom = 0.0; if (getMappingCount() > 0) { AtomAtomMapping firstAtomMCS = getMCSList().iterator().next(); if (!firstAtomMCS.isEmpty()) { rAtomCount = (double) this.getMCSList().iterator().next().getQuery().getAtomCount(); pAtomCount = (double) this.getMCSList().iterator().next().getTarget().getAtomCount(); double matchCount = (double) firstAtomMCS.getCount(); tanimotoAtom = (matchCount) / (rAtomCount + pAtomCount - matchCount); BigDecimal tan = new BigDecimal(tanimotoAtom); tan = tan.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); tanimotoAtom = tan.doubleValue(); } } return tanimotoAtom; }
/** * {@inheritDoc} */ @Override public synchronized double getTanimotoSimilarity() { int decimalPlaces = 4; double rAtomCount; double pAtomCount; double tanimotoAtom = 0.0; if (getMappingCount() > 0) { AtomAtomMapping firstAtomMCS = getMCSList().iterator().next(); if (!firstAtomMCS.isEmpty()) { rAtomCount = (double) this.getMCSList().iterator().next().getQuery().getAtomCount(); pAtomCount = (double) this.getMCSList().iterator().next().getTarget().getAtomCount(); double matchCount = (double) firstAtomMCS.getCount(); tanimotoAtom = (matchCount) / (rAtomCount + pAtomCount - matchCount); BigDecimal tan = new BigDecimal(tanimotoAtom); tan = tan.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); tanimotoAtom = tan.doubleValue(); } } return tanimotoAtom; }
/** * {@inheritDoc} */ @Override public synchronized double getEuclideanDistance() { int decimalPlaces = 4; double sourceAtomCount; double targetAtomCount; double euclidean = -1.; if (getMappingCount() > 0) { AtomAtomMapping firstAtomMCS = getMCSList().iterator().next(); if (!firstAtomMCS.isEmpty()) { sourceAtomCount = (double) this.getMCSList().iterator() .next().getQuery().getAtomCount(); targetAtomCount = (double) this.getMCSList().iterator() .next().getTarget().getAtomCount(); double common = (double) firstAtomMCS.getCount(); euclidean = Math.sqrt(sourceAtomCount + targetAtomCount - 2 * common); BigDecimal dist = new BigDecimal(euclidean); dist = dist.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); euclidean = dist.doubleValue(); } } return euclidean; }
/** * {@inheritDoc} */ @Override public synchronized double getEuclideanDistance() { int decimalPlaces = 4; double sourceAtomCount; double targetAtomCount; double euclidean = -1.; if (getMappingCount() > 0) { AtomAtomMapping firstAtomMCS = getMCSList().iterator().next(); if (!firstAtomMCS.isEmpty()) { sourceAtomCount = (double) this.getMCSList().iterator() .next().getQuery().getAtomCount(); targetAtomCount = (double) this.getMCSList().iterator() .next().getTarget().getAtomCount(); double common = (double) firstAtomMCS.getCount(); euclidean = Math.sqrt(sourceAtomCount + targetAtomCount - 2 * common); BigDecimal dist = new BigDecimal(euclidean); dist = dist.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); euclidean = dist.doubleValue(); } } return euclidean; }
/** * {@inheritDoc} */ @Override public synchronized double getEuclideanDistance() { int decimalPlaces = 4; double sourceAtomCount; double targetAtomCount; double euclidean = -1.; if (getMappingCount() > 0) { AtomAtomMapping firstAtomMCS = getMCSList().iterator().next(); if (!firstAtomMCS.isEmpty()) { sourceAtomCount = (double) this.getMCSList().iterator() .next().getQuery().getAtomCount(); targetAtomCount = (double) this.getMCSList().iterator() .next().getTarget().getAtomCount(); double common = (double) firstAtomMCS.getCount(); euclidean = Math.sqrt(sourceAtomCount + targetAtomCount - 2 * common); BigDecimal dist = new BigDecimal(euclidean); dist = dist.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); euclidean = dist.doubleValue(); } } return euclidean; }
/** * {@inheritDoc} */ @Override public synchronized double getTanimotoSimilarity() { int decimalPlaces = 4; double rAtomCount; double pAtomCount; double tanimotoAtom = 0.0; if (getMappingCount() > 0) { AtomAtomMapping firstAtomMCS = getMCSList().iterator().next(); if (!firstAtomMCS.isEmpty()) { rAtomCount = (double) this.getMCSList().iterator().next().getQuery().getAtomCount(); pAtomCount = (double) this.getMCSList().iterator().next().getTarget().getAtomCount(); double matchCount = (double) firstAtomMCS.getCount(); tanimotoAtom = (matchCount) / (rAtomCount + pAtomCount - matchCount); BigDecimal tan = new BigDecimal(tanimotoAtom); tan = tan.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); tanimotoAtom = tan.doubleValue(); } } return tanimotoAtom; }
}).filter((atomatomMapping) -> (!atomatomMapping.isEmpty())).forEach((atomatomMapping) -> { allCliqueAtomMCS.add(atomatomMapping); });
}).filter((atomatomMapping) -> (!atomatomMapping.isEmpty())).forEach((atomatomMapping) -> { allCliqueAtomMCS.add(atomatomMapping); });
}).filter((atomatomMapping) -> (!atomatomMapping.isEmpty())).forEach((atomatomMapping) -> { allCliqueAtomMCS.add(atomatomMapping); });
private synchronized void setVFMappings(List<AtomAtomMapping> mappingsVF2) { int counter = 0; for (AtomAtomMapping solution : mappingsVF2) { AtomAtomMapping atomatomMapping = new AtomAtomMapping(getQuery(), getTarget()); if (solution.getCount() > vfMappingSize) { this.vfMappingSize = solution.getCount(); counter = 0; } solution.getMappingsByAtoms().entrySet().stream().forEach((mapping) -> { IAtom qAtom; IAtom tAtom; qAtom = mapping.getKey(); tAtom = mapping.getValue(); if (qAtom != null && tAtom != null) { atomatomMapping.put(qAtom, tAtom); } else { try { throw new CDKException("Atom index pointing to NULL"); } catch (CDKException ex) { Logger.error(Level.SEVERE, null, ex); } } }); if (!atomatomMapping.isEmpty() && !hasMap(atomatomMapping, getMCSList()) && atomatomMapping.getCount() == vfMappingSize) { getMCSList().add(counter, atomatomMapping); counter++; } } }
private synchronized void setVFMappings(List<AtomAtomMapping> mappingsVF2) { int counter = 0; for (AtomAtomMapping solution : mappingsVF2) { AtomAtomMapping atomatomMapping = new AtomAtomMapping(getQuery(), getTarget()); if (solution.getCount() > vfMappingSize) { this.vfMappingSize = solution.getCount(); counter = 0; } for (Map.Entry<IAtom, IAtom> mapping : solution.getMappingsByAtoms().entrySet()) { IAtom qAtom; IAtom tAtom; qAtom = mapping.getKey(); tAtom = mapping.getValue(); if (qAtom != null && tAtom != null) { atomatomMapping.put(qAtom, tAtom); } else { try { throw new CDKException("Atom index pointing to NULL"); } catch (CDKException ex) { Logger.error(Level.SEVERE, null, ex); } } } if (!atomatomMapping.isEmpty() && !hasMap(atomatomMapping, getMCSList()) && atomatomMapping.getCount() == vfMappingSize) { getMCSList().add(counter, atomatomMapping); counter++; } } }
private synchronized void setVFMappings(List<AtomAtomMapping> mappingsVF2) { int counter = 0; for (AtomAtomMapping solution : mappingsVF2) { AtomAtomMapping atomatomMapping = new AtomAtomMapping(getQuery(), getTarget()); if (solution.getCount() > vfMappingSize) { this.vfMappingSize = solution.getCount(); counter = 0; } for (Map.Entry<IAtom, IAtom> mapping : solution.getMappingsByAtoms().entrySet()) { IAtom qAtom; IAtom tAtom; qAtom = mapping.getKey(); tAtom = mapping.getValue(); if (qAtom != null && tAtom != null) { atomatomMapping.put(qAtom, tAtom); } else { try { throw new CDKException("Atom index pointing to NULL"); } catch (CDKException ex) { Logger.error(Level.SEVERE, null, ex); } } } if (!atomatomMapping.isEmpty() && !hasMap(atomatomMapping, getMCSList()) && atomatomMapping.getCount() == vfMappingSize) { getMCSList().add(counter, atomatomMapping); counter++; } } }
synchronized void printMatch(BaseMapping isomorphism) { int overlap = isomorphism.getFirstAtomMapping().isEmpty() ? 0 : isomorphism.getFirstAtomMapping().getCount(); try { System.out.println("Q: " + isomorphism.getQuery().getID() + " T: " + isomorphism.getTarget().getID() + " atoms: " + isomorphism.getQuery().getAtomCount() + " atoms: " + isomorphism.getTarget().getAtomCount() + " overlaps: " + overlap + " mcs " + isomorphism.getFirstAtomMapping().getCommonFragmentAsSMILES()); } catch (CloneNotSupportedException | CDKException ex) { LOGGER.error(Level.SEVERE, "Print MCS ", ex.getMessage()); } }
return !getFirstAtomMapping().isEmpty();
return !getFirstAtomMapping().isEmpty();
return !getFirstAtomMapping().isEmpty();