#include <OpenMS/CHEMISTRY/EmpiricalFormula.h>
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 '+' or '-' followed by a number, if no number follows the charge of +/- 1 is set.
Public Types | |
Typedefs | |
typedef HashMap< const Element *, UInt >::ConstIterator | ConstIterator |
Iterators. | |
typedef HashMap< const Element *, UInt >::ConstIterator | const_iterator |
Public Member Functions | |
Constructors and Destructors | |
EmpiricalFormula () | |
default constructor | |
EmpiricalFormula (const EmpiricalFormula &rhs) | |
copy constructor | |
EmpiricalFormula (const String &rhs) throw (Exception::ParseError) | |
constructor from an OpenMS String | |
EmpiricalFormula (UInt number, const Element *element, Int charge=0) | |
constructor with element pointer and number | |
virtual | ~EmpiricalFormula () |
destructor | |
Accessors | |
DoubleReal | getMonoWeight () const |
returns the mono isotopic weight of the formula | |
DoubleReal | getAverageWeight () const |
returns the average weight of the formula | |
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 | |
UInt | getNumberOf (UInt atomic_number) const |
returns the number of atoms with the given atomic_number | |
UInt | getNumberOf (const String &name) const |
returns the number of atoms with the given name | |
UInt | getNumberOf (const Element *element) const |
returns the number of atoms | |
UInt | getNumberOfAtoms () const |
returns the atoms total | |
Int | getCharge () const |
returns the charge | |
void | setCharge (Int charge) |
sets the charge | |
String | getString () const |
returns the formula as a string | |
EmpiricalFormula & | operator= (const EmpiricalFormula &rhs) |
assignment operator | |
EmpiricalFormula & | operator= (const String &rhs) throw (Exception::ParseError) |
assignment operator which assigns an string to the formula | |
EmpiricalFormula & | operator+= (const EmpiricalFormula &rhs) |
adds the elements of the given formula | |
EmpiricalFormula & | operator+= (const String &rhs) throw (Exception::ParseError) |
adds the elements from the given formula, which is given as a OpenMS String | |
EmpiricalFormula | operator+ (const EmpiricalFormula &rhs) const |
adds the elements of the given formula and returns a new formula | |
EmpiricalFormula | operator+ (const String &rhs) const throw (Exception::ParseError) |
adds the elements of the given formula (given as a String) and returns a new formula | |
EmpiricalFormula & | operator-= (const EmpiricalFormula &rhs) throw (Exception::SizeUnderflow) |
subtracts the elements of a formula | |
EmpiricalFormula & | operator-= (const String &rhs) throw (Exception::ParseError, Exception::SizeUnderflow) |
subtracts the elements of a formula given as string | |
EmpiricalFormula | operator- (const EmpiricalFormula &rhs) const throw (Exception::SizeUnderflow) |
subtracts the elements of a formula an returns a new formula | |
EmpiricalFormula | operator- (const String &rhs) const throw (Exception::ParseError, Exception::SizeUnderflow) |
subtracts the elements of a formula given as a String and returns a new formula | |
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 throw (Exception::ParseError) |
returns true if the formulas contain equal elements in equal quantities | |
bool | operator!= (const EmpiricalFormula &rhs) const |
returns true if the formulas differ in elements composition | |
bool | operator!= (const String &rhs) const throw (Exception::ParseError) |
returns true if the formulas differ in elements composition | |
Iterators | |
ConstIterator | begin () const |
ConstIterator | end () const |
Protected Member Functions | |
void | readElementsFromFile_ (const String &file_name) throw (Exception::FileNotFound, Exception::ParseError) |
Int | parseFormula_ (HashMap< const Element *, UInt > &ef, const String &formula) const throw (Exception::ParseError) |
Protected Attributes | |
HashMap< const Element *, UInt > | formula_ |
Int | charge_ |
const ElementDB * | element_db_ |
Friends | |
std::ostream & | operator<< (std::ostream &, const EmpiricalFormula &) |
writes the formula to a stream |
typedef HashMap<const Element*, UInt>::ConstIterator ConstIterator |
Iterators.
typedef HashMap<const Element*, UInt>::ConstIterator const_iterator |
EmpiricalFormula | ( | ) |
default constructor
EmpiricalFormula | ( | const EmpiricalFormula & | rhs | ) |
copy constructor
EmpiricalFormula | ( | const String & | rhs | ) | throw (Exception::ParseError) |
EmpiricalFormula | ( | UInt | number, | |
const Element * | element, | |||
Int | charge = 0 | |||
) |
constructor with element pointer and number
virtual ~EmpiricalFormula | ( | ) | [virtual] |
destructor
DoubleReal getMonoWeight | ( | ) | const |
returns the mono isotopic weight of the formula
DoubleReal getAverageWeight | ( | ) | const |
returns the average weight of the formula
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 |
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
returns the number of atoms with the given atomic_number
UInt getNumberOfAtoms | ( | ) | const |
returns the atoms total
Int getCharge | ( | ) | const |
returns the charge
void setCharge | ( | Int | charge | ) |
sets the charge
String getString | ( | ) | const |
returns the formula as a string
EmpiricalFormula& operator= | ( | const EmpiricalFormula & | rhs | ) |
assignment operator
Assignment
EmpiricalFormula& operator= | ( | const String & | rhs | ) | throw (Exception::ParseError) |
assignment operator which assigns an string to the formula
EmpiricalFormula& operator+= | ( | const EmpiricalFormula & | rhs | ) |
adds the elements of the given formula
EmpiricalFormula& operator+= | ( | const String & | rhs | ) | throw (Exception::ParseError) |
EmpiricalFormula operator+ | ( | const EmpiricalFormula & | rhs | ) | const |
adds the elements of the given formula and returns a new formula
EmpiricalFormula operator+ | ( | const String & | rhs | ) | const throw (Exception::ParseError) |
adds the elements of the given formula (given as a String) and returns a new formula
EmpiricalFormula& operator-= | ( | const EmpiricalFormula & | rhs | ) | throw (Exception::SizeUnderflow) |
subtracts the elements of a formula
EmpiricalFormula& operator-= | ( | const String & | rhs | ) | throw (Exception::ParseError, Exception::SizeUnderflow) |
subtracts the elements of a formula given as string
EmpiricalFormula operator- | ( | const EmpiricalFormula & | rhs | ) | const throw (Exception::SizeUnderflow) |
subtracts the elements of a formula an returns a new formula
EmpiricalFormula operator- | ( | const String & | rhs | ) | const throw (Exception::ParseError, Exception::SizeUnderflow) |
subtracts the elements of a formula given as a String and returns a new formula
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 throw (Exception::ParseError) |
returns true if the formulas contain equal elements in equal quantities
bool operator!= | ( | const EmpiricalFormula & | rhs | ) | const |
returns true if the formulas differ in elements composition
bool operator!= | ( | const String & | rhs | ) | const throw (Exception::ParseError) |
returns true if the formulas differ in elements composition
ConstIterator begin | ( | ) | const [inline] |
ConstIterator end | ( | ) | const [inline] |
void readElementsFromFile_ | ( | const String & | file_name | ) | throw (Exception::FileNotFound, Exception::ParseError) [protected] |
Int parseFormula_ | ( | HashMap< const Element *, UInt > & | ef, | |
const String & | formula | |||
) | const throw (Exception::ParseError) [protected] |
std::ostream& operator<< | ( | std::ostream & | , | |
const EmpiricalFormula & | ||||
) | [friend] |
writes the formula to a stream
const ElementDB* element_db_ [protected] |
Generated Tue Apr 1 15:36:42 2008 -- using doxygen 1.5.4 | OpenMS / TOPP 1.1 |