OpenMS
Peak2D.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg$
6 // $Authors: Marc Sturm $
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 
28  class OPENMS_DLLAPI Peak2D
29  {
30 public:
31 
34 
36  typedef float IntensityType;
38  typedef double CoordinateType;
42 
45 
48  {
49  RT = 0,
50  MZ = 1,
51  DIMENSION = 2
52  };
53 
55  static char const * shortDimensionName(UInt const dim);
57  static char const * shortDimensionNameRT();
59  static char const * shortDimensionNameMZ();
60 
62  static char const * fullDimensionName(UInt const dim);
64  static char const * fullDimensionNameRT();
66  static char const * fullDimensionNameMZ();
67 
69  static char const * shortDimensionUnit(UInt const dim);
71  static char const * shortDimensionUnitRT();
73  static char const * shortDimensionUnitMZ();
74 
76  static char const * fullDimensionUnit(UInt const dim);
78  static char const * fullDimensionUnitRT();
80  static char const * fullDimensionUnitMZ();
81 
83 
84 protected:
85 
88 
90  static char const * const dimension_name_short_[DIMENSION];
91 
93  static char const * const dimension_name_full_[DIMENSION];
94 
96  static char const * const dimension_unit_short_[DIMENSION];
97 
99  static char const * const dimension_unit_full_[DIMENSION];
100 
102 
103 public:
104 
108  Peak2D() = default;
109 
111  explicit Peak2D(const PositionType& pos, const IntensityType in) :
112  position_(pos),
113  intensity_(in)
114  {}
115 
117  Peak2D(const Peak2D & p) = default;
118 
120  Peak2D(Peak2D&&) noexcept = default;
121 
123  Peak2D& operator=(const Peak2D& rhs) = default;
124 
126  Peak2D& operator=(Peak2D&&) noexcept = default;
135  ~Peak2D() noexcept = default;
136 
138 
142  IntensityType getIntensity() const
143  {
144  return intensity_;
145  }
146 
148  void setIntensity(IntensityType intensity)
149  {
150  intensity_ = intensity;
151  }
152 
154  PositionType const & getPosition() const
155  {
156  return position_;
157  }
158 
161  {
162  return position_;
163  }
164 
166  void setPosition(const PositionType & position)
167  {
168  position_ = position;
169  }
170 
173  {
174  return position_[MZ];
175  }
176 
178  void setMZ(CoordinateType coordinate)
179  {
180  position_[MZ] = coordinate;
181  }
182 
185  {
186  return position_[RT];
187  }
188 
190  void setRT(CoordinateType coordinate)
191  {
192  position_[RT] = coordinate;
193  }
194 
196 
198  bool operator==(const Peak2D & rhs) const
199  {
200 #pragma clang diagnostic push
201 #pragma clang diagnostic ignored "-Wfloat-equal"
202  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
203 #pragma clang diagnostic pop
204  }
205 
207  bool operator!=(const Peak2D & rhs) const
208  {
209  return !(operator==(rhs));
210  }
211 
220  {
221  bool operator()(const Peak2D & left, const Peak2D & right) const
222  {
223  return left.getIntensity() < right.getIntensity();
224  }
225 
226  bool operator()(const Peak2D & left, IntensityType right) const
227  {
228  return left.getIntensity() < right;
229  }
230 
231  bool operator()(IntensityType left, const Peak2D & right) const
232  {
233  return left < right.getIntensity();
234  }
235 
236  bool operator()(IntensityType left, IntensityType right) const
237  {
238  return left < right;
239  }
240 
241  };
242 
244  struct RTLess
245  {
246  bool operator()(const Peak2D & left, const Peak2D & right) const
247  {
248  return left.getRT() < right.getRT();
249  }
250 
251  bool operator()(const Peak2D & left, CoordinateType right) const
252  {
253  return left.getRT() < right;
254  }
255 
256  bool operator()(CoordinateType left, const Peak2D & right) const
257  {
258  return left < right.getRT();
259  }
260 
261  bool operator()(CoordinateType left, CoordinateType right) const
262  {
263  return left < right;
264  }
265 
266  };
267 
269  struct MZLess
270  {
271  bool operator()(const Peak2D & left, const Peak2D & right) const
272  {
273  return left.getMZ() < right.getMZ();
274  }
275 
276  bool operator()(const Peak2D & left, CoordinateType right) const
277  {
278  return left.getMZ() < right;
279  }
280 
281  bool operator()(CoordinateType left, const Peak2D & right) const
282  {
283  return left < right.getMZ();
284  }
285 
286  bool operator()(CoordinateType left, CoordinateType right) const
287  {
288  return left < right;
289  }
290 
291  };
292 
295  {
296  bool operator()(const Peak2D & left, const Peak2D & right) const
297  {
298  return left.getPosition() < right.getPosition();
299  }
300 
301  bool operator()(const Peak2D & left, const PositionType & right) const
302  {
303  return left.getPosition() < right;
304  }
305 
306  bool operator()(const PositionType & left, const Peak2D & right) const
307  {
308  return left < right.getPosition();
309  }
310 
311  bool operator()(const PositionType & left, const PositionType & right) const
312  {
313  return left < right;
314  }
315 
316  };
318 
319  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
320 
321 protected:
322 
324  PositionType position_{};
326  IntensityType intensity_{};
327  };
328 
330  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
331 
332 } // namespace OpenMS
333 
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:29
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: Peak2D.h:172
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak2D.h:154
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: Peak2D.h:178
Peak2D(Peak2D &&) noexcept=default
Move constructor.
Peak2D(const PositionType &pos, const IntensityType in)
Member constructor.
Definition: Peak2D.h:111
float IntensityType
Intensity type.
Definition: Peak2D.h:36
double CoordinateType
Coordinate type (of the position)
Definition: Peak2D.h:38
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition: Peak2D.h:190
bool operator==(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:198
static char const * fullDimensionName(UInt const dim)
Full name of the dimension (self-explanatory form)
PositionType position_
The data point position.
Definition: Peak2D.h:324
static char const * shortDimensionUnitRT()
Unit of measurement (abbreviated form)
static char const * fullDimensionUnitRT()
Unit of measurement (self-explanatory form)
static char const * shortDimensionUnitMZ()
Unit of measurement (abbreviated form)
static char const * shortDimensionNameMZ()
Short name of the dimension (abbreviated form)
static char const * fullDimensionNameRT()
Full name of the dimension (self-explanatory form)
IntensityType getIntensity() const
Definition: Peak2D.h:142
static char const * shortDimensionUnit(UInt const dim)
Unit of measurement (abbreviated form)
void setIntensity(IntensityType intensity)
Sets data point intensity (height)
Definition: Peak2D.h:148
void setPosition(const PositionType &position)
Mutable access to the position.
Definition: Peak2D.h:166
DimensionDescription
This enum maps the symbolic names of the dimensions to numbers.
Definition: Peak2D.h:48
friend std::ostream & operator<<(std::ostream &os, const Peak2D &point)
Print the contents to a stream.
Peak2D()=default
DPosition< 2 > PositionType
Position type.
Definition: Peak2D.h:40
bool operator!=(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:207
static char const * shortDimensionName(UInt const dim)
Short name of the dimension (abbreviated form)
IntensityType intensity_
The data point intensity.
Definition: Peak2D.h:326
static char const * fullDimensionUnit(UInt const dim)
Unit of measurement (self-explanatory form)
static char const * fullDimensionNameMZ()
Full name of the dimension (self-explanatory form)
static char const * fullDimensionUnitMZ()
Unit of measurement (self-explanatory form)
static char const * shortDimensionNameRT()
Short name of the dimension (abbreviated form)
PositionType & getPosition()
Mutable access to the position.
Definition: Peak2D.h:160
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:184
Peak2D(const Peak2D &p)=default
Copy constructor.
unsigned int UInt
Unsigned integer type.
Definition: Types.h:64
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)
@ RT
RT in seconds.
Definition: Peak2D.h:220
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:221
bool operator()(const Peak2D &left, IntensityType right) const
Definition: Peak2D.h:226
bool operator()(IntensityType left, const Peak2D &right) const
Definition: Peak2D.h:231
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak2D.h:236
Comparator by m/z position.
Definition: Peak2D.h:270
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:286
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:271
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:281
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:276
Comparator by position. Lexicographical comparison (first RT then m/z) is done.
Definition: Peak2D.h:295
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak2D.h:311
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:296
bool operator()(const Peak2D &left, const PositionType &right) const
Definition: Peak2D.h:301
bool operator()(const PositionType &left, const Peak2D &right) const
Definition: Peak2D.h:306
Comparator by RT position.
Definition: Peak2D.h:245
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:261
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:246
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:256
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:251