OpenMS  2.8.0
Peak2D.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-2021.
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: Timo Sachsenberg$
32 // $Authors: Marc Sturm $
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 Peak2D
55  {
56 public:
57 
60 
62  typedef float IntensityType;
64  typedef double CoordinateType;
68 
71 
74  {
75  RT = 0,
76  MZ = 1,
77  DIMENSION = 2
78  };
79 
81  static char const * shortDimensionName(UInt const dim);
83  static char const * shortDimensionNameRT();
85  static char const * shortDimensionNameMZ();
86 
88  static char const * fullDimensionName(UInt const dim);
90  static char const * fullDimensionNameRT();
92  static char const * fullDimensionNameMZ();
93 
95  static char const * shortDimensionUnit(UInt const dim);
97  static char const * shortDimensionUnitRT();
99  static char const * shortDimensionUnitMZ();
100 
102  static char const * fullDimensionUnit(UInt const dim);
104  static char const * fullDimensionUnitRT();
106  static char const * fullDimensionUnitMZ();
107 
109 
110 protected:
111 
114 
116  static char const * const dimension_name_short_[DIMENSION];
117 
119  static char const * const dimension_name_full_[DIMENSION];
120 
122  static char const * const dimension_unit_short_[DIMENSION];
123 
125  static char const * const dimension_unit_full_[DIMENSION];
126 
128 
129 public:
130 
134  Peak2D() :
135  position_(),
136  intensity_(0)
137  {}
138 
140  explicit Peak2D(const PositionType& pos, const IntensityType in) :
141  position_(pos),
142  intensity_(in)
143  {}
144 
146  Peak2D(const Peak2D & p) = default;
147 
149  Peak2D(Peak2D&&) = default;
150 
160  {}
162 
167  {
168  return intensity_;
169  }
170 
172  void setIntensity(IntensityType intensity)
173  {
174  intensity_ = intensity;
175  }
176 
178  PositionType const & getPosition() const
179  {
180  return position_;
181  }
182 
185  {
186  return position_;
187  }
188 
190  void setPosition(const PositionType & position)
191  {
192  position_ = position;
193  }
194 
197  {
198  return position_[MZ];
199  }
200 
202  void setMZ(CoordinateType coordinate)
203  {
204  position_[MZ] = coordinate;
205  }
206 
209  {
210  return position_[RT];
211  }
212 
214  void setRT(CoordinateType coordinate)
215  {
216  position_[RT] = coordinate;
217  }
218 
220 
222  Peak2D & operator=(const Peak2D & rhs) = default;
223 
225  Peak2D& operator=(Peak2D&&) & = default;
226 
228  bool operator==(const Peak2D & rhs) const
229  {
230 #pragma clang diagnostic push
231 #pragma clang diagnostic ignored "-Wfloat-equal"
232  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
233 #pragma clang diagnostic pop
234  }
235 
237  bool operator!=(const Peak2D & rhs) const
238  {
239  return !(operator==(rhs));
240  }
241 
250  {
251  bool operator()(const Peak2D & left, const Peak2D & right) const
252  {
253  return left.getIntensity() < right.getIntensity();
254  }
255 
256  bool operator()(const Peak2D & left, IntensityType right) const
257  {
258  return left.getIntensity() < right;
259  }
260 
261  bool operator()(IntensityType left, const Peak2D & right) const
262  {
263  return left < right.getIntensity();
264  }
265 
266  bool operator()(IntensityType left, IntensityType right) const
267  {
268  return left < right;
269  }
270 
271  };
272 
274  struct RTLess
275  {
276  bool operator()(const Peak2D & left, const Peak2D & right) const
277  {
278  return left.getRT() < right.getRT();
279  }
280 
281  bool operator()(const Peak2D & left, CoordinateType right) const
282  {
283  return left.getRT() < right;
284  }
285 
286  bool operator()(CoordinateType left, const Peak2D & right) const
287  {
288  return left < right.getRT();
289  }
290 
291  bool operator()(CoordinateType left, CoordinateType right) const
292  {
293  return left < right;
294  }
295 
296  };
297 
299  struct MZLess
300  {
301  bool operator()(const Peak2D & left, const Peak2D & right) const
302  {
303  return left.getMZ() < right.getMZ();
304  }
305 
306  bool operator()(const Peak2D & left, CoordinateType right) const
307  {
308  return left.getMZ() < right;
309  }
310 
311  bool operator()(CoordinateType left, const Peak2D & right) const
312  {
313  return left < right.getMZ();
314  }
315 
316  bool operator()(CoordinateType left, CoordinateType right) const
317  {
318  return left < right;
319  }
320 
321  };
322 
325  {
326  bool operator()(const Peak2D & left, const Peak2D & right) const
327  {
328  return left.getPosition() < right.getPosition();
329  }
330 
331  bool operator()(const Peak2D & left, const PositionType & right) const
332  {
333  return left.getPosition() < right;
334  }
335 
336  bool operator()(const PositionType & left, const Peak2D & right) const
337  {
338  return left < right.getPosition();
339  }
340 
341  bool operator()(const PositionType & left, const PositionType & right) const
342  {
343  return left < right;
344  }
345 
346  };
348 
349  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
350 
351 protected:
352 
357  };
358 
360  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
361 
362 } // namespace OpenMS
363 
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: Peak2D.h:196
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak2D.h:178
Peak2D & operator=(const Peak2D &rhs)=default
Assignment operator.
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: Peak2D.h:202
Peak2D(const PositionType &pos, const IntensityType in)
Member constructor.
Definition: Peak2D.h:140
float IntensityType
Intensity type.
Definition: Peak2D.h:62
double CoordinateType
Coordinate type (of the position)
Definition: Peak2D.h:64
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition: Peak2D.h:214
bool operator==(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:228
static char const * fullDimensionName(UInt const dim)
Full name of the dimension (self-explanatory form)
PositionType position_
The data point position.
Definition: Peak2D.h:354
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:166
Peak2D & operator=(Peak2D &&) &=default
Move assignment operator.
Peak2D(Peak2D &&)=default
Move constructor.
static char const * shortDimensionUnit(UInt const dim)
Unit of measurement (abbreviated form)
void setIntensity(IntensityType intensity)
Sets data point intensity (height)
Definition: Peak2D.h:172
void setPosition(const PositionType &position)
Mutable access to the position.
Definition: Peak2D.h:190
DimensionDescription
This enum maps the symbolic names of the dimensions to numbers.
Definition: Peak2D.h:74
friend std::ostream & operator<<(std::ostream &os, const Peak2D &point)
Print the contents to a stream.
DPosition< 2 > PositionType
Position type.
Definition: Peak2D.h:66
bool operator!=(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:237
static char const * shortDimensionName(UInt const dim)
Short name of the dimension (abbreviated form)
IntensityType intensity_
The data point intensity.
Definition: Peak2D.h:356
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:184
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:208
~Peak2D()
Destructor.
Definition: Peak2D.h:159
Peak2D(const Peak2D &p)=default
Copy constructor.
Peak2D()
Definition: Peak2D.h:134
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:47
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Definition: Peak2D.h:250
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:251
bool operator()(const Peak2D &left, IntensityType right) const
Definition: Peak2D.h:256
bool operator()(IntensityType left, const Peak2D &right) const
Definition: Peak2D.h:261
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak2D.h:266
Comparator by m/z position.
Definition: Peak2D.h:300
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:316
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:301
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:311
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:306
Comparator by position. Lexicographical comparison (first RT then m/z) is done.
Definition: Peak2D.h:325
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak2D.h:341
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:326
bool operator()(const Peak2D &left, const PositionType &right) const
Definition: Peak2D.h:331
bool operator()(const PositionType &left, const Peak2D &right) const
Definition: Peak2D.h:336
Comparator by RT position.
Definition: Peak2D.h:275
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:291
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:276
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:286
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:281