Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
EmpiricalFormula.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2013.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Andreas Bertsch $
32 // $Authors: Andreas Bertsch $
33 // --------------------------------------------------------------------------
34 //
35 #ifndef OPENMS_CHEMISTRY_EMPIRICALFORMULA_H
36 #define OPENMS_CHEMISTRY_EMPIRICALFORMULA_H
37 
38 #include <iostream>
39 #include <vector>
40 
44 #include <OpenMS/CONCEPT/Types.h>
45 
46 namespace OpenMS
47 {
48  class Element;
49  class ElementDB;
78  class OPENMS_DLLAPI EmpiricalFormula
79  {
80 
81 public:
82 
89 
95 
98 
103  EmpiricalFormula(const String & rhs);
104 
106  EmpiricalFormula(SignedSize number, const Element * element, SignedSize charge = 0);
107 
109  virtual ~EmpiricalFormula();
111 
115  DoubleReal getMonoWeight() const;
117 
119  DoubleReal getAverageWeight() const;
120 
126  IsotopeDistribution getIsotopeDistribution(UInt max_depth) const;
127 
129  const Element * getElement(const String & name) const;
130 
132  const Element * getElement(UInt atomic_number) const;
133 
135  const ElementDB * getElementDB() const;
136 
138  Size getNumberOf(UInt atomic_number) const;
139 
141  Size getNumberOf(const String & name) const;
142 
144  Size getNumberOf(const Element * element) const;
145 
147  Size getNumberOfAtoms() const;
148 
150  SignedSize getCharge() const;
151 
153  void setCharge(SignedSize charge);
154 
156  String getString() const;
158 
162  EmpiricalFormula & operator=(const EmpiricalFormula & rhs);
164 
169  EmpiricalFormula & operator=(const String & rhs);
170 
172  EmpiricalFormula & operator+=(const EmpiricalFormula & rhs);
173 
178  EmpiricalFormula & operator+=(const String & rhs);
179 
181  EmpiricalFormula operator*(const SignedSize & times) const;
182 
184  EmpiricalFormula operator+(const EmpiricalFormula & rhs) const;
185 
190  EmpiricalFormula operator+(const String & rhs) const;
191 
193  EmpiricalFormula & operator-=(const EmpiricalFormula & rhs);
194 
199  EmpiricalFormula & operator-=(const String & rhs);
200 
202  EmpiricalFormula operator-(const EmpiricalFormula & rhs) const;
203 
208  EmpiricalFormula operator-(const String & rhs) const;
210 
214  bool isEmpty() const;
216 
218  bool isCharged() const;
219 
221  bool hasElement(const Element * element) const;
222 
224  bool hasElement(const String & name) const;
225 
227  bool hasElement(UInt atomic_number) const;
228 
230  bool operator==(const EmpiricalFormula & rhs) const;
231 
236  bool operator==(const String & rhs) const;
237 
239  bool operator!=(const EmpiricalFormula & rhs) const;
240 
245  bool operator!=(const String & rhs) const;
247 
249  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const EmpiricalFormula & formula);
250 
254  inline ConstIterator begin() const { return formula_.begin(); }
255 
256  inline ConstIterator end() const { return formula_.end(); }
258 
259 protected:
260 
262  void removeZeroedElements_();
263 
265 
267 
268  void readElementsFromFile_(const String & file_name);
269 
270  SignedSize parseFormula_(Map<const Element *, SignedSize> & ef, const String & formula) const;
271 
273  };
274 
275  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const EmpiricalFormula & formula);
276 
277 } // namespace OpenMS
278 #endif
A more convenient string class.
Definition: String.h:56
Map< const Element *, SignedSize >::ConstIterator const_iterator
Definition: EmpiricalFormula.h:88
SignedSize charge_
Definition: EmpiricalFormula.h:266
Map< const Element *, SignedSize >::ConstIterator ConstIterator
Iterators.
Definition: EmpiricalFormula.h:87
Map< const Element *, SignedSize > formula_
Definition: EmpiricalFormula.h:264
Isotope distribution class.
Definition: IsotopeDistribution.h:61
std::ostream & operator<<(std::ostream &os, const ItraqQuantifier::ItraqQuantifierStats &stats)
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:151
Representation of an empirical formula.
Definition: EmpiricalFormula.h:78
ConstIterator end() const
Definition: EmpiricalFormula.h:256
Representation of an element.
Definition: Element.h:54
DPosition< D, TCoordinateType > operator*(DPosition< D, TCoordinateType > position, typename DPosition< D, TCoordinateType >::CoordinateType scalar)
Scalar multiplication (a bit inefficient)
Definition: DPosition.h:415
Base::const_iterator ConstIterator
Definition: Map.h:81
Stores elements.
Definition: ElementDB.h:70
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
ConstIterator begin() const
Definition: EmpiricalFormula.h:254
const ElementDB * element_db_
Definition: EmpiricalFormula.h:272
Map class based on the STL map (containing serveral convenience functions)
Definition: Map.h:50

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:13 using doxygen 1.8.5