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

EmpiricalFormula.h (Maintainer: Andreas Bertsch)

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // --------------------------------------------------------------------------
00005 //                   OpenMS Mass Spectrometry Framework
00006 // --------------------------------------------------------------------------
00007 //  Copyright (C) 2003-2008 -- Oliver Kohlbacher, Knut Reinert
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Lesser General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //  This library is distributed in the hope that it will be useful,
00015 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //  Lesser General Public License for more details.
00018 //
00019 //  You should have received a copy of the GNU Lesser General Public
00020 //  License along with this library; if not, write to the Free Software
00021 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 // --------------------------------------------------------------------------
00024 // $Maintainer: Andreas Bertsch $
00025 // --------------------------------------------------------------------------
00026 //
00027 #ifndef OPENMS_CHEMISTRY_EMPIRICALFORMULA_H
00028 #define OPENMS_CHEMISTRY_EMPIRICALFORMULA_H
00029 
00030 #include <iostream>
00031 #include <vector>
00032 
00033 #include <OpenMS/DATASTRUCTURES/String.h>
00034 #include <OpenMS/DATASTRUCTURES/HashMap.h>
00035 #include <OpenMS/CHEMISTRY/IsotopeDistribution.h>
00036 #include <OpenMS/CONCEPT/Types.h>
00037 
00038 namespace OpenMS
00039 {
00040   class Element;
00041   class ElementDB;
00057   class EmpiricalFormula
00058   {
00059 
00060     public:
00061 
00065 
00066       typedef HashMap<const Element*, UInt>::ConstIterator ConstIterator;
00067       typedef HashMap<const Element*, UInt>::ConstIterator const_iterator;
00068 
00072 
00073       EmpiricalFormula();
00074 
00076       EmpiricalFormula(const EmpiricalFormula& rhs);
00077 
00079       EmpiricalFormula(const String& rhs) throw(Exception::ParseError);
00080 
00082       EmpiricalFormula(UInt number, const Element* element, Int charge = 0);
00083 
00085       virtual ~EmpiricalFormula();
00087 
00091 
00092       DoubleReal getMonoWeight() const;
00093 
00095       DoubleReal getAverageWeight() const;
00096 
00102       IsotopeDistribution getIsotopeDistribution(UInt max_depth) const;
00103 
00105       const Element* getElement(const String& name) const;
00106 
00108       const Element* getElement(UInt atomic_number) const;
00109 
00111       const ElementDB* getElementDB() const;
00112 
00114       UInt getNumberOf(UInt atomic_number) const;
00115 
00117       UInt getNumberOf(const String& name) const;
00118 
00120       UInt getNumberOf(const Element* element) const;
00121 
00123       UInt getNumberOfAtoms() const;
00124 
00126       Int getCharge() const;
00127 
00129       void setCharge(Int charge);
00130 
00132       String getString() const;
00134 
00138 
00139       EmpiricalFormula& operator = (const EmpiricalFormula& rhs);
00140 
00142       EmpiricalFormula& operator = (const String& rhs) throw(Exception::ParseError);
00143 
00145       EmpiricalFormula& operator += (const EmpiricalFormula& rhs);
00146 
00148       EmpiricalFormula& operator += (const String& rhs) throw(Exception::ParseError);
00149 
00151       EmpiricalFormula operator + (const EmpiricalFormula& rhs) const;
00152 
00154       EmpiricalFormula operator + (const String& rhs) const throw(Exception::ParseError);
00155 
00157       EmpiricalFormula& operator -= (const EmpiricalFormula& rhs) throw(Exception::SizeUnderflow);
00158 
00160       EmpiricalFormula& operator -= (const String& rhs) throw(Exception::ParseError, Exception::SizeUnderflow);
00161 
00163       EmpiricalFormula operator - (const EmpiricalFormula& rhs) const throw(Exception::SizeUnderflow);
00164 
00166       EmpiricalFormula operator - (const String& rhs) const throw(Exception::ParseError, Exception::SizeUnderflow);
00168 
00172 
00173       bool isEmpty() const;
00174 
00176       bool isCharged() const;
00177 
00179       bool hasElement(const Element* element) const;
00180 
00182       bool hasElement(const String& name) const;
00183 
00185       bool hasElement(UInt atomic_number) const;
00186 
00188       bool operator == (const EmpiricalFormula& rhs) const;
00189 
00191       bool operator == (const String& rhs) const throw(Exception::ParseError);
00192 
00194       bool operator != (const EmpiricalFormula& rhs) const;
00195 
00197       bool operator != (const String& rhs) const throw(Exception::ParseError);
00199 
00201       friend std::ostream& operator << (std::ostream&, const EmpiricalFormula&);
00202 
00206       inline ConstIterator begin() const { return formula_.begin(); }
00207 
00208       inline ConstIterator end() const { return formula_.end(); }
00210 
00211     protected:
00212 
00213       HashMap<const Element*, UInt> formula_;
00214 
00215       Int charge_;
00216 
00217       void readElementsFromFile_(const String& file_name) throw(Exception::FileNotFound, Exception::ParseError);
00218 
00219       Int parseFormula_(HashMap<const Element*, UInt>& ef,const String& formula) const throw(Exception::ParseError);
00220 
00221       const ElementDB* element_db_;
00222   };
00223 
00224   std::ostream& operator << (std::ostream&, const EmpiricalFormula::EmpiricalFormula&);
00225 
00226 } // namespace OpenMS
00227 #endif

Generated Tue Apr 1 15:36:34 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1