Class AtomChain
java.lang.Object
com.compomics.util.experiment.personalization.ExperimentObject
com.compomics.util.experiment.biology.atoms.AtomChain
- All Implemented Interfaces:
Serializable
A chain of atoms.
- Author:
- Marc Vaudel, Harald Barsnes
- See Also:
-
Field Summary
Fields inherited from class com.compomics.util.experiment.personalization.ExperimentObject
NO_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAppends an atom to the chain of atoms.voidAppends an atom to the chain of atoms.clone()Returns the atom chain as a list of AtomImpl.static AtomChaingetAtomChain(String atomChainAsString) Returns an atom chain from the input as string.doublegetMass()Returns the mass of the atomic chain as sum of the individual atoms.intgetOccurrence(Atom atom, Integer isotope) Returns the occurrence of a given atom in the chain.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.booleanisSameCompositionAs(AtomChain anotherChain) Indicates whether two atom chains are of the same composition by comparing their string and type.voidRemoves all the occurrences of the given atom.voidsetOccurrence(Atom atom, Integer isotope, Integer occurrence) Sets the occurrence of a given atom.intsize()Returns the number of atoms in this atom chain.toString()Methods inherited from class com.compomics.util.experiment.personalization.ExperimentObject
addUrParam, asLong, clearParametersMap, getId, getUrParam, getUrParams, removeUrParam, setId, setUrParams
-
Constructor Details
-
AtomChain
public AtomChain()Creates an empty atom chain.
-
-
Method Details
-
getAtomChain
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
Appends an atom to the chain of atoms.- Parameters:
atom- a new atom
-
append
Appends an atom to the chain of atoms.- Parameters:
atom- a new atomoccurrence- the number of times this atom should be added
-
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 atomsincludeBrackets- boolean indicating whether brackets are included for the number of occurrences of each atomalwaysIncludeNumber- boolean indicating whether the number is shown even when there is only one occurrence of an atomisotopeCurlyBrackets- 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 13Cnegative- if true, a minus sign is added in front of the occurrence valuesalwaysRecreate- 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
Returns the occurrence of a given atom in the chain.- Parameters:
atom- the atom of interestisotope- the isotope to look for- Returns:
- the occurrence of the atom in this atom chain
-
remove
Removes all the occurrences of the given atom.- Parameters:
atom- the atomisotope- the isotope
-
setOccurrence
Sets the occurrence of a given atom.- Parameters:
atom- the atomisotope- the isotope numberoccurrence- the occurrence
-
isSameCompositionAs
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
-
clone
-