OpenMS
MobilityPeak2D.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-2023.
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: Chris Bielow $
32 // $Authors: Chris Bielow $
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 
54  class OPENMS_DLLAPI MobilityPeak2D
55  {
56  public:
59 
61  typedef float IntensityType;
63  typedef double CoordinateType;
67 
70 
73  {
74  IM = 0,
75  MZ = 1,
76  DIMENSION = 2
77  };
78 
80  static char const * shortDimensionName(UInt const dim);
82  static char const * shortDimensionNameIM();
84  static char const * shortDimensionNameMZ();
85 
87  static char const * fullDimensionName(UInt const dim);
89  static char const * fullDimensionNameIM();
91  static char const * fullDimensionNameMZ();
92 
94  static char const * shortDimensionUnit(UInt const dim);
96  static char const * shortDimensionUnitIM();
98  static char const * shortDimensionUnitMZ();
99 
101  static char const * fullDimensionUnit(UInt const dim);
103  static char const * fullDimensionUnitIM();
105  static char const * fullDimensionUnitMZ();
106 
108 
109  protected:
112 
114  static char const * const dimension_name_short_[DIMENSION];
115 
117  static char const * const dimension_name_full_[DIMENSION];
118 
120  static char const * const dimension_unit_short_[DIMENSION];
121 
123  static char const * const dimension_unit_full_[DIMENSION];
124 
126 
127  public:
131  MobilityPeak2D() = default;
132 
134  explicit MobilityPeak2D(const PositionType& pos, const IntensityType in) :
135  position_(pos),
136  intensity_(in)
137  {}
138 
140  MobilityPeak2D(const MobilityPeak2D & p) = default;
141 
143  MobilityPeak2D(MobilityPeak2D&&) noexcept = default;
144 
146  MobilityPeak2D& operator=(const MobilityPeak2D& rhs) = default;
147 
149  MobilityPeak2D& operator=(MobilityPeak2D&&) noexcept = default;
158  ~MobilityPeak2D() noexcept = default;
160 
164  IntensityType getIntensity() const
165  {
166  return intensity_;
167  }
168 
170  void setIntensity(IntensityType intensity)
171  {
172  intensity_ = intensity;
173  }
174 
176  PositionType const & getPosition() const
177  {
178  return position_;
179  }
180 
183  {
184  return position_;
185  }
186 
188  void setPosition(const PositionType & position)
189  {
190  position_ = position;
191  }
192 
195  {
196  return position_[MZ];
197  }
198 
200  void setMZ(CoordinateType coordinate)
201  {
202  position_[MZ] = coordinate;
203  }
204 
207  {
208  return position_[IM];
209  }
210 
212  void setMobility(CoordinateType coordinate)
213  {
214  position_[IM] = coordinate;
215  }
216 
218 
220  bool operator==(const MobilityPeak2D & rhs) const
221  {
222 #pragma clang diagnostic push
223 #pragma clang diagnostic ignored "-Wfloat-equal"
224  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
225 #pragma clang diagnostic pop
226  }
227 
229  bool operator!=(const MobilityPeak2D& rhs) const
230  {
231  return !(operator==(rhs));
232  }
233 
242  {
243  bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
244  {
245  return left.getIntensity() < right.getIntensity();
246  }
247 
248  bool operator()(const MobilityPeak2D & left, IntensityType right) const
249  {
250  return left.getIntensity() < right;
251  }
252 
253  bool operator()(IntensityType left, const MobilityPeak2D & right) const
254  {
255  return left < right.getIntensity();
256  }
257 
258  bool operator()(IntensityType left, IntensityType right) const
259  {
260  return left < right;
261  }
262  };
263 
265  struct IMLess
266  {
267  bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
268  {
269  return left.getMobility() < right.getMobility();
270  }
271 
272  bool operator()(const MobilityPeak2D & left, CoordinateType right) const
273  {
274  return left.getMobility() < right;
275  }
276 
277  bool operator()(CoordinateType left, const MobilityPeak2D & right) const
278  {
279  return left < right.getMobility();
280  }
281 
282  bool operator()(CoordinateType left, CoordinateType right) const
283  {
284  return left < right;
285  }
286  };
287 
289  struct MZLess
290  {
291  bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
292  {
293  return left.getMZ() < right.getMZ();
294  }
295 
296  bool operator()(const MobilityPeak2D & left, CoordinateType right) const
297  {
298  return left.getMZ() < right;
299  }
300 
301  bool operator()(CoordinateType left, const MobilityPeak2D & right) const
302  {
303  return left < right.getMZ();
304  }
305 
306  bool operator()(CoordinateType left, CoordinateType right) const
307  {
308  return left < right;
309  }
310  };
311 
314  {
315  bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
316  {
317  return left.getPosition() < right.getPosition();
318  }
319 
320  bool operator()(const MobilityPeak2D & left, const PositionType & right) const
321  {
322  return left.getPosition() < right;
323  }
324 
325  bool operator()(const PositionType & left, const MobilityPeak2D & right) const
326  {
327  return left < right.getPosition();
328  }
329 
330  bool operator()(const PositionType & left, const PositionType & right) const
331  {
332  return left < right;
333  }
334  };
336 
337  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const MobilityPeak2D & point);
338 
339 protected:
341  PositionType position_{};
343  IntensityType intensity_ {};
344  };
345 
347  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const MobilityPeak2D & point);
348 } // namespace OpenMS
A 2-dimensional raw data point or peak.
Definition: MobilityPeak2D.h:55
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: MobilityPeak2D.h:194
MobilityPeak2D(const PositionType &pos, const IntensityType in)
Member constructor.
Definition: MobilityPeak2D.h:134
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: MobilityPeak2D.h:176
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: MobilityPeak2D.h:200
void setMobility(CoordinateType coordinate)
Mutable access to the IM coordinate (index 0)
Definition: MobilityPeak2D.h:212
float IntensityType
Intensity type.
Definition: MobilityPeak2D.h:61
double CoordinateType
Coordinate type (of the position)
Definition: MobilityPeak2D.h:63
static char const * fullDimensionName(UInt const dim)
Full name of the dimension (self-explanatory form)
PositionType position_
The data point position.
Definition: MobilityPeak2D.h:341
static char const * shortDimensionUnitIM()
Unit of measurement (abbreviated form)
bool operator==(const MobilityPeak2D &rhs) const
Equality operator.
Definition: MobilityPeak2D.h:220
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:164
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:229
void setIntensity(IntensityType intensity)
Sets data point intensity (height)
Definition: MobilityPeak2D.h:170
void setPosition(const PositionType &position)
Mutable access to the position.
Definition: MobilityPeak2D.h:188
CoordinateType getMobility() const
Returns the IM coordinate (index 0)
Definition: MobilityPeak2D.h:206
DimensionDescription
This enum maps the symbolic names of the dimensions to numbers.
Definition: MobilityPeak2D.h:73
MobilityPeak2D(const MobilityPeak2D &p)=default
Copy constructor.
DPosition< 2 > PositionType
Position type.
Definition: MobilityPeak2D.h:65
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:343
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:182
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Comparator by IM position.
Definition: MobilityPeak2D.h:266
bool operator()(CoordinateType left, CoordinateType right) const
Definition: MobilityPeak2D.h:282
bool operator()(CoordinateType left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:277
bool operator()(const MobilityPeak2D &left, CoordinateType right) const
Definition: MobilityPeak2D.h:272
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:267
Definition: MobilityPeak2D.h:242
bool operator()(const MobilityPeak2D &left, IntensityType right) const
Definition: MobilityPeak2D.h:248
bool operator()(IntensityType left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:253
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:243
bool operator()(IntensityType left, IntensityType right) const
Definition: MobilityPeak2D.h:258
Comparator by m/z position.
Definition: MobilityPeak2D.h:290
bool operator()(CoordinateType left, CoordinateType right) const
Definition: MobilityPeak2D.h:306
bool operator()(CoordinateType left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:301
bool operator()(const MobilityPeak2D &left, CoordinateType right) const
Definition: MobilityPeak2D.h:296
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:291
Comparator by position. Lexicographical comparison (first IM then m/z) is done.
Definition: MobilityPeak2D.h:314
bool operator()(const PositionType &left, const PositionType &right) const
Definition: MobilityPeak2D.h:330
bool operator()(const MobilityPeak2D &left, const PositionType &right) const
Definition: MobilityPeak2D.h:320
bool operator()(const PositionType &left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:325
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition: MobilityPeak2D.h:315