OpenMS  2.8.0
ChromatogramPeak.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-2021.
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: Andreas Bertsch $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/CONCEPT/Types.h>
39 
40 #include <iosfwd>
41 #include <functional>
42 
43 namespace OpenMS
44 {
45 
53  class OPENMS_DLLAPI ChromatogramPeak
54  {
55 public:
61  enum {DIMENSION = 1};
63  typedef double IntensityType;
67  typedef double CoordinateType;
69 
75  inline ChromatogramPeak() :
76  position_(),
77  intensity_(0)
78  {}
79 
81  inline ChromatogramPeak(const ChromatogramPeak & p) :
82  position_(p.position_),
83  intensity_(p.intensity_)
84  {}
85 
87  inline ChromatogramPeak(const PositionType retention_time, const IntensityType intensity) :
88  position_(retention_time),
89  intensity_(intensity)
90  {}
91 
101  {}
103 
108 
110  inline IntensityType getIntensity() const { return intensity_; }
112  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
113 
115  inline CoordinateType getRT() const
116  {
117  return position_[0];
118  }
119 
121  inline void setRT(CoordinateType rt)
122  {
123  position_[0] = rt;
124  }
125 
127  inline CoordinateType getPos() const
128  {
129  return position_[0];
130  }
131 
133  inline void setPos(CoordinateType pos)
134  {
135  position_[0] = pos;
136  }
137 
139  inline CoordinateType getMZ() const
140  {
141  return position_[0];
142  }
143 
145  inline void setMZ(CoordinateType rt)
146  {
147  position_[0] = rt;
148  }
149 
151  inline PositionType const & getPosition() const
152  {
153  return position_;
154  }
155 
158  {
159  return position_;
160  }
161 
163  inline void setPosition(PositionType const & position)
164  {
165  position_ = position;
166  }
167 
169 
172  {
173  if (this == &rhs) return *this;
174 
175  intensity_ = rhs.intensity_;
176  position_ = rhs.position_;
177 
178  return *this;
179  }
180 
182  inline bool operator==(const ChromatogramPeak & rhs) const
183  {
184 #pragma clang diagnostic push
185 #pragma clang diagnostic ignored "-Wfloat-equal"
186  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
187 #pragma clang diagnostic pop
188  }
189 
191  inline bool operator!=(const ChromatogramPeak & rhs) const
192  {
193  return !(operator==(rhs));
194  }
195 
205  {
206  inline bool operator()(ChromatogramPeak const & left, ChromatogramPeak const & right) const
207  {
208  return left.getIntensity() < right.getIntensity();
209  }
210 
211  inline bool operator()(ChromatogramPeak const & left, IntensityType right) const
212  {
213  return left.getIntensity() < right;
214  }
215 
216  inline bool operator()(IntensityType left, ChromatogramPeak const & right) const
217  {
218  return left < right.getIntensity();
219  }
220 
221  inline bool operator()(IntensityType left, IntensityType right) const
222  {
223  return left < right;
224  }
225 
226  };
227 
229  struct RTLess
230  {
231  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
232  {
233  return left.getRT() < right.getPos();
234  }
235 
236  inline bool operator()(ChromatogramPeak const & left, CoordinateType right) const
237  {
238  return left.getRT() < right;
239  }
240 
241  inline bool operator()(CoordinateType left, ChromatogramPeak const & right) const
242  {
243  return left < right.getRT();
244  }
245 
246  inline bool operator()(CoordinateType left, CoordinateType right) const
247  {
248  return left < right;
249  }
250 
251  };
252 
255  {
256  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
257  {
258  return left.getPosition() < right.getPosition();
259  }
260 
261  inline bool operator()(const ChromatogramPeak & left, const PositionType & right) const
262  {
263  return left.getPosition() < right;
264  }
265 
266  inline bool operator()(const PositionType & left, const ChromatogramPeak & right) const
267  {
268  return left < right.getPosition();
269  }
270 
271  inline bool operator()(const PositionType & left, const PositionType & right) const
272  {
273  return left < right;
274  }
275  };
277 protected:
282  };
283 
285  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChromatogramPeak & point);
286 
287 } // namespace OpenMS
288 
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:54
ChromatogramPeak & operator=(const ChromatogramPeak &rhs)
Assignment operator.
Definition: ChromatogramPeak.h:171
CoordinateType getMZ() const
Alias for getRT()
Definition: ChromatogramPeak.h:139
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: ChromatogramPeak.h:151
DPosition< 1 > PositionType
Position type.
Definition: ChromatogramPeak.h:65
ChromatogramPeak(const PositionType retention_time, const IntensityType intensity)
Constructor with position and intensity.
Definition: ChromatogramPeak.h:87
double CoordinateType
Coordinate type.
Definition: ChromatogramPeak.h:67
PositionType position_
The data point position.
Definition: ChromatogramPeak.h:279
~ChromatogramPeak()
Destructor.
Definition: ChromatogramPeak.h:100
CoordinateType getPos() const
Alias for getRT()
Definition: ChromatogramPeak.h:127
IntensityType getIntensity() const
Non-mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:110
void setMZ(CoordinateType rt)
Alias for setRT()
Definition: ChromatogramPeak.h:145
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:121
bool operator!=(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:191
bool operator==(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:182
ChromatogramPeak(const ChromatogramPeak &p)
Copy constructor.
Definition: ChromatogramPeak.h:81
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:112
double IntensityType
Intensity type.
Definition: ChromatogramPeak.h:63
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: ChromatogramPeak.h:163
void setPos(CoordinateType pos)
Alias for setRT()
Definition: ChromatogramPeak.h:133
IntensityType intensity_
The data point intensity.
Definition: ChromatogramPeak.h:281
ChromatogramPeak()
Default constructor.
Definition: ChromatogramPeak.h:75
PositionType & getPosition()
Mutable access to the position.
Definition: ChromatogramPeak.h:157
CoordinateType getRT() const
Non-mutable access to RT.
Definition: ChromatogramPeak.h:115
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Comparator by intensity.
Definition: ChromatogramPeak.h:205
bool operator()(ChromatogramPeak const &left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:206
bool operator()(ChromatogramPeak const &left, IntensityType right) const
Definition: ChromatogramPeak.h:211
bool operator()(IntensityType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:216
bool operator()(IntensityType left, IntensityType right) const
Definition: ChromatogramPeak.h:221
Comparator by position. As this class has dimension 1, this is basically an alias for RTLess.
Definition: ChromatogramPeak.h:255
bool operator()(const PositionType &left, const PositionType &right) const
Definition: ChromatogramPeak.h:271
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:256
bool operator()(const PositionType &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:266
bool operator()(const ChromatogramPeak &left, const PositionType &right) const
Definition: ChromatogramPeak.h:261
Comparator by RT position.
Definition: ChromatogramPeak.h:230
bool operator()(CoordinateType left, CoordinateType right) const
Definition: ChromatogramPeak.h:246
bool operator()(ChromatogramPeak const &left, CoordinateType right) const
Definition: ChromatogramPeak.h:236
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:231
bool operator()(CoordinateType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:241