java.lang.Object
com.compomics.util.experiment.personalization.ExperimentObject
com.compomics.util.experiment.biology.atoms.AtomChain
All Implemented Interfaces:
Serializable

public class AtomChain
extends ExperimentObject
A chain of atoms.
Author:
Marc Vaudel, Harald Barsnes
See Also:
Serialized Form
  • Constructor Details

    • AtomChain

      public AtomChain()
      Creates an empty atom chain.
  • Method Details

    • getAtomChain

      public static AtomChain getAtomChain​(String atomChainAsString)
      Returns an atom chain from the input as string. Atoms are represented by their canonical short name, e.g. C for Carbon, Na for Sodium. The occurrence of a given atom is to be written in parentheses, e.g. C(3)PO is parsed as three C's, one P and one O. No negative values are allowed. The isotope is to be written prior to the atom, e.g. 13C(2)18OP is parsed as two 13C atoms, one 18O, and one P.
      Parameters:
      atomChainAsString - the atomic chain as a string
      Returns:
      the atom chain represented in the given string
    • append

      public void append​(AtomImpl atom)
      Appends an atom to the chain of atoms.
      Parameters:
      atom - a new atom
    • append

      public void append​(AtomImpl atom, int occurrence)
      Appends an atom to the chain of atoms.
      Parameters:
      atom - a new atom
      occurrence - the number of times this atom should be added
    • getAtomChain

      public ArrayList<AtomImpl> getAtomChain()
      Returns the atom chain as a list of AtomImpl.
      Returns:
      the atom chain as a list of AtomImpl
    • getMass

      public double getMass()
      Returns the mass of the atomic chain as sum of the individual atoms.
      Returns:
      the mass of the atomic chain as sum of the individual atoms
    • size

      public int size()
      Returns the number of atoms in this atom chain.
      Returns:
      the number of atoms in this atom chain
    • getStringValue

      public String getStringValue​(boolean includeSpaces, boolean includeBrackets, boolean alwaysIncludeNumber, boolean isotopeCurlyBrackets, boolean negative, boolean alwaysRecreate)
      Sets the string value from the stringValue attribute, sets it from the composition if not set.
      Parameters:
      includeSpaces - boolean indicating whether spaces should be included between atoms
      includeBrackets - boolean indicating whether brackets are included for the number of occurrences of each atom
      alwaysIncludeNumber - boolean indicating whether the number is shown even when there is only one occurrence of an atom
      isotopeCurlyBrackets - if true, the isotopes are indicated as curly brackets after the atom, e.g. carbon 13 is written as C{13}, if false, the isotopes are indicated as a number before the atom, e.g. carbon 13 is written as 13C
      negative - if true, a minus sign is added in front of the occurrence values
      alwaysRecreate - if true, the string value will be recreated even if it already exists (use in order to not overwrite the standard format)
      Returns:
      the string value
    • getOccurrence

      public int getOccurrence​(Atom atom, Integer isotope)
      Returns the occurrence of a given atom in the chain.
      Parameters:
      atom - the atom of interest
      isotope - the isotope to look for
      Returns:
      the occurrence of the atom in this atom chain
    • remove

      public void remove​(Atom atom, Integer isotope)
      Removes all the occurrences of the given atom.
      Parameters:
      atom - the atom
      isotope - the isotope
    • setOccurrence

      public void setOccurrence​(Atom atom, Integer isotope, Integer occurrence)
      Sets the occurrence of a given atom.
      Parameters:
      atom - the atom
      isotope - the isotope number
      occurrence - the occurrence
    • isSameCompositionAs

      public boolean isSameCompositionAs​(AtomChain anotherChain)
      Indicates whether two atom chains are of the same composition by comparing their string and type. An empty chain is considered to be the same composition as a null chain.
      Parameters:
      anotherChain - another atom chain
      Returns:
      a boolean indicating whether two atom chains are of the same composition
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • clone

      public AtomChain clone()
      Overrides:
      clone in class Object