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-2017.
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: Chris Bielow $
32 // $Authors: Andreas Bertsch, Chris Bielow $
33 // --------------------------------------------------------------------------
34 //
35 #ifndef OPENMS_CHEMISTRY_EMPIRICALFORMULA_H
36 #define OPENMS_CHEMISTRY_EMPIRICALFORMULA_H
37 
38 #include <iosfwd>
39 #include <map>
40 #include <set>
41 #include <algorithm>
42 
43 #include <OpenMS/CONCEPT/Types.h>
44 
45 namespace OpenMS
46 {
47  class String;
48  class Element;
49  class ElementDB;
50  class IsotopeDistribution;
51 
80  class OPENMS_DLLAPI EmpiricalFormula
81  {
82 
83 protected:
85  typedef std::map<const Element*, SignedSize> MapType_;
86 
87 public:
91  typedef MapType_::const_iterator ConstIterator;
93  typedef MapType_::const_iterator const_iterator;
95 
101 
104 
110  explicit EmpiricalFormula(const String& rhs);
111 
113  EmpiricalFormula(SignedSize number, const Element* element, SignedSize charge = 0);
114 
116  virtual ~EmpiricalFormula();
118 
122  double getMonoWeight() const;
124 
126  double getAverageWeight() const;
127 
141  bool estimateFromWeightAndComp(double average_weight, double C, double H, double N, double O, double S, double P);
142 
157  bool estimateFromWeightAndCompAndS(double average_weight, UInt S, double C, double H, double N, double O, double P);
158 
159 
167  IsotopeDistribution getIsotopeDistribution(UInt max_depth) const;
168 
178  IsotopeDistribution getConditionalFragmentIsotopeDist(const EmpiricalFormula& precursor, const std::set<UInt>& precursor_isotopes) const;
179 
181  SignedSize getNumberOf(const Element* element) const;
182 
184  SignedSize getNumberOfAtoms() const;
185 
187  SignedSize getCharge() const;
188 
190  void setCharge(SignedSize charge);
191 
193  String toString() const;
195 
199  EmpiricalFormula& operator=(const EmpiricalFormula& rhs);
201 
203  EmpiricalFormula& operator+=(const EmpiricalFormula& rhs);
204 
206  EmpiricalFormula operator*(const SignedSize& times) const;
207 
209  EmpiricalFormula operator+(const EmpiricalFormula& rhs) const;
210 
212  EmpiricalFormula& operator-=(const EmpiricalFormula& rhs);
213 
215  EmpiricalFormula operator-(const EmpiricalFormula& rhs) const;
216 
218 
222  bool isEmpty() const;
224 
226  bool isCharged() const;
227 
229  bool hasElement(const Element* element) const;
230 
232  bool contains(const EmpiricalFormula& ef);
233 
235  bool operator==(const EmpiricalFormula& rhs) const;
236 
238  bool operator!=(const EmpiricalFormula& rhs) const;
239 
241 
243  friend OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const EmpiricalFormula& formula);
244 
248  inline ConstIterator begin() const { return formula_.begin(); }
249 
250  inline ConstIterator end() const { return formula_.end(); }
252 
253 protected:
254 
256  void removeZeroedElements_();
257 
258  MapType_ formula_;
259 
261 
262  SignedSize parseFormula_(std::map<const Element*, SignedSize>& ef, const String& formula) const;
263 
264  };
265 
266  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const EmpiricalFormula& formula);
267 
268 } // namespace OpenMS
269 #endif
A more convenient string class.
Definition: String.h:57
SignedSize charge_
Definition: EmpiricalFormula.h:260
ConstIterator begin() const
Definition: EmpiricalFormula.h:248
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
Isotope distribution class.
Definition: IsotopeDistribution.h:62
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:135
MapType_::const_iterator ConstIterator
Iterators.
Definition: EmpiricalFormula.h:92
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
MapType_ formula_
Definition: EmpiricalFormula.h:258
ConstIterator end() const
Definition: EmpiricalFormula.h:250
Representation of an empirical formula.
Definition: EmpiricalFormula.h:80
Representation of an element.
Definition: Element.h:54
MapType_::const_iterator const_iterator
Definition: EmpiricalFormula.h:93
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
DPosition< D, TCoordinateType > operator*(DPosition< D, TCoordinateType > position, typename DPosition< D, TCoordinateType >::CoordinateType scalar)
Scalar multiplication (a bit inefficient)
Definition: DPosition.h:421
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
std::map< const Element *, SignedSize > MapType_
Internal typedef for the used map type.
Definition: EmpiricalFormula.h:85
String toString(T i)
toString functions (single argument)
Definition: StringUtils.h:69

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:00 using doxygen 1.8.13