OpenMS
MobilityPeak2D.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: Chris Bielow $
6 // $Authors: Chris Bielow $
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 MobilityPeak2D
29  {
30  public:
33 
35  typedef float IntensityType;
37  typedef double CoordinateType;
41 
44 
47  {
48  IM = 0,
49  MZ = 1,
50  DIMENSION = 2
51  };
52 
54  static char const * shortDimensionName(UInt const dim);
56  static char const * shortDimensionNameIM();
58  static char const * shortDimensionNameMZ();
59 
61  static char const * fullDimensionName(UInt const dim);
63  static char const * fullDimensionNameIM();
65  static char const * fullDimensionNameMZ();
66 
68  static char const * shortDimensionUnit(UInt const dim);
70  static char const * shortDimensionUnitIM();
72  static char const * shortDimensionUnitMZ();
73 
75  static char const * fullDimensionUnit(UInt const dim);
77  static char const * fullDimensionUnitIM();
79  static char const * fullDimensionUnitMZ();
80 
82 
83  protected:
86 
88  static char const * const dimension_name_short_[DIMENSION];
89 
91  static char const * const dimension_name_full_[DIMENSION];
92 
94  static char const * const dimension_unit_short_[DIMENSION];
95 
97  static char const * const dimension_unit_full_[DIMENSION];
98 
100 
101  public:
105  MobilityPeak2D() = default;
106 
108  explicit MobilityPeak2D(const PositionType& pos, const IntensityType in) :
109  position_(pos),
110  intensity_(in)
111  {}
112 
114  MobilityPeak2D(const MobilityPeak2D & p) = default;
115 
117  MobilityPeak2D(MobilityPeak2D&&) noexcept = default;
118 
120  MobilityPeak2D& operator=(const MobilityPeak2D& rhs) = default;
121 
123  MobilityPeak2D& operator=(MobilityPeak2D&&) noexcept = default;
132  ~MobilityPeak2D() noexcept = default;
134 
138  IntensityType getIntensity() const
139  {
140  return intensity_;
141  }
142 
144  void setIntensity(IntensityType intensity)
145  {
146  intensity_ = intensity;
147  }
148 
150  PositionType const & getPosition() const
151  {
152  return position_;
153  }
154 
157  {
158  return position_;
159  }
160 
162  void setPosition(const PositionType & position)
163  {
164  position_ = position;
165  }
166 
169  {
170  return position_[MZ];
171  }
172 
174  void setMZ(CoordinateType coordinate)
175  {
176  position_[MZ] = coordinate;
177  }
178 
181  {
182  return position_[IM];
183  }
184 
186  void setMobility(CoordinateType coordinate)
187  {
188  position_[IM] = coordinate;
189  }
190 
192 
194  bool operator==(const MobilityPeak2D & rhs) const
195  {
196 #pragma clang diagnostic push
197 #pragma clang diagnostic ignored "-Wfloat-equal"
198  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
199 #pragma clang diagnostic pop
200  }
201 
203  bool operator!=(const MobilityPeak2D& rhs) const
204  {
205  return !(operator==(rhs));
206  }
207 
216  {
217  bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
218  {
219  return left.getIntensity() < right.getIntensity();
220  }
221 
222  bool operator()(const MobilityPeak2D & left, IntensityType right) const
223  {
224  return left.getIntensity() < right;
225  }
226 
227  bool operator()(IntensityType left, const MobilityPeak2D & right) const
228  {
229  return left < right.getIntensity();
230  }
231 
232  bool operator()(IntensityType left, IntensityType right) const
233  {
234  return left < right;
235  }
236  };
237 
239  struct IMLess
240  {
241  bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
242  {
243  return left.getMobility() < right.getMobility();
244  }
245 
246  bool operator()(const MobilityPeak2D & left, CoordinateType right) const
247  {
248  return left.getMobility() < right;
249  }
250 
251  bool operator()(CoordinateType left, const MobilityPeak2D & right) const
252  {
253  return left < right.getMobility();
254  }
255 
256  bool operator()(CoordinateType left, CoordinateType right) const
257  {
258  return left < right;
259  }
260  };
261 
263  struct MZLess
264  {
265  bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
266  {
267  return left.getMZ() < right.getMZ();
268  }
269 
270  bool operator()(const MobilityPeak2D & left, CoordinateType right) const
271  {
272  return left.getMZ() < right;
273  }
274 
275  bool operator()(CoordinateType left, const MobilityPeak2D & right) const
276  {
277  return left < right.getMZ();
278  }
279 
280  bool operator()(CoordinateType left, CoordinateType right) const
281  {
282  return left < right;
283  }
284  };
285 
288  {
289  bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
290  {
291  return left.getPosition() < right.getPosition();
292  }
293 
294  bool operator()(const MobilityPeak2D & left, const PositionType & right) const
295  {
296  return left.getPosition() < right;
297  }
298 
299  bool operator()(const PositionType & left, const MobilityPeak2D & right) const
300  {
301  return left < right.getPosition();
302  }
303 
304  bool operator()(const PositionType & left, const PositionType & right) const
305  {
306  return left < right;
307  }
308  };
310 
311  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const MobilityPeak2D & point);
312 
313 protected:
315  PositionType position_{};
317  IntensityType intensity_ {};
318  };
319 
321  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const MobilityPeak2D & point);
322 } // namespace OpenMS
A 2-dimensional raw data point or peak.
Definition: MobilityPeak2D.h:29
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: MobilityPeak2D.h:168
MobilityPeak2D(const PositionType &pos, const IntensityType in)
Member constructor.
Definition: MobilityPeak2D.h:108
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: MobilityPeak2D.h:150
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: MobilityPeak2D.h:174
void setMobility(CoordinateType coordinate)
Mutable access to the IM coordinate (index 0)
Definition: MobilityPeak2D.h:186
float IntensityType
Intensity type.
Definition: MobilityPeak2D.h:35
double CoordinateType
Coordinate type (of the position)
Definition: MobilityPeak2D.h:37
static char const * fullDimensionName(UInt const dim)
Full name of the dimension (self-explanatory form)
PositionType position_
The data point position.
Definition: MobilityPeak2D.h:315
static char const * shortDimensionUnitIM()
Unit of measurement (abbreviated form)
bool operator==(const MobilityPeak2D &rhs) const
Equality operator.
Definition: MobilityPeak2D.h:194
static char const * shortDimensionUnitMZ()
Unit of measurement (abbreviated form)
static char const * shortDimensionNameMZ()
Short name of the dimension (abbreviated form)
IntensityType getIntensity() const
Definition: MobilityPeak2D.h:138
static char const * shortDimensionUnit(UInt const dim)
Unit of measurement (abbreviated form)
friend std::ostream & operator<<(std::ostream &os, const MobilityPeak2D &point)
Print the contents to a stream.
static char const * fullDimensionUnitIM()
Unit of measurement (self-explanatory form)
bool operator!=(const MobilityPeak2D &rhs) const
Equality operator.
Definition: MobilityPeak2D.h:203
void setIntensity(IntensityType intensity)
Sets data point intensity (height)
Definition: MobilityPeak2D.h:144
void setPosition(const PositionType &position)
Mutable access to the position.
Definition: MobilityPeak2D.h:162
CoordinateType getMobility() const
Returns the IM coordinate (index 0)
Definition: MobilityPeak2D.h:180
DimensionDescription
This enum maps the symbolic names of the dimensions to numbers.
Definition: MobilityPeak2D.h:47
MobilityPeak2D(const MobilityPeak2D &p)=default
Copy constructor.
DPosition< 2 > PositionType
Position type.
Definition: MobilityPeak2D.h:39
static char const * fullDimensionNameIM()
Full name of the dimension (self-explanatory form)
static char const * shortDimensionName(UInt const dim)
Short name of the dimension (abbreviated form)
IntensityType intensity_
The data point intensity.
Definition: MobilityPeak2D.h:317
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 * shortDimensionNameIM()
Short name of the dimension (abbreviated form)
MobilityPeak2D(MobilityPeak2D &&) noexcept=default
Move constructor.
PositionType & getPosition()
Mutable access to the position.
Definition: MobilityPeak2D.h:156
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)
Comparator by IM position.
Definition: MobilityPeak2D.h:240
bool operator()(CoordinateType left, CoordinateType right) const
Definition: MobilityPeak2D.h:256
bool operator()(CoordinateType left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:251
bool operator()(const MobilityPeak2D &left, CoordinateType right) const
Definition: MobilityPeak2D.h:246
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:241
Definition: MobilityPeak2D.h:216
bool operator()(const MobilityPeak2D &left, IntensityType right) const
Definition: MobilityPeak2D.h:222
bool operator()(IntensityType left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:227
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:217
bool operator()(IntensityType left, IntensityType right) const
Definition: MobilityPeak2D.h:232
Comparator by m/z position.
Definition: MobilityPeak2D.h:264
bool operator()(CoordinateType left, CoordinateType right) const
Definition: MobilityPeak2D.h:280
bool operator()(CoordinateType left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:275
bool operator()(const MobilityPeak2D &left, CoordinateType right) const
Definition: MobilityPeak2D.h:270
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:265
Comparator by position. Lexicographical comparison (first IM then m/z) is done.
Definition: MobilityPeak2D.h:288
bool operator()(const PositionType &left, const PositionType &right) const
Definition: MobilityPeak2D.h:304
bool operator()(const MobilityPeak2D &left, const PositionType &right) const
Definition: MobilityPeak2D.h:294
bool operator()(const PositionType &left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:299
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:289