Class Changes


  • @PublicAPI
    public class Changes
    extends Object
    The change set of the standardization procedure.

    Contains a clone of the original molecule, the result molecule and a map of atoms and atom-indexes for each atom of the input molecule. All modifications (added removed and modified) made by the standardization process atoms should be stored here.

    The mapping of the indexes can be gathered using the methods newToOld() and oldToNew()

    Getting the mapping based on a list of sequential changes on a molecule can be gathered using the methods newToOld(List, Molecule) and newToOld(List, Molecule)

    To merge more than one Changes object is possible using append(Changes) method.

    Since:
    5.11
    • Constructor Detail

      • Changes

        public Changes​(Molecule original)
        Initializes the changes object. Default index mapping is based on the original molecule. A clone of the original molecule is created and stored to represent the molecule in the state before standardization process.
        Parameters:
        original - the original molecule
      • Changes

        public Changes​(Molecule original,
                       Molecule result)
        Initializes the changes object. Default index mapping is based on the original molecule. The clone of the original molecule is stored to represent the molecule in the state before standardization process.
        Parameters:
        original - the original molecule
        result - the result molecule to be standardized. should be different of the original molecule
      • Changes

        public Changes​(Molecule molecule,
                       StandardizerAction action)
        Initializes the changes object. Default index mapping is based on the original molecule. A clone of the original molecule is created and stored to represent the molecule in the state before standardization process.
        Parameters:
        molecule - the original molecule
        action - the action generating the changes
    • Method Detail

      • getOriginal

        public Molecule getOriginal()
        Gets the original molecule of the standardization process. (It is a clone of the original molecule in the state before the standardization)
        Returns:
        the clone of the original molecule in the state before the standardization process
      • getResult

        public Molecule getResult()
        Gets the result molecule of the standardization process
        Returns:
        the result molecule of the standardization process
      • getAddedAtoms

        public List<MolAtom> getAddedAtoms()
        Gets the list of atoms added during the standardization procedure
        Returns:
        the list of atoms added during the standardization procedure. This list should be not modified, as it affects the changes object!
      • getRemovedAtoms

        public List<MolAtom> getRemovedAtoms()
        Gets the list of atoms removed during the standardization procedure
        Returns:
        the list of atoms removed during the standardization procedure. This list should be not modified, as it affects the changes object!
      • getModifiedAtoms

        public List<MolAtom> getModifiedAtoms()
        Gets the list of modified atoms during the standardization procedure
        Returns:
        the list of modified atoms during the standardization procedure. This list should be not modified, as it affects the changes object!
      • getCleanRelevantAtoms

        public List<MolAtom> getCleanRelevantAtoms()
        Gets the list of atoms changed during the standardization procedure, and needs to be cleaned
        Returns:
        the list of atoms changed during the standardization procedure. This list should be not modified, as it affects the changes object!
      • addAtom

        public void addAtom​(MolAtom atom)
        Adds an atom to the "added atom" list.
        Parameters:
        atom - an atom to be added to the "added atom" list.
      • addAtom

        public void addAtom​(MolAtom atom,
                            boolean cleanRelevant)
        Adds an atom to the "added atom" list.
        Parameters:
        atom - an atom to be added to the "added atom" list.
        cleanRelevant - whether the atom is relevant for cleaning the output molecule
      • removeAtom

        public void removeAtom​(MolAtom atom)
        Adds an atom to the "removed atom" list.
        Parameters:
        atom - an atom to be added to the "removed atom" list.
      • removeAtom

        public void removeAtom​(MolAtom atom,
                               boolean cleanRelevant)
        Adds an atom to the "removed atom" list.
        Parameters:
        atom - an atom to be added to the "removed atom" list.
        cleanRelevant - whether the atom is relevant for cleaning the output molecule
      • modifyAtom

        public void modifyAtom​(MolAtom atom)
        Adds an atom to the "modified atom" list.
        Parameters:
        atom - an atom to be added to the "modified atom" list.
      • modifyAtom

        public void modifyAtom​(MolAtom atom,
                               boolean cleanRelevant)
        Adds an atom to the "modified atom" list.
        Parameters:
        atom - an atom to be added to the "modified atom" list.
        cleanRelevant - whether the atom is relevant for cleaning the output molecule
      • addAllAtoms

        public void addAllAtoms​(Collection<MolAtom> atoms)
        Adds atoms to the "added atom" list.
        Parameters:
        atoms - atoms to be added to the "added atom" list.
      • addAllAtoms

        public void addAllAtoms​(Collection<MolAtom> atoms,
                                boolean cleanRelevant)
        Adds atoms to the "added atom" list.
        Parameters:
        atoms - atoms to be added to the "added atom" list.
        cleanRelevant - whether the atoms are relevant for cleaning the output molecule
      • removeAllAtoms

        public void removeAllAtoms​(Collection<MolAtom> atoms)
        Adds atoms to the "removed atom" list
        Parameters:
        atoms - atoms to be added to the "removed atom" list
      • removeAllAtoms

        public void removeAllAtoms​(Collection<MolAtom> atoms,
                                   boolean cleanRelevant)
        Adds atoms to the "removed atom" list
        Parameters:
        atoms - atoms to be added to the "removed atom" list
        cleanRelevant - whether the atoms are relevant for cleaning the output molecule
      • modifyAllAtoms

        public void modifyAllAtoms​(Collection<MolAtom> atoms)
        Adds atoms to the "modified atom" list.
        Parameters:
        atoms - atoms to be added to the "modified atom" list.
      • modifyAllAtoms

        public void modifyAllAtoms​(Collection<MolAtom> atoms,
                                   boolean cleanRelevant)
        Adds atoms to the "modified atom" list.
        Parameters:
        atoms - atoms to be added to the "modified atom" list.
        cleanRelevant - whether the atoms are relevant for cleaning the output molecule
      • setModified

        public void setModified​(boolean modified)
        Sets whether any modifications were applied on the molecule.
        Parameters:
        modified - whether any modifications were applied on the molecule.
      • isModified

        public boolean isModified()
        Gets whether any modifications were applied on the molecule.
        Returns:
        whether any modifications were applied on the molecule.
      • oldToNew

        public int[] oldToNew()
        Returns the old -> new atom index mapping.
        oldToNew[i]==j means that the i-th atom of the old molecule corresponds to the j-th atom of the new molecule.
        Returns:
        the old -> new atom index mapping
      • newToOld

        public int[] newToOld()
        Returns the new -> old atom index mapping.
        newToOld[i]==j means that the i-th atom of the new molecule corresponds to the j-th atom of the old molecule.
        Returns:
        the new -> old atom index mapping
      • oldToNew

        public static int[] oldToNew​(List<Changes> changeList,
                                     Molecule target)
        Calculates the old -> new atom index mapping based on a list of changes.
        oldToNew[i]==j means that the i-th atom of the old molecule corresponds to the j-th atom of the new molecule.
        Parameters:
        changeList - the target list of changes
        target - the target molecule (needed in case of no changes)
        Returns:
        the old -> new atom index mapping based on a list of changes
      • newToOld

        public static int[] newToOld​(List<Changes> changeList,
                                     Molecule target)
        Calculates the new -> old atom index mapping based on a list of changes.
        newToOld[i]==j means that the i-th atom of the new molecule corresponds to the j-th atom of the old molecule.
        Parameters:
        changeList - the target list of changes
        target - the target molecule (needed in case of no changes)
        Returns:
        the new -> old atom index mapping based on a list of changes
      • append

        public void append​(Changes changes)
        Appends a set of changes to the already existing changes. Added / Removed / Modified molecules contained by the parameter are added to this object.
        Parameters:
        changes - the set of changes to be appended