Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
IMSIsotopeDistribution.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: Timo Sachsenberg $
32 // $Authors: Anton Pervukhin <Anton.Pervukhin@CeBiTec.Uni-Bielefeld.DE> $
33 // --------------------------------------------------------------------------
34 //
35 
36 #ifndef OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_IMSISOTOPEDISTRIBUTION_H
37 #define OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_IMSISOTOPEDISTRIBUTION_H
38 
39 #include <vector>
40 #include <ostream>
41 #include <algorithm>
42 
43 #include <OpenMS/config.h>
44 
45 namespace OpenMS
46 {
47 
48  namespace ims
49  {
50 
88  class OPENMS_DLLAPI IMSIsotopeDistribution
89  {
90 
91 public:
93  typedef double mass_type;
94 
96  typedef double abundance_type;
97 
99  typedef unsigned int nominal_mass_type;
100 
102  struct Peak
103  {
104  Peak(mass_type local_mass = 0.0, abundance_type local_abundance = 0.0) :
105  mass(local_mass), abundance(local_abundance)
106  {}
107 
108  bool operator==(const Peak & peak) const
109  {
110 #pragma clang diagnostic push
111 #pragma clang diagnostic ignored "-Wfloat-equal"
112  return peak.mass == mass && peak.abundance == abundance;
113 #pragma clang diagnostic pop
114  }
115 
116  mass_type mass;
117  abundance_type abundance;
118  };
119 
121  typedef Peak peak_type;
122 
124  typedef std::vector<peak_type> peaks_container;
125 
127  typedef peaks_container::iterator peaks_iterator;
128 
130  typedef peaks_container::const_iterator const_peaks_iterator;
131 
133  typedef peaks_container::size_type size_type;
134 
136  typedef std::vector<mass_type> masses_container;
137 
139  typedef masses_container::iterator masses_iterator;
140 
142  typedef masses_container::const_iterator const_masses_iterator;
143 
145  typedef std::vector<abundance_type> abundances_container;
146 
148  typedef abundances_container::iterator abundances_iterator;
149 
151  typedef abundances_container::const_iterator const_abundances_iterator;
152 
154  static abundance_type ABUNDANCES_SUM_ERROR;
155 
157  static size_type SIZE;
158 
160  explicit IMSIsotopeDistribution(nominal_mass_type nominalMass = 0) :
161  nominal_mass_(nominalMass)
162  {}
163 
165  explicit IMSIsotopeDistribution(mass_type mass) :
166  nominal_mass_(0)
167  {
168  peaks_.push_back(peaks_container::value_type(mass, 1.0));
169  }
170 
172  IMSIsotopeDistribution(const peaks_container & peaks,
173  nominal_mass_type nominalMass = 0) :
174  peaks_(peaks),
175  nominal_mass_(nominalMass)
176  {}
177 
180  peaks_(distribution.peaks_),
181  nominal_mass_(distribution.nominal_mass_)
182  {}
183 
186  {}
187 
194  size_type size() const { return std::min(peaks_.size(), SIZE); }
195 
202  IMSIsotopeDistribution & operator=(
203  const IMSIsotopeDistribution & distribution);
204 
212  bool operator==(const IMSIsotopeDistribution & distribution) const;
213 
221  bool operator!=(const IMSIsotopeDistribution & distribution) const;
222 
233  IMSIsotopeDistribution & operator*=(
234  const IMSIsotopeDistribution & distribution);
235 
246  IMSIsotopeDistribution & operator*=(unsigned int pow);
247 
254  mass_type getMass(size_type i) const
255  {
256  return peaks_[i].mass + nominal_mass_ + i;
257  }
258 
265  abundance_type getAbundance(size_type i) const
266  {
267  return peaks_[i].abundance;
268  }
269 
275  mass_type getAverageMass() const;
276 
282  nominal_mass_type getNominalMass() const { return nominal_mass_; }
283 
289  void setNominalMass(nominal_mass_type nominalMass)
290  {
291  this->nominal_mass_ = nominalMass;
292  }
293 
299  masses_container getMasses() const;
300 
306  abundances_container getAbundances() const;
307 
313  void normalize();
314 
320  bool empty() const { return peaks_.empty(); }
321 
322 private:
324  peaks_container peaks_;
325 
327  nominal_mass_type nominal_mass_;
328 
330  void setMinimumSize_();
331  };
332 
339  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os,
340  const IMSIsotopeDistribution & distribution);
341 
342  } // namespace ims
343 } // namespace OpenMS
344 
345 #endif // OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_ISOTOPE_DISTRIBUTION_H
bool empty() const
Definition: IMSIsotopeDistribution.h:320
Peak peak_type
Type of isotope peak.
Definition: IMSIsotopeDistribution.h:121
Structure that represents an isotope peak - pair of mass and abundance.
Definition: IMSIsotopeDistribution.h:102
IMSIsotopeDistribution(const IMSIsotopeDistribution &distribution)
Copy constructor.
Definition: IMSIsotopeDistribution.h:179
std::vector< abundance_type > abundances_container
Type of container with isotope abundances.
Definition: IMSIsotopeDistribution.h:145
IMSIsotopeDistribution(mass_type mass)
Constructor with single isotope.
Definition: IMSIsotopeDistribution.h:165
std::vector< mass_type > masses_container
Type of container with isotope masses.
Definition: IMSIsotopeDistribution.h:136
static size_type SIZE
Length of isotope distribution.
Definition: IMSIsotopeDistribution.h:157
Peak(mass_type local_mass=0.0, abundance_type local_abundance=0.0)
Definition: IMSIsotopeDistribution.h:104
nominal_mass_type nominal_mass_
Nominal mass of distribution.
Definition: IMSIsotopeDistribution.h:327
masses_container::const_iterator const_masses_iterator
Type of const iterator over container with isotope masses.
Definition: IMSIsotopeDistribution.h:142
double mass_type
Type of isotope mass.
Definition: IMSIsotopeDistribution.h:93
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
bool operator==(const Peak &peak) const
Definition: IMSIsotopeDistribution.h:108
IMSIsotopeDistribution(nominal_mass_type nominalMass=0)
Constructor with nominal mass.
Definition: IMSIsotopeDistribution.h:160
mass_type mass
Definition: IMSIsotopeDistribution.h:116
Represents a distribution of isotopes restricted to the first K elements.
Definition: IMSIsotopeDistribution.h:88
abundance_type getAbundance(size_type i) const
Definition: IMSIsotopeDistribution.h:265
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OPENSWATHALGO_DLLAPI void normalize(const std::vector< double > &intensities, double normalization_factor, std::vector< double > &normalized_intensities)
Normalize intensities in vector by normalization_factor.
IMSIsotopeDistribution(const peaks_container &peaks, nominal_mass_type nominalMass=0)
Constructor with isotopes and nominal mass.
Definition: IMSIsotopeDistribution.h:172
void setNominalMass(nominal_mass_type nominalMass)
Definition: IMSIsotopeDistribution.h:289
peaks_container::const_iterator const_peaks_iterator
Type of const iterator over container with peaks.
Definition: IMSIsotopeDistribution.h:130
peaks_container::size_type size_type
Type of peaks container&#39;s size.
Definition: IMSIsotopeDistribution.h:133
double abundance_type
Type of isotope abundance.
Definition: IMSIsotopeDistribution.h:96
mass_type getMass(size_type i) const
Definition: IMSIsotopeDistribution.h:254
abundance_type abundance
Definition: IMSIsotopeDistribution.h:117
std::vector< peak_type > peaks_container
Type of container to store peaks.
Definition: IMSIsotopeDistribution.h:124
masses_container::iterator masses_iterator
Type of iterator over container with isotope masses.
Definition: IMSIsotopeDistribution.h:139
~IMSIsotopeDistribution()
Destructor.
Definition: IMSIsotopeDistribution.h:185
abundances_container::const_iterator const_abundances_iterator
Type of const iterator over container with isotope abundances.
Definition: IMSIsotopeDistribution.h:151
static abundance_type ABUNDANCES_SUM_ERROR
Error to be allowed for isotope distribution.
Definition: IMSIsotopeDistribution.h:154
unsigned int nominal_mass_type
Type of isotope nominal mass.
Definition: IMSIsotopeDistribution.h:99
nominal_mass_type getNominalMass() const
Definition: IMSIsotopeDistribution.h:282
size_type size() const
Definition: IMSIsotopeDistribution.h:194
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
peaks_container peaks_
Container for isotopes.
Definition: IMSIsotopeDistribution.h:324
peaks_container::iterator peaks_iterator
Type of iterator over container with peaks.
Definition: IMSIsotopeDistribution.h:127
abundances_container::iterator abundances_iterator
Type of iterator over container with isotope abundances.
Definition: IMSIsotopeDistribution.h:148
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)

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