Representation of an empirical formula. More...
#include <OpenMS/CHEMISTRY/EmpiricalFormula.h>
Public Types | |
Typedefs | |
| typedef Map< const Element *, SignedSize >::ConstIterator | ConstIterator |
| Iterators. | |
| typedef Map< const Element *, SignedSize >::ConstIterator | const_iterator |
Public Member Functions | |
Constructors and Destructors | |
| EmpiricalFormula () | |
| default constructor | |
| EmpiricalFormula (const EmpiricalFormula &rhs) | |
| copy constructor | |
| EmpiricalFormula (const String &rhs) | |
| EmpiricalFormula (SignedSize number, const Element *element, SignedSize charge=0) | |
| constructor with element pointer and number | |
| virtual | ~EmpiricalFormula () |
| destructor | |
Accessors | |
| DoubleReal | getMonoWeight () const |
| returns the mono isotopic weight of the formula (includes proton charges) | |
| DoubleReal | getAverageWeight () const |
| returns the average weight of the formula (includes proton charges) | |
| IsotopeDistribution | getIsotopeDistribution (UInt max_depth) const |
| returns the isotope distribution of the formula The details of the calculation of the isotope distribution are described in the doc to the IsotopeDistribution class. | |
| const Element * | getElement (const String &name) const |
| returns a pointer to the element with name or symbol or 0 if no such element is fount | |
| const Element * | getElement (UInt atomic_number) const |
| returns a pointer to the element with given atomic number or 0 if none if found | |
| const ElementDB * | getElementDB () const |
| returns a pointer to the element db which is used with this class | |
| Size | getNumberOf (UInt atomic_number) const |
| returns the number of atoms with the given atomic_number | |
| Size | getNumberOf (const String &name) const |
| returns the number of atoms with the given name | |
| Size | getNumberOf (const Element *element) const |
| returns the number of atoms | |
| Size | getNumberOfAtoms () const |
| returns the atoms total | |
| SignedSize | getCharge () const |
| returns the charge | |
| void | setCharge (SignedSize charge) |
| sets the charge | |
| String | getString () const |
| returns the formula as a string (charges are not included) | |
| EmpiricalFormula & | operator= (const EmpiricalFormula &rhs) |
| assignment operator | |
| EmpiricalFormula & | operator= (const String &rhs) |
| EmpiricalFormula & | operator+= (const EmpiricalFormula &rhs) |
| adds the elements of the given formula | |
| EmpiricalFormula & | operator+= (const String &rhs) |
| EmpiricalFormula | operator* (const SignedSize ×) const |
| multiplies the elements and charge with a factor | |
| EmpiricalFormula | operator+ (const EmpiricalFormula &rhs) const |
| adds the elements of the given formula and returns a new formula | |
| EmpiricalFormula | operator+ (const String &rhs) const |
| EmpiricalFormula & | operator-= (const EmpiricalFormula &rhs) |
| subtracts the elements of a formula | |
| EmpiricalFormula & | operator-= (const String &rhs) |
| EmpiricalFormula | operator- (const EmpiricalFormula &rhs) const |
| subtracts the elements of a formula an returns a new formula | |
| EmpiricalFormula | operator- (const String &rhs) const |
Predicates | |
| bool | isEmpty () const |
| returns true if the formula does not contain a element | |
| bool | isCharged () const |
| returns true if charge != 0 | |
| bool | hasElement (const Element *element) const |
| returns true if the formula contains the element | |
| bool | hasElement (const String &name) const |
| returns true if the formula contains the element, given with its name or symbol | |
| bool | hasElement (UInt atomic_number) const |
| returns true if the formula contains the element with the given atomic number | |
| bool | operator== (const EmpiricalFormula &rhs) const |
| returns true if the formulas contain equal elements in equal quantities | |
| bool | operator== (const String &rhs) const |
| bool | operator!= (const EmpiricalFormula &rhs) const |
| returns true if the formulas differ in elements composition | |
| bool | operator!= (const String &rhs) const |
Iterators | |
| ConstIterator | begin () const |
| ConstIterator | end () const |
Protected Member Functions | |
| void | removeZeroedElements_ () |
| remove elements with count 0 | |
| void | readElementsFromFile_ (const String &file_name) |
| SignedSize | parseFormula_ (Map< const Element *, SignedSize > &ef, const String &formula) const |
Protected Attributes | |
| Map< const Element *, SignedSize > | formula_ |
| SignedSize | charge_ |
| const ElementDB * | element_db_ |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const EmpiricalFormula &formula) |
| writes the formula to a stream | |
Representation of an empirical formula.
The formula can be used as follows: elements are represented through its symbol or full name. The symbol or name is followed by a number. If not, the frequency is set to one. Examples are CH3OH or CarbonHydrogen3OH. The names must start with an capital letter (symbols always have an upper-case letter at the beginning). Additionally charges can be used with '+' followed by a number, if no number follows the charge of +1 is set. Negative charges can be added using a '-' sign. However, negative charges are only set if the last element in the string also has a number. E.g. H4C-1, does not set a negative charge, only -1 Carbon atoms, correctly it should be stated H4C-1-.
This class also supports the usage of specific isotopes. By default "C" describes not one isotope but a natural distribution or different isotopes. This distribution can be accessed via the member getIsotopeDistribution().
If one wants only use a specific isotope, it can be specified using "(",")" brackets. For example, to specify 14C a heavy isotope of carbon it is expressed as "(14)C". The isotope distribution of that instance contains only one isotope, 14C itself with a frequency of 100%.
Instances EmpiricalFormula support a (limited) set of mathmatical operations. Additions and subtractions are supported in different flavors. However, one must be careful, because this can lead to negative frequencies. In most cases this might be misleading, however, the class therefore supports difference formulae. E.g. formula differences of reactions from post-translational modifications.
| typedef Map<const Element *, SignedSize>::ConstIterator const_iterator |
| typedef Map<const Element *, SignedSize>::ConstIterator ConstIterator |
Iterators.
| EmpiricalFormula | ( | ) |
default constructor
| EmpiricalFormula | ( | const EmpiricalFormula & | rhs | ) |
copy constructor
| EmpiricalFormula | ( | const String & | rhs | ) |
| EmpiricalFormula | ( | SignedSize | number, | |
| const Element * | element, | |||
| SignedSize | charge = 0 | |||
| ) |
constructor with element pointer and number
| virtual ~EmpiricalFormula | ( | ) | [virtual] |
destructor
| ConstIterator begin | ( | ) | const [inline] |
| ConstIterator end | ( | ) | const [inline] |
| DoubleReal getAverageWeight | ( | ) | const |
returns the average weight of the formula (includes proton charges)
Referenced by Residue::getAIonToFullAverageWeight(), Residue::getBIonToFullAverageWeight(), Residue::getCIonMinusOneToFullAverageWeight(), Residue::getCIonPlusOneToFullAverageWeight(), Residue::getCIonPlusTwoToFullAverageWeight(), Residue::getCIonToFullAverageWeight(), Residue::getCTerminalToFullAverageWeight(), Residue::getInternalToFullAverageWeight(), Residue::getNTerminalToFullAverageWeight(), Residue::getXIonToFullAverageWeight(), Residue::getYIonToFullAverageWeight(), Residue::getZIonMinusOneToFullAverageWeight(), Residue::getZIonPlusOneToFullAverageWeight(), Residue::getZIonPlusTwoToFullAverageWeight(), and Residue::getZIonToFullAverageWeight().
| SignedSize getCharge | ( | ) | const |
returns the charge
returns a pointer to the element with name or symbol or 0 if no such element is fount
returns a pointer to the element with given atomic number or 0 if none if found
| const ElementDB* getElementDB | ( | ) | const |
returns a pointer to the element db which is used with this class
| IsotopeDistribution getIsotopeDistribution | ( | UInt | max_depth | ) | const |
returns the isotope distribution of the formula The details of the calculation of the isotope distribution are described in the doc to the IsotopeDistribution class.
| max_depth,: | this parameter gives the max isotope which is considered, if 0 all are reported |
| DoubleReal getMonoWeight | ( | ) | const |
returns the mono isotopic weight of the formula (includes proton charges)
Referenced by initModificationMassesRNA().
returns the number of atoms with the given atomic_number
| Size getNumberOfAtoms | ( | ) | const |
returns the atoms total
| String getString | ( | ) | const |
returns the formula as a string (charges are not included)
Referenced by initModificationMassesRNA(), and SvmTheoreticalSpectrumGenerator::IonType::operator<().
| bool hasElement | ( | const Element * | element | ) | const |
returns true if the formula contains the element
| bool hasElement | ( | const String & | name | ) | const |
returns true if the formula contains the element, given with its name or symbol
| bool hasElement | ( | UInt | atomic_number | ) | const |
returns true if the formula contains the element with the given atomic number
| bool isCharged | ( | ) | const |
returns true if charge != 0
| bool isEmpty | ( | ) | const |
returns true if the formula does not contain a element
| bool operator!= | ( | const EmpiricalFormula & | rhs | ) | const |
returns true if the formulas differ in elements composition
| bool operator!= | ( | const String & | rhs | ) | const |
returns true if the formulas differ in elements composition
| throws | ParseError if the formula cannot be parsed |
| EmpiricalFormula operator* | ( | const SignedSize & | times | ) | const |
multiplies the elements and charge with a factor
| EmpiricalFormula operator+ | ( | const EmpiricalFormula & | rhs | ) | const |
adds the elements of the given formula and returns a new formula
| EmpiricalFormula operator+ | ( | const String & | rhs | ) | const |
adds the elements of the given formula (given as a String) and returns a new formula
| throws | ParseError if the formula cannot be parsed |
| EmpiricalFormula& operator+= | ( | const String & | rhs | ) |
| EmpiricalFormula& operator+= | ( | const EmpiricalFormula & | rhs | ) |
adds the elements of the given formula
| EmpiricalFormula operator- | ( | const EmpiricalFormula & | rhs | ) | const |
subtracts the elements of a formula an returns a new formula
| EmpiricalFormula operator- | ( | const String & | rhs | ) | const |
subtracts the elements of a formula given as a String and returns a new formula
| throws | ParseError if the formula cannot be parsed |
| EmpiricalFormula& operator-= | ( | const String & | rhs | ) |
subtracts the elements of a formula given as string
| throws | ParseError if the formula cannot be parsed |
| EmpiricalFormula& operator-= | ( | const EmpiricalFormula & | rhs | ) |
subtracts the elements of a formula
| EmpiricalFormula& operator= | ( | const EmpiricalFormula & | rhs | ) |
assignment operator
Assignment
| EmpiricalFormula& operator= | ( | const String & | rhs | ) |
assignment operator which assigns an string to the formula
| throws | ParseError if the formula cannot be parsed |
| bool operator== | ( | const EmpiricalFormula & | rhs | ) | const |
returns true if the formulas contain equal elements in equal quantities
| bool operator== | ( | const String & | rhs | ) | const |
returns true if the formulas contain equal elements in equal quantities
| throws | ParseError if the formula cannot be parsed |
| SignedSize parseFormula_ | ( | Map< const Element *, SignedSize > & | ef, | |
| const String & | formula | |||
| ) | const [protected] |
| void readElementsFromFile_ | ( | const String & | file_name | ) | [protected] |
| void removeZeroedElements_ | ( | ) | [protected] |
remove elements with count 0
| void setCharge | ( | SignedSize | charge | ) |
sets the charge
Referenced by initModificationMassesRNA().
| std::ostream& operator<< | ( | std::ostream & | os, | |
| const EmpiricalFormula & | formula | |||
| ) | [friend] |
writes the formula to a stream
SignedSize charge_ [protected] |
const ElementDB* element_db_ [protected] |
Map<const Element *, SignedSize> formula_ [protected] |
| OpenMS / TOPP release 1.10.0 | Documentation generated on Thu Mar 7 2013 09:42:50 using doxygen 1.7.1 |