OpenMS
Loading...
Searching...
No Matches
IMSIsotopeDistribution.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Anton Pervukhin <Anton.Pervukhin@CeBiTec.Uni-Bielefeld.DE> $
7// --------------------------------------------------------------------------
8//
9
10#pragma once
11
12#include <algorithm> // std::min
13#include <vector>
14#include <iosfwd>
15#include <algorithm>
16
17#include <OpenMS/config.h>
18
19namespace OpenMS
20{
21
22 namespace ims
23 {
24
62 class OPENMS_DLLAPI IMSIsotopeDistribution
63 {
64
65public:
67 typedef double mass_type;
68
70 typedef double abundance_type;
71
73 typedef unsigned int nominal_mass_type;
74
76 struct Peak
77 {
78 Peak(mass_type local_mass = 0.0, abundance_type local_abundance = 0.0) :
79 mass(local_mass), abundance(local_abundance)
80 {}
81
82 bool operator==(const Peak& peak) const = default;
83
86 };
87
89 typedef Peak peak_type;
90
92 typedef std::vector<peak_type> peaks_container;
93
95 typedef peaks_container::iterator peaks_iterator;
96
98 typedef peaks_container::const_iterator const_peaks_iterator;
99
101 typedef peaks_container::size_type size_type;
102
104 typedef std::vector<mass_type> masses_container;
105
107 typedef masses_container::iterator masses_iterator;
108
110 typedef masses_container::const_iterator const_masses_iterator;
111
113 typedef std::vector<abundance_type> abundances_container;
114
116 typedef abundances_container::iterator abundances_iterator;
117
119 typedef abundances_container::const_iterator const_abundances_iterator;
120
123
126
128 explicit IMSIsotopeDistribution(nominal_mass_type nominalMass = 0) :
129 nominal_mass_(nominalMass)
130 {}
131
134 nominal_mass_(0)
135 {
136 peaks_.push_back(peaks_container::value_type(mass, 1.0));
137 }
138
141 nominal_mass_type nominalMass = 0) :
142 peaks_(peaks),
143 nominal_mass_(nominalMass)
144 {}
145
148 peaks_(distribution.peaks_),
149 nominal_mass_(distribution.nominal_mass_)
150 {}
151
155
162 size_type size() const { return std::min(peaks_.size(), SIZE); }
163
171 const IMSIsotopeDistribution & distribution);
172
180 bool operator==(const IMSIsotopeDistribution & distribution) const;
181
189 bool operator!=(const IMSIsotopeDistribution & distribution) const;
190
202 const IMSIsotopeDistribution & distribution);
203
215
223 {
224 return peaks_[i].mass + nominal_mass_ + i;
225 }
226
234 {
235 return peaks_[i].abundance;
236 }
237
244
250 nominal_mass_type getNominalMass() const { return nominal_mass_; }
251
258 {
259 this->nominal_mass_ = nominalMass;
260 }
261
268
275
281 void normalize();
282
288 bool empty() const { return peaks_.empty(); }
289
290private:
293
296
299 };
300
307 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os,
308 const IMSIsotopeDistribution & distribution);
309
310 } // namespace ims
311} // namespace OpenMS
312
Represents a distribution of isotopes restricted to the first K elements.
Definition IMSIsotopeDistribution.h:63
masses_container getMasses() const
peaks_container peaks_
Container for isotopes.
Definition IMSIsotopeDistribution.h:292
void setMinimumSize_()
Sets peaks/isotopes container minimum size.
std::vector< peak_type > peaks_container
Type of container to store peaks.
Definition IMSIsotopeDistribution.h:92
bool operator!=(const IMSIsotopeDistribution &distribution) const
nominal_mass_type nominal_mass_
Nominal mass of distribution.
Definition IMSIsotopeDistribution.h:295
IMSIsotopeDistribution(nominal_mass_type nominalMass=0)
Constructor with nominal mass.
Definition IMSIsotopeDistribution.h:128
IMSIsotopeDistribution(const peaks_container &peaks, nominal_mass_type nominalMass=0)
Constructor with isotopes and nominal mass.
Definition IMSIsotopeDistribution.h:140
nominal_mass_type getNominalMass() const
Definition IMSIsotopeDistribution.h:250
double abundance_type
Type of isotope abundance.
Definition IMSIsotopeDistribution.h:70
IMSIsotopeDistribution(mass_type mass)
Constructor with single isotope.
Definition IMSIsotopeDistribution.h:133
size_type size() const
Definition IMSIsotopeDistribution.h:162
std::vector< abundance_type > abundances_container
Type of container with isotope abundances.
Definition IMSIsotopeDistribution.h:113
bool empty() const
Definition IMSIsotopeDistribution.h:288
abundances_container getAbundances() const
peaks_container::size_type size_type
Type of peaks container's size.
Definition IMSIsotopeDistribution.h:101
IMSIsotopeDistribution & operator=(const IMSIsotopeDistribution &distribution)
peaks_container::iterator peaks_iterator
Type of iterator over container with peaks.
Definition IMSIsotopeDistribution.h:95
static size_type SIZE
Length of isotope distribution.
Definition IMSIsotopeDistribution.h:125
IMSIsotopeDistribution & operator*=(const IMSIsotopeDistribution &distribution)
~IMSIsotopeDistribution()
Destructor.
Definition IMSIsotopeDistribution.h:153
bool operator==(const IMSIsotopeDistribution &distribution) const
Peak peak_type
Type of isotope peak.
Definition IMSIsotopeDistribution.h:89
IMSIsotopeDistribution(const IMSIsotopeDistribution &distribution)
Copy constructor.
Definition IMSIsotopeDistribution.h:147
abundance_type getAbundance(size_type i) const
Definition IMSIsotopeDistribution.h:233
mass_type getMass(size_type i) const
Definition IMSIsotopeDistribution.h:222
IMSIsotopeDistribution & operator*=(unsigned int pow)
abundances_container::iterator abundances_iterator
Type of iterator over container with isotope abundances.
Definition IMSIsotopeDistribution.h:116
masses_container::const_iterator const_masses_iterator
Type of const iterator over container with isotope masses.
Definition IMSIsotopeDistribution.h:110
abundances_container::const_iterator const_abundances_iterator
Type of const iterator over container with isotope abundances.
Definition IMSIsotopeDistribution.h:119
peaks_container::const_iterator const_peaks_iterator
Type of const iterator over container with peaks.
Definition IMSIsotopeDistribution.h:98
std::vector< mass_type > masses_container
Type of container with isotope masses.
Definition IMSIsotopeDistribution.h:104
masses_container::iterator masses_iterator
Type of iterator over container with isotope masses.
Definition IMSIsotopeDistribution.h:107
double mass_type
Type of isotope mass.
Definition IMSIsotopeDistribution.h:67
static abundance_type ABUNDANCES_SUM_ERROR
Error to be allowed for isotope distribution.
Definition IMSIsotopeDistribution.h:122
void setNominalMass(nominal_mass_type nominalMass)
Definition IMSIsotopeDistribution.h:257
unsigned int nominal_mass_type
Type of isotope nominal mass.
Definition IMSIsotopeDistribution.h:73
std::ostream & operator<<(std::ostream &os, const IMSAlphabet &alphabet)
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Structure that represents an isotope peak - pair of mass and abundance.
Definition IMSIsotopeDistribution.h:77
bool operator==(const Peak &peak) const =default
Peak(mass_type local_mass=0.0, abundance_type local_abundance=0.0)
Definition IMSIsotopeDistribution.h:78
abundance_type abundance
Definition IMSIsotopeDistribution.h:85
mass_type mass
Definition IMSIsotopeDistribution.h:84