/** * 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; }
/** * Returns atom index of the given atom in the query molecule * * @param atom * @return */ public synchronized int getQueryIndex(IAtom atom) { return getQuery().getAtomNumber(atom); }
/** * 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 atom index of the given atom in the query molecule * * @param atom * @return */ public synchronized int getQueryIndex(IAtom atom) { return getQuery().indexOf(atom); }
/** * Returns atom index of the given atom in the query molecule * * @param atom * @return */ public synchronized int getQueryIndex(IAtom atom) { return getQuery().indexOf(atom); }
public Map<IAtom, IAtom> sortByValues(Map<IAtom, IAtom> map) { List<Map.Entry<IAtom, IAtom>> entries = new LinkedList<>(map.entrySet()); Collections.sort(entries, (Entry<IAtom, IAtom> o1, Entry<IAtom, IAtom> o2) -> { int atomNumber1 = getQuery().getAtomNumber(o1.getKey()); int atomNumber2 = getQuery().getAtomNumber(o2.getKey()); return atomNumber1 - atomNumber2; }); //LinkedHashMap will keep the keys in the order they are inserted //which is currently sorted on natural ordering Map<IAtom, IAtom> sortedMap = new LinkedHashMap<>(); entries.stream().forEach((entry) -> { sortedMap.put(entry.getKey(), entry.getValue()); }); return sortedMap; }
public Map<IAtom, IAtom> sortByValues(Map<IAtom, IAtom> map) { List<Map.Entry<IAtom, IAtom>> entries = new LinkedList<>(map.entrySet()); Collections.sort(entries, (Entry<IAtom, IAtom> o1, Entry<IAtom, IAtom> o2) -> { int atomNumber1 = getQuery().indexOf(o1.getKey()); int atomNumber2 = getQuery().indexOf(o2.getKey()); return atomNumber1 - atomNumber2; }); //LinkedHashMap will keep the keys in the order they are inserted //which is currently sorted on natural ordering Map<IAtom, IAtom> sortedMap = new LinkedHashMap<>(); entries.stream().forEach((entry) -> { sortedMap.put(entry.getKey(), entry.getValue()); }); return sortedMap; }
public Map<IAtom, IAtom> sortByValues(Map<IAtom, IAtom> map) { List<Map.Entry<IAtom, IAtom>> entries = new LinkedList<>(map.entrySet()); Collections.sort(entries, (Entry<IAtom, IAtom> o1, Entry<IAtom, IAtom> o2) -> { int atomNumber1 = getQuery().indexOf(o1.getKey()); int atomNumber2 = getQuery().indexOf(o2.getKey()); return atomNumber1 - atomNumber2; }); //LinkedHashMap will keep the keys in the order they are inserted //which is currently sorted on natural ordering Map<IAtom, IAtom> sortedMap = new LinkedHashMap<>(); entries.stream().forEach((entry) -> { sortedMap.put(entry.getKey(), entry.getValue()); }); return sortedMap; }
@Override public int hashCode() { int hash = 7; hash = 67 * hash + (this.getQuery() != null ? this.getQuery().hashCode() : 0); hash = 67 * hash + (this.getTarget() != null ? this.getTarget().hashCode() : 0); hash = 67 * hash + (this.mapping != null ? this.getMappingsByAtoms().hashCode() : 0); hash = 67 * hash + (this.mappingIndex != null ? this.getMappingsByIndex().hashCode() : 0); return hash; }
@Override public int hashCode() { int hash = 7; hash = 67 * hash + (this.getQuery() != null ? this.getQuery().hashCode() : 0); hash = 67 * hash + (this.getTarget() != null ? this.getTarget().hashCode() : 0); hash = 67 * hash + (this.mapping != null ? this.getMappingsByAtoms().hashCode() : 0); hash = 67 * hash + (this.mappingIndex != null ? this.getMappingsByIndex().hashCode() : 0); return hash; }
@Override public int hashCode() { int hash = 7; hash = 67 * hash + (this.getQuery() != null ? this.getQuery().hashCode() : 0); hash = 67 * hash + (this.getTarget() != null ? this.getTarget().hashCode() : 0); hash = 67 * hash + (this.mapping != null ? this.getMappingsByAtoms().hashCode() : 0); hash = 67 * hash + (this.mappingIndex != null ? this.getMappingsByIndex().hashCode() : 0); return hash; }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final AtomAtomMapping other = (AtomAtomMapping) obj; if (this.getQuery() != other.getQuery() && (this.getQuery() == null || !this.query.equals(other.query))) { return false; } if (this.getTarget() != other.getTarget() && (this.getTarget() == null || !this.target.equals(other.target))) { return false; } if (this.mapping != other.getMappingsByAtoms() && (this.mapping == null || !this.mapping.equals(other.mapping))) { return false; } return this.mappingIndex == other.getMappingsByIndex() || (this.mappingIndex != null && this.mappingIndex.equals(other.mappingIndex)); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final AtomAtomMapping other = (AtomAtomMapping) obj; if (this.getQuery() != other.getQuery() && (this.getQuery() == null || !this.query.equals(other.query))) { return false; } if (this.getTarget() != other.getTarget() && (this.getTarget() == null || !this.target.equals(other.target))) { return false; } if (this.mapping != other.getMappingsByAtoms() && (this.mapping == null || !this.mapping.equals(other.mapping))) { return false; } return this.mappingIndex == other.getMappingsByIndex() || (this.mappingIndex != null && this.mappingIndex.equals(other.mappingIndex)); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final AtomAtomMapping other = (AtomAtomMapping) obj; if (this.getQuery() != other.getQuery() && (this.getQuery() == null || !this.query.equals(other.query))) { return false; } if (this.getTarget() != other.getTarget() && (this.getTarget() == null || !this.target.equals(other.target))) { return false; } if (this.mapping != other.getMappingsByAtoms() && (this.mapping == null || !this.mapping.equals(other.mapping))) { return false; } return this.mappingIndex == other.getMappingsByIndex() || (this.mappingIndex != null && this.mappingIndex.equals(other.mappingIndex)); }
/** * * @param atom1 * @param atom2 */ public synchronized void put(IAtom atom1, IAtom atom2) { mapping.put(atom1, atom2); mappingIndex.put(getQuery().getAtomNumber(atom1), getTarget().getAtomNumber(atom2)); }
/** * * @param atom1 * @param atom2 */ public synchronized void put(IAtom atom1, IAtom atom2) { mapping.put(atom1, atom2); mappingIndex.put(getQuery().indexOf(atom1), getTarget().indexOf(atom2)); }
/** * * @param atom1 * @param atom2 */ public synchronized void put(IAtom atom1, IAtom atom2) { try { atom1.setID(atom1.getID() == null ? getQuery().indexOf(atom1) + "" : atom1.getID()); atom2.setID(atom2.getID() == null ? getTarget().indexOf(atom2) + "" : atom2.getID()); mapping.put(atom1, atom2); mappingIndex.put(getQuery().indexOf(atom1), getTarget().indexOf(atom2)); } catch (Exception e) { LOGGER.error("Error: Add Mapping to the Map", e.getMessage()); } }