OpenMS
Loading...
Searching...
No Matches
MobilityPeak2D.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: Chris Bielow $
6// $Authors: Chris Bielow $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14
15#include <iosfwd>
16#include <functional>
17
18namespace OpenMS
19{
20
29 class OPENMS_DLLAPI MobilityPeak2D
30 {
31 public:
34
36 typedef float IntensityType;
38 typedef double CoordinateType;
42
45
48 {
49 IM = 0,
50 MZ = 1,
51 DIMENSION = 2
52 };
53
55 static char const * shortDimensionName(UInt const dim);
57 static char const * shortDimensionNameIM();
59 static char const * shortDimensionNameMZ();
60
62 static char const * fullDimensionName(UInt const dim);
64 static char const * fullDimensionNameIM();
66 static char const * fullDimensionNameMZ();
67
69 static char const * shortDimensionUnit(UInt const dim);
71 static char const * shortDimensionUnitIM();
73 static char const * shortDimensionUnitMZ();
74
76 static char const * fullDimensionUnit(UInt const dim);
78 static char const * fullDimensionUnitIM();
80 static char const * fullDimensionUnitMZ();
81
83
84 protected:
87
89 static char const * const dimension_name_short_[DIMENSION];
90
92 static char const * const dimension_name_full_[DIMENSION];
93
95 static char const * const dimension_unit_short_[DIMENSION];
96
98 static char const * const dimension_unit_full_[DIMENSION];
99
101
102 public:
106 MobilityPeak2D() = default;
107
109 explicit MobilityPeak2D(const PositionType& pos, const IntensityType in) :
110 position_(pos),
111 intensity_(in)
112 {}
113
115 MobilityPeak2D(const MobilityPeak2D & p) = default;
116
118 MobilityPeak2D(MobilityPeak2D&&) noexcept = default;
119
121 MobilityPeak2D& operator=(const MobilityPeak2D& rhs) = default;
122
124 MobilityPeak2D& operator=(MobilityPeak2D&&) noexcept = default;
133 ~MobilityPeak2D() noexcept = default;
135
139 IntensityType getIntensity() const
140 {
141 return intensity_;
142 }
143
146 {
147 intensity_ = intensity;
148 }
149
151 PositionType const & getPosition() const
152 {
153 return position_;
154 }
155
158 {
159 return position_;
160 }
161
163 void setPosition(const PositionType & position)
164 {
165 position_ = position;
166 }
167
170 {
171 return position_[MZ];
172 }
173
175 void setMZ(CoordinateType coordinate)
176 {
177 position_[MZ] = coordinate;
178 }
179
182 {
183 return position_[IM];
184 }
185
188 {
189 position_[IM] = coordinate;
190 }
191
193
195 bool operator==(const MobilityPeak2D & rhs) const
196 {
197 return std::tie(intensity_, position_) == std::tie(rhs.intensity_, rhs.position_);
198 }
199
201 bool operator!=(const MobilityPeak2D& rhs) const
202 {
203 return !(operator==(rhs));
204 }
205
214 {
215 bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
216 {
217 return left.getIntensity() < right.getIntensity();
218 }
219
220 bool operator()(const MobilityPeak2D & left, IntensityType right) const
221 {
222 return left.getIntensity() < right;
223 }
224
225 bool operator()(IntensityType left, const MobilityPeak2D & right) const
226 {
227 return left < right.getIntensity();
228 }
229
230 bool operator()(IntensityType left, IntensityType right) const
231 {
232 return left < right;
233 }
234 };
235
237 struct IMLess
238 {
239 bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
240 {
241 return left.getMobility() < right.getMobility();
242 }
243
244 bool operator()(const MobilityPeak2D & left, CoordinateType right) const
245 {
246 return left.getMobility() < right;
247 }
248
249 bool operator()(CoordinateType left, const MobilityPeak2D & right) const
250 {
251 return left < right.getMobility();
252 }
253
255 {
256 return left < right;
257 }
258 };
259
261 struct MZLess
262 {
263 bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
264 {
265 return left.getMZ() < right.getMZ();
266 }
267
268 bool operator()(const MobilityPeak2D & left, CoordinateType right) const
269 {
270 return left.getMZ() < right;
271 }
272
273 bool operator()(CoordinateType left, const MobilityPeak2D & right) const
274 {
275 return left < right.getMZ();
276 }
277
279 {
280 return left < right;
281 }
282 };
283
286 {
287 bool operator()(const MobilityPeak2D & left, const MobilityPeak2D & right) const
288 {
289 return left.getPosition() < right.getPosition();
290 }
291
292 bool operator()(const MobilityPeak2D & left, const PositionType & right) const
293 {
294 return left.getPosition() < right;
295 }
296
297 bool operator()(const PositionType & left, const MobilityPeak2D & right) const
298 {
299 return left < right.getPosition();
300 }
301
302 bool operator()(const PositionType & left, const PositionType & right) const
303 {
304 return left < right;
305 }
306 };
308
309 friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const MobilityPeak2D & point);
310
311protected:
313 PositionType position_{};
315 IntensityType intensity_ {};
316 };
317
319 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const MobilityPeak2D & point);
320} // namespace OpenMS
321
322// Hash function specialization for MobilityPeak2D
323namespace std
324{
325 template<>
326 struct hash<OpenMS::MobilityPeak2D>
327 {
328 std::size_t operator()(const OpenMS::MobilityPeak2D& p) const noexcept
329 {
330 std::size_t seed = OpenMS::hash_float(p.getMobility());
332 OpenMS::hash_combine(seed, OpenMS::hash_float(p.getIntensity()));
333 return seed;
334 }
335 };
336} // namespace std
Representation of a coordinate in D-dimensional space.
Definition DPosition.h:32
A 2-dimensional raw data point or peak.
Definition MobilityPeak2D.h:30
friend std::ostream & operator<<(std::ostream &os, const MobilityPeak2D &point)
Print the contents to a stream.
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition MobilityPeak2D.h:169
MobilityPeak2D(const PositionType &pos, const IntensityType in)
Member constructor.
Definition MobilityPeak2D.h:109
static char const * fullDimensionUnitIM()
Unit of measurement (self-explanatory form)
static char const * shortDimensionNameMZ()
Short name of the dimension (abbreviated form)
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition MobilityPeak2D.h:175
void setMobility(CoordinateType coordinate)
Mutable access to the IM coordinate (index 0)
Definition MobilityPeak2D.h:187
static char const * fullDimensionNameMZ()
Full name of the dimension (self-explanatory form)
PositionType const & getPosition() const
Non-mutable access to the position.
Definition MobilityPeak2D.h:151
float IntensityType
Intensity type.
Definition MobilityPeak2D.h:36
double CoordinateType
Coordinate type (of the position)
Definition MobilityPeak2D.h:38
static char const * fullDimensionUnit(UInt const dim)
Unit of measurement (self-explanatory form)
PositionType position_
The data point position.
Definition MobilityPeak2D.h:313
static char const * shortDimensionUnit(UInt const dim)
Unit of measurement (abbreviated form)
bool operator==(const MobilityPeak2D &rhs) const
Equality operator.
Definition MobilityPeak2D.h:195
static char const * fullDimensionName(UInt const dim)
Full name of the dimension (self-explanatory form)
static char const * fullDimensionNameIM()
Full name of the dimension (self-explanatory form)
IntensityType getIntensity() const
Definition MobilityPeak2D.h:139
static char const * fullDimensionUnitMZ()
Unit of measurement (self-explanatory form)
static char const * shortDimensionUnitIM()
Unit of measurement (abbreviated form)
bool operator!=(const MobilityPeak2D &rhs) const
Equality operator.
Definition MobilityPeak2D.h:201
void setIntensity(IntensityType intensity)
Sets data point intensity (height)
Definition MobilityPeak2D.h:145
static char const * shortDimensionUnitMZ()
Unit of measurement (abbreviated form)
PositionType & getPosition()
Mutable access to the position.
Definition MobilityPeak2D.h:157
void setPosition(const PositionType &position)
Mutable access to the position.
Definition MobilityPeak2D.h:163
CoordinateType getMobility() const
Returns the IM coordinate (index 0)
Definition MobilityPeak2D.h:181
DimensionDescription
This enum maps the symbolic names of the dimensions to numbers.
Definition MobilityPeak2D.h:48
MobilityPeak2D(const MobilityPeak2D &p)=default
Copy constructor.
DPosition< 2 > PositionType
Position type.
Definition MobilityPeak2D.h:40
IntensityType intensity_
The data point intensity.
Definition MobilityPeak2D.h:315
static char const * shortDimensionNameIM()
Short name of the dimension (abbreviated form)
static char const * shortDimensionName(UInt const dim)
Short name of the dimension (abbreviated form)
MobilityPeak2D(MobilityPeak2D &&) noexcept=default
Move 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)
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t hash_float(T value) noexcept
Hash for a floating point type (float or double).
Definition HashUtils.h:142
STL namespace.
Comparator by IM position.
Definition MobilityPeak2D.h:238
bool operator()(CoordinateType left, CoordinateType right) const
Definition MobilityPeak2D.h:254
bool operator()(CoordinateType left, const MobilityPeak2D &right) const
Definition MobilityPeak2D.h:249
bool operator()(const MobilityPeak2D &left, CoordinateType right) const
Definition MobilityPeak2D.h:244
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition MobilityPeak2D.h:239
Definition MobilityPeak2D.h:214
bool operator()(const MobilityPeak2D &left, IntensityType right) const
Definition MobilityPeak2D.h:220
bool operator()(IntensityType left, const MobilityPeak2D &right) const
Definition MobilityPeak2D.h:225
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition MobilityPeak2D.h:215
bool operator()(IntensityType left, IntensityType right) const
Definition MobilityPeak2D.h:230
Comparator by m/z position.
Definition MobilityPeak2D.h:262
bool operator()(CoordinateType left, CoordinateType right) const
Definition MobilityPeak2D.h:278
bool operator()(CoordinateType left, const MobilityPeak2D &right) const
Definition MobilityPeak2D.h:273
bool operator()(const MobilityPeak2D &left, CoordinateType right) const
Definition MobilityPeak2D.h:268
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition MobilityPeak2D.h:263
Comparator by position. Lexicographical comparison (first IM then m/z) is done.
Definition MobilityPeak2D.h:286
bool operator()(const PositionType &left, const PositionType &right) const
Definition MobilityPeak2D.h:302
bool operator()(const MobilityPeak2D &left, const PositionType &right) const
Definition MobilityPeak2D.h:292
bool operator()(const PositionType &left, const MobilityPeak2D &right) const
Definition MobilityPeak2D.h:297
bool operator()(const MobilityPeak2D &left, const MobilityPeak2D &right) const
Definition MobilityPeak2D.h:287
std::size_t operator()(const OpenMS::MobilityPeak2D &p) const noexcept
Definition MobilityPeak2D.h:328