public class Composition extends Mass
| Modifier and Type | Class and Description |
|---|---|
static class |
Composition.Builder
Class to build a Composition
|
| Modifier and Type | Field and Description |
|---|---|
protected gnu.trove.map.TObjectIntMap<Atom> |
atomCounterMap |
protected int |
charge |
| Modifier | Constructor and Description |
|---|---|
|
Composition(Composition... compositions)
Constructs a composition that is the sum of the
compositions |
protected |
Composition(String formula,
gnu.trove.map.TObjectIntMap<Atom> atomCountMap,
int charge) |
|
Composition(gnu.trove.map.TObjectIntMap<Atom> atomCounterMap,
int charge)
Construct a new composition that contains the
charge and the atoms in the atomCounterMap. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
Set<Atom> |
getAtoms()
Returns a set containing all the Atoms in this composition.
|
int |
getCharge()
Return the charge for this composition.
|
int |
getCount(Atom atom)
Counts the number of times
atom occurs in this Composition |
String |
getFormula()
Return the formula for this composition.
|
double |
getMassDefect()
The amount by which the mass of all atomic nuclei in this composition differs
from the sum of the masses of its constituent protons, neutrons and electrons.
|
double |
getMolecularMass()
Returns the monoisotopic molecular mass of this composition.
|
int |
hashCode() |
boolean |
isEmpty()
Returns true if this composition contains no atoms or charge, false otherwise.
|
static Composition |
parseComposition(String s)
Creates a Composition by parsing the given string.
|
int |
size()
Returns the number of atoms in this composition
|
static Composition |
subtractCompositions(Composition composition1,
Composition composition2) |
String |
toString() |
protected final int charge
protected final gnu.trove.map.TObjectIntMap<Atom> atomCounterMap
public Composition(gnu.trove.map.TObjectIntMap<Atom> atomCounterMap, int charge)
charge and the atoms in the atomCounterMap.atomCounterMap - the atoms to include in the compositioncharge - the charge of the compositionprotected Composition(String formula, gnu.trove.map.TObjectIntMap<Atom> atomCountMap, int charge)
public Composition(Composition... compositions)
compositionscompositions - the Compositions to sumpublic Set<Atom> getAtoms()
public double getMolecularMass()
This is due to the fact that as our composition is a Map of unsorted atoms the same atoms traversing order is not garantied.
As each instance mass is calculated by traversing atomic masses and that mass
are unexactly represented in the standard binary floating point, these roundoff errors
can propagate through the calculation in non-intuitive ways and may lead to teany tiny different results.
public String getFormula()
getFormula in class MassAtomicCompositionParserpublic double getMassDefect()
MassgetMassDefect in class Masspublic int getCharge()
public int getCount(Atom atom)
atom occurs in this Compositionatom - the atomatom occurs in this Compositionpublic int size()
public boolean isEmpty()
public static Composition parseComposition(String s)
s - the string to parseAtomicCompositionParserpublic static Composition subtractCompositions(Composition composition1, Composition composition2)
Copyright © 2016. All Rights Reserved.