OpenMS
ChromatogramPeak.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: Andreas Bertsch $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/CONCEPT/Types.h>
13 
14 #include <iosfwd>
15 #include <functional>
16 
17 namespace OpenMS
18 {
19 
27  class OPENMS_DLLAPI ChromatogramPeak
28  {
29 public:
35  enum {DIMENSION = 1};
37  typedef double IntensityType;
41  typedef double CoordinateType;
43 
49  inline ChromatogramPeak() :
50  position_(),
51  intensity_(0)
52  {}
53 
55  inline ChromatogramPeak(const ChromatogramPeak & p) :
56  position_(p.position_),
57  intensity_(p.intensity_)
58  {}
59 
61  inline ChromatogramPeak(const PositionType retention_time, const IntensityType intensity) :
62  position_(retention_time),
63  intensity_(intensity)
64  {}
65 
75  {}
77 
82 
84  inline IntensityType getIntensity() const { return intensity_; }
86  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
87 
89  inline CoordinateType getRT() const
90  {
91  return position_[0];
92  }
93 
95  inline void setRT(CoordinateType rt)
96  {
97  position_[0] = rt;
98  }
99 
101  inline CoordinateType getPos() const
102  {
103  return position_[0];
104  }
105 
107  inline void setPos(CoordinateType pos)
108  {
109  position_[0] = pos;
110  }
111 
113  inline CoordinateType getMZ() const
114  {
115  return position_[0];
116  }
117 
119  inline void setMZ(CoordinateType rt)
120  {
121  position_[0] = rt;
122  }
123 
125  inline PositionType const & getPosition() const
126  {
127  return position_;
128  }
129 
132  {
133  return position_;
134  }
135 
137  inline void setPosition(PositionType const & position)
138  {
139  position_ = position;
140  }
141 
143 
146  {
147  if (this == &rhs) return *this;
148 
149  intensity_ = rhs.intensity_;
150  position_ = rhs.position_;
151 
152  return *this;
153  }
154 
156  inline bool operator==(const ChromatogramPeak & rhs) const
157  {
158 #pragma clang diagnostic push
159 #pragma clang diagnostic ignored "-Wfloat-equal"
160  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
161 #pragma clang diagnostic pop
162  }
163 
165  inline bool operator!=(const ChromatogramPeak & rhs) const
166  {
167  return !(operator==(rhs));
168  }
169 
179  {
180  inline bool operator()(ChromatogramPeak const & left, ChromatogramPeak const & right) const
181  {
182  return left.getIntensity() < right.getIntensity();
183  }
184 
185  inline bool operator()(ChromatogramPeak const & left, IntensityType right) const
186  {
187  return left.getIntensity() < right;
188  }
189 
190  inline bool operator()(IntensityType left, ChromatogramPeak const & right) const
191  {
192  return left < right.getIntensity();
193  }
194 
195  inline bool operator()(IntensityType left, IntensityType right) const
196  {
197  return left < right;
198  }
199 
200  };
201 
203  struct RTLess
204  {
205  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
206  {
207  return left.getRT() < right.getPos();
208  }
209 
210  inline bool operator()(ChromatogramPeak const & left, CoordinateType right) const
211  {
212  return left.getRT() < right;
213  }
214 
215  inline bool operator()(CoordinateType left, ChromatogramPeak const & right) const
216  {
217  return left < right.getRT();
218  }
219 
220  inline bool operator()(CoordinateType left, CoordinateType right) const
221  {
222  return left < right;
223  }
224 
225  };
226 
229  {
230  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
231  {
232  return left.getPosition() < right.getPosition();
233  }
234 
235  inline bool operator()(const ChromatogramPeak & left, const PositionType & right) const
236  {
237  return left.getPosition() < right;
238  }
239 
240  inline bool operator()(const PositionType & left, const ChromatogramPeak & right) const
241  {
242  return left < right.getPosition();
243  }
244 
245  inline bool operator()(const PositionType & left, const PositionType & right) const
246  {
247  return left < right;
248  }
249  };
251 protected:
256  };
257 
259  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChromatogramPeak & point);
260 
261 } // namespace OpenMS
262 
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:28
ChromatogramPeak & operator=(const ChromatogramPeak &rhs)
Assignment operator.
Definition: ChromatogramPeak.h:145
CoordinateType getMZ() const
Alias for getRT()
Definition: ChromatogramPeak.h:113
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: ChromatogramPeak.h:125
DPosition< 1 > PositionType
Position type.
Definition: ChromatogramPeak.h:39
ChromatogramPeak(const PositionType retention_time, const IntensityType intensity)
Constructor with position and intensity.
Definition: ChromatogramPeak.h:61
double CoordinateType
Coordinate type.
Definition: ChromatogramPeak.h:41
PositionType position_
The data point position.
Definition: ChromatogramPeak.h:253
~ChromatogramPeak()
Destructor.
Definition: ChromatogramPeak.h:74
CoordinateType getPos() const
Alias for getRT()
Definition: ChromatogramPeak.h:101
IntensityType getIntensity() const
Non-mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:84
void setMZ(CoordinateType rt)
Alias for setRT()
Definition: ChromatogramPeak.h:119
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:95
bool operator!=(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:165
bool operator==(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:156
ChromatogramPeak(const ChromatogramPeak &p)
Copy constructor.
Definition: ChromatogramPeak.h:55
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:86
double IntensityType
Intensity type.
Definition: ChromatogramPeak.h:37
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: ChromatogramPeak.h:137
void setPos(CoordinateType pos)
Alias for setRT()
Definition: ChromatogramPeak.h:107
IntensityType intensity_
The data point intensity.
Definition: ChromatogramPeak.h:255
ChromatogramPeak()
Default constructor.
Definition: ChromatogramPeak.h:49
PositionType & getPosition()
Mutable access to the position.
Definition: ChromatogramPeak.h:131
CoordinateType getRT() const
Non-mutable access to RT.
Definition: ChromatogramPeak.h:89
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Comparator by intensity.
Definition: ChromatogramPeak.h:179
bool operator()(ChromatogramPeak const &left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:180
bool operator()(ChromatogramPeak const &left, IntensityType right) const
Definition: ChromatogramPeak.h:185
bool operator()(IntensityType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:190
bool operator()(IntensityType left, IntensityType right) const
Definition: ChromatogramPeak.h:195
Comparator by position. As this class has dimension 1, this is basically an alias for RTLess.
Definition: ChromatogramPeak.h:229
bool operator()(const PositionType &left, const PositionType &right) const
Definition: ChromatogramPeak.h:245
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:230
bool operator()(const PositionType &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:240
bool operator()(const ChromatogramPeak &left, const PositionType &right) const
Definition: ChromatogramPeak.h:235
Comparator by RT position.
Definition: ChromatogramPeak.h:204
bool operator()(CoordinateType left, CoordinateType right) const
Definition: ChromatogramPeak.h:220
bool operator()(ChromatogramPeak const &left, CoordinateType right) const
Definition: ChromatogramPeak.h:210
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:205
bool operator()(CoordinateType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:215