Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

EmpiricalFormula Class Reference
[Chemistry]

#include <OpenMS/CHEMISTRY/EmpiricalFormula.h>

List of all members.


Detailed Description

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 '+' 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 ElementgetElement (const String &name) const
 returns a pointer to the element with name or symbol or 0 if no such element is fount
const ElementgetElement (UInt atomic_number) const
 returns a pointer to the element with given atomic number or 0 if none if found
const ElementDBgetElementDB () 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
EmpiricalFormulaoperator= (const EmpiricalFormula &rhs)
 assignment operator
EmpiricalFormulaoperator= (const String &rhs) throw (Exception::ParseError)
 assignment operator which assigns an string to the formula
EmpiricalFormulaoperator+= (const EmpiricalFormula &rhs)
 adds the elements of the given formula
EmpiricalFormulaoperator+= (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
EmpiricalFormulaoperator-= (const EmpiricalFormula &rhs) throw (Exception::SizeUnderflow)
 subtracts the elements of a formula
EmpiricalFormulaoperator-= (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 *, UIntformula_
Int charge_
const ElementDBelement_db_

Friends

std::ostream & operator<< (std::ostream &, const EmpiricalFormula &)
 writes the formula to a stream


Member Typedef Documentation

typedef HashMap<const Element*, UInt>::ConstIterator ConstIterator

Iterators.

typedef HashMap<const Element*, UInt>::ConstIterator const_iterator


Constructor & Destructor Documentation

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 (  )  [virtual]

destructor


Member Function Documentation

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.

Parameters:
max_depth,: this parameter gives the max isotope which is considered, if 0 all are reported

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

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)

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

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]


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const EmpiricalFormula  
) [friend]

writes the formula to a stream


Member Data Documentation

HashMap<const Element*, UInt> formula_ [protected]

Int charge_ [protected]

const ElementDB* element_db_ [protected]


The documentation for this class was generated from the following file:
Generated Tue Apr 1 15:36:42 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1