OpenMS  2.6.0
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-2020.
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 #pragma once
37 
38 #include <vector>
39 #include <iosfwd>
40 #include <algorithm>
41 
42 #include <OpenMS/config.h>
43 
44 namespace OpenMS
45 {
46 
47  namespace ims
48  {
49 
87  class OPENMS_DLLAPI IMSIsotopeDistribution
88  {
89 
90 public:
92  typedef double mass_type;
93 
95  typedef double abundance_type;
96 
98  typedef unsigned int nominal_mass_type;
99 
101  struct Peak
102  {
103  Peak(mass_type local_mass = 0.0, abundance_type local_abundance = 0.0) :
104  mass(local_mass), abundance(local_abundance)
105  {}
106 
107  bool operator==(const Peak & peak) const
108  {
109 #pragma clang diagnostic push
110 #pragma clang diagnostic ignored "-Wfloat-equal"
111  return peak.mass == mass && peak.abundance == abundance;
112 #pragma clang diagnostic pop
113  }
114 
117  };
118 
120  typedef Peak peak_type;
121 
123  typedef std::vector<peak_type> peaks_container;
124 
126  typedef peaks_container::iterator peaks_iterator;
127 
129  typedef peaks_container::const_iterator const_peaks_iterator;
130 
132  typedef peaks_container::size_type size_type;
133 
135  typedef std::vector<mass_type> masses_container;
136 
138  typedef masses_container::iterator masses_iterator;
139 
141  typedef masses_container::const_iterator const_masses_iterator;
142 
144  typedef std::vector<abundance_type> abundances_container;
145 
147  typedef abundances_container::iterator abundances_iterator;
148 
150  typedef abundances_container::const_iterator const_abundances_iterator;
151 
154 
156  static size_type SIZE;
157 
159  explicit IMSIsotopeDistribution(nominal_mass_type nominalMass = 0) :
160  nominal_mass_(nominalMass)
161  {}
162 
165  nominal_mass_(0)
166  {
167  peaks_.push_back(peaks_container::value_type(mass, 1.0));
168  }
169 
172  nominal_mass_type nominalMass = 0) :
173  peaks_(peaks),
174  nominal_mass_(nominalMass)
175  {}
176 
179  peaks_(distribution.peaks_),
180  nominal_mass_(distribution.nominal_mass_)
181  {}
182 
185  {}
186 
193  size_type size() const { return std::min(peaks_.size(), SIZE); }
194 
201  IMSIsotopeDistribution & operator=(
202  const IMSIsotopeDistribution & distribution);
203 
211  bool operator==(const IMSIsotopeDistribution & distribution) const;
212 
220  bool operator!=(const IMSIsotopeDistribution & distribution) const;
221 
232  IMSIsotopeDistribution & operator*=(
233  const IMSIsotopeDistribution & distribution);
234 
245  IMSIsotopeDistribution & operator*=(unsigned int pow);
246 
254  {
255  return peaks_[i].mass + nominal_mass_ + i;
256  }
257 
265  {
266  return peaks_[i].abundance;
267  }
268 
274  mass_type getAverageMass() const;
275 
281  nominal_mass_type getNominalMass() const { return nominal_mass_; }
282 
289  {
290  this->nominal_mass_ = nominalMass;
291  }
292 
298  masses_container getMasses() const;
299 
305  abundances_container getAbundances() const;
306 
312  void normalize();
313 
319  bool empty() const { return peaks_.empty(); }
320 
321 private:
324 
327 
329  void setMinimumSize_();
330  };
331 
338  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os,
339  const IMSIsotopeDistribution & distribution);
340 
341  } // namespace ims
342 } // namespace OpenMS
343 
OpenMS::ims::IMSIsotopeDistribution::Peak::Peak
Peak(mass_type local_mass=0.0, abundance_type local_abundance=0.0)
Definition: IMSIsotopeDistribution.h:103
OpenMS::ims::IMSIsotopeDistribution::Peak
Structure that represents an isotope peak - pair of mass and abundance.
Definition: IMSIsotopeDistribution.h:101
double
OpenMS::ims::IMSIsotopeDistribution::peak_type
Peak peak_type
Type of isotope peak.
Definition: IMSIsotopeDistribution.h:120
OpenMS::ims::IMSIsotopeDistribution::ABUNDANCES_SUM_ERROR
static abundance_type ABUNDANCES_SUM_ERROR
Error to be allowed for isotope distribution.
Definition: IMSIsotopeDistribution.h:153
OpenMS::ims::IMSIsotopeDistribution::getNominalMass
nominal_mass_type getNominalMass() const
Definition: IMSIsotopeDistribution.h:281
OpenMS::ims::IMSIsotopeDistribution::IMSIsotopeDistribution
IMSIsotopeDistribution(const IMSIsotopeDistribution &distribution)
Copy constructor.
Definition: IMSIsotopeDistribution.h:178
KDTree::operator!=
bool operator!=(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:824
OpenMS::ims::IMSIsotopeDistribution::Peak::abundance
abundance_type abundance
Definition: IMSIsotopeDistribution.h:116
OpenMS::ims::IMSIsotopeDistribution::getMass
mass_type getMass(size_type i) const
Definition: IMSIsotopeDistribution.h:253
OpenMS::ims::IMSIsotopeDistribution::~IMSIsotopeDistribution
~IMSIsotopeDistribution()
Destructor.
Definition: IMSIsotopeDistribution.h:184
OpenMS::ims::IMSIsotopeDistribution::Peak::operator==
bool operator==(const Peak &peak) const
Definition: IMSIsotopeDistribution.h:107
OpenMS::ims::IMSIsotopeDistribution::size_type
peaks_container::size_type size_type
Type of peaks container's size.
Definition: IMSIsotopeDistribution.h:132
OpenMS::ims::IMSIsotopeDistribution::IMSIsotopeDistribution
IMSIsotopeDistribution(const peaks_container &peaks, nominal_mass_type nominalMass=0)
Constructor with isotopes and nominal mass.
Definition: IMSIsotopeDistribution.h:171
OpenMS::ims::IMSIsotopeDistribution::abundances_container
std::vector< abundance_type > abundances_container
Type of container with isotope abundances.
Definition: IMSIsotopeDistribution.h:144
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::ims::IMSIsotopeDistribution::peaks_
peaks_container peaks_
Container for isotopes.
Definition: IMSIsotopeDistribution.h:323
OpenMS::ims::IMSIsotopeDistribution::const_masses_iterator
masses_container::const_iterator const_masses_iterator
Type of const iterator over container with isotope masses.
Definition: IMSIsotopeDistribution.h:141
OpenMS::ims::IMSIsotopeDistribution::mass_type
double mass_type
Type of isotope mass.
Definition: IMSIsotopeDistribution.h:92
OpenMS::ims::IMSIsotopeDistribution::size
size_type size() const
Definition: IMSIsotopeDistribution.h:193
OpenMS::ims::IMSIsotopeDistribution::getAbundance
abundance_type getAbundance(size_type i) const
Definition: IMSIsotopeDistribution.h:264
OpenMS::ims::IMSIsotopeDistribution::masses_iterator
masses_container::iterator masses_iterator
Type of iterator over container with isotope masses.
Definition: IMSIsotopeDistribution.h:138
OpenMS::ims::IMSIsotopeDistribution::setNominalMass
void setNominalMass(nominal_mass_type nominalMass)
Definition: IMSIsotopeDistribution.h:288
OpenMS::ims::IMSIsotopeDistribution::abundances_iterator
abundances_container::iterator abundances_iterator
Type of iterator over container with isotope abundances.
Definition: IMSIsotopeDistribution.h:147
OpenMS::ims::IMSIsotopeDistribution::peaks_iterator
peaks_container::iterator peaks_iterator
Type of iterator over container with peaks.
Definition: IMSIsotopeDistribution.h:126
OpenMS::ims::IMSIsotopeDistribution::IMSIsotopeDistribution
IMSIsotopeDistribution(mass_type mass)
Constructor with single isotope.
Definition: IMSIsotopeDistribution.h:164
OpenMS::ims::IMSIsotopeDistribution::SIZE
static size_type SIZE
Length of isotope distribution.
Definition: IMSIsotopeDistribution.h:156
OpenMS::ims::IMSIsotopeDistribution::empty
bool empty() const
Definition: IMSIsotopeDistribution.h:319
OpenMS::Internal::operator==
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
OpenMS::ims::IMSIsotopeDistribution::const_abundances_iterator
abundances_container::const_iterator const_abundances_iterator
Type of const iterator over container with isotope abundances.
Definition: IMSIsotopeDistribution.h:150
OpenMS::ims::IMSIsotopeDistribution::abundance_type
double abundance_type
Type of isotope abundance.
Definition: IMSIsotopeDistribution.h:95
OpenMS::ims::IMSIsotopeDistribution::IMSIsotopeDistribution
IMSIsotopeDistribution(nominal_mass_type nominalMass=0)
Constructor with nominal mass.
Definition: IMSIsotopeDistribution.h:159
OpenMS::ims::IMSIsotopeDistribution::const_peaks_iterator
peaks_container::const_iterator const_peaks_iterator
Type of const iterator over container with peaks.
Definition: IMSIsotopeDistribution.h:129
OpenMS::ims::operator<<
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)
OpenMS::ims::IMSIsotopeDistribution::nominal_mass_type
unsigned int nominal_mass_type
Type of isotope nominal mass.
Definition: IMSIsotopeDistribution.h:98
OpenMS::ims::IMSIsotopeDistribution::peaks_container
std::vector< peak_type > peaks_container
Type of container to store peaks.
Definition: IMSIsotopeDistribution.h:123
OpenMS::ims::IMSIsotopeDistribution::nominal_mass_
nominal_mass_type nominal_mass_
Nominal mass of distribution.
Definition: IMSIsotopeDistribution.h:326
OpenSwath::normalize
OPENSWATHALGO_DLLAPI void normalize(const std::vector< double > &intensities, double normalization_factor, std::vector< double > &normalized_intensities)
Normalize intensities in vector by normalization_factor.
OpenMS::ims::IMSIsotopeDistribution::masses_container
std::vector< mass_type > masses_container
Type of container with isotope masses.
Definition: IMSIsotopeDistribution.h:135
OpenMS::ims::IMSIsotopeDistribution
Represents a distribution of isotopes restricted to the first K elements.
Definition: IMSIsotopeDistribution.h:87
OpenMS::ims::IMSIsotopeDistribution::Peak::mass
mass_type mass
Definition: IMSIsotopeDistribution.h:115