OpenMS
ChromatogramPeak.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: Andreas Bertsch $
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 
27  class OPENMS_DLLAPI ChromatogramPeak
28  {
29 public:
35  enum {DIMENSION = 1};
37  typedef double IntensityType;
41  typedef double CoordinateType;
43 
49  inline ChromatogramPeak() :
50  position_(),
51  intensity_(0)
52  {}
53 
55  inline ChromatogramPeak(const ChromatogramPeak & p) :
56  position_(p.position_),
57  intensity_(p.intensity_)
58  {}
59 
61  inline ChromatogramPeak(const PositionType retention_time, const IntensityType intensity) :
62  position_(retention_time),
63  intensity_(intensity)
64  {}
65 
75  {}
77 
82 
84  inline IntensityType getIntensity() const { return intensity_; }
86  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
87 
89  inline CoordinateType getRT() const
90  {
91  return position_[0];
92  }
93 
95  inline void setRT(CoordinateType rt)
96  {
97  position_[0] = rt;
98  }
99 
101  inline CoordinateType getPos() const
102  {
103  return position_[0];
104  }
105 
107  inline void setPos(CoordinateType pos)
108  {
109  position_[0] = pos;
110  }
111 
113  inline PositionType const & getPosition() const
114  {
115  return position_;
116  }
117 
120  {
121  return position_;
122  }
123 
125  inline void setPosition(PositionType const & position)
126  {
127  position_ = position;
128  }
129 
131 
134  {
135  if (this == &rhs) return *this;
136 
137  intensity_ = rhs.intensity_;
138  position_ = rhs.position_;
139 
140  return *this;
141  }
142 
144  inline bool operator==(const ChromatogramPeak & rhs) const
145  {
146 #pragma clang diagnostic push
147 #pragma clang diagnostic ignored "-Wfloat-equal"
148  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
149 #pragma clang diagnostic pop
150  }
151 
153  inline bool operator!=(const ChromatogramPeak & rhs) const
154  {
155  return !(operator==(rhs));
156  }
157 
167  {
168  inline bool operator()(ChromatogramPeak const & left, ChromatogramPeak const & right) const
169  {
170  return left.getIntensity() < right.getIntensity();
171  }
172 
173  inline bool operator()(ChromatogramPeak const & left, IntensityType right) const
174  {
175  return left.getIntensity() < right;
176  }
177 
178  inline bool operator()(IntensityType left, ChromatogramPeak const & right) const
179  {
180  return left < right.getIntensity();
181  }
182 
183  inline bool operator()(IntensityType left, IntensityType right) const
184  {
185  return left < right;
186  }
187 
188  };
189 
191  struct RTLess
192  {
193  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
194  {
195  return left.getRT() < right.getPos();
196  }
197 
198  inline bool operator()(ChromatogramPeak const & left, CoordinateType right) const
199  {
200  return left.getRT() < right;
201  }
202 
203  inline bool operator()(CoordinateType left, ChromatogramPeak const & right) const
204  {
205  return left < right.getRT();
206  }
207 
208  inline bool operator()(CoordinateType left, CoordinateType right) const
209  {
210  return left < right;
211  }
212 
213  };
214 
217  {
218  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
219  {
220  return left.getPosition() < right.getPosition();
221  }
222 
223  inline bool operator()(const ChromatogramPeak & left, const PositionType & right) const
224  {
225  return left.getPosition() < right;
226  }
227 
228  inline bool operator()(const PositionType & left, const ChromatogramPeak & right) const
229  {
230  return left < right.getPosition();
231  }
232 
233  inline bool operator()(const PositionType & left, const PositionType & right) const
234  {
235  return left < right;
236  }
237  };
239 protected:
244  };
245 
247  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChromatogramPeak & point);
248 
249 } // namespace OpenMS
250 
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:28
ChromatogramPeak & operator=(const ChromatogramPeak &rhs)
Assignment operator.
Definition: ChromatogramPeak.h:133
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: ChromatogramPeak.h:113
DPosition< 1 > PositionType
Position type.
Definition: ChromatogramPeak.h:39
ChromatogramPeak(const PositionType retention_time, const IntensityType intensity)
Constructor with position and intensity.
Definition: ChromatogramPeak.h:61
double CoordinateType
Coordinate type.
Definition: ChromatogramPeak.h:41
PositionType position_
The data point position.
Definition: ChromatogramPeak.h:241
~ChromatogramPeak()
Destructor.
Definition: ChromatogramPeak.h:74
CoordinateType getPos() const
Alias for getRT()
Definition: ChromatogramPeak.h:101
IntensityType getIntensity() const
Non-mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:84
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:95
bool operator!=(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:153
bool operator==(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:144
ChromatogramPeak(const ChromatogramPeak &p)
Copy constructor.
Definition: ChromatogramPeak.h:55
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:86
double IntensityType
Intensity type.
Definition: ChromatogramPeak.h:37
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: ChromatogramPeak.h:125
void setPos(CoordinateType pos)
Alias for setRT()
Definition: ChromatogramPeak.h:107
IntensityType intensity_
The data point intensity.
Definition: ChromatogramPeak.h:243
ChromatogramPeak()
Default constructor.
Definition: ChromatogramPeak.h:49
PositionType & getPosition()
Mutable access to the position.
Definition: ChromatogramPeak.h:119
CoordinateType getRT() const
Non-mutable access to RT.
Definition: ChromatogramPeak.h:89
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 intensity.
Definition: ChromatogramPeak.h:167
bool operator()(ChromatogramPeak const &left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:168
bool operator()(ChromatogramPeak const &left, IntensityType right) const
Definition: ChromatogramPeak.h:173
bool operator()(IntensityType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:178
bool operator()(IntensityType left, IntensityType right) const
Definition: ChromatogramPeak.h:183
Comparator by position. As this class has dimension 1, this is basically an alias for RTLess.
Definition: ChromatogramPeak.h:217
bool operator()(const PositionType &left, const PositionType &right) const
Definition: ChromatogramPeak.h:233
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:218
bool operator()(const PositionType &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:228
bool operator()(const ChromatogramPeak &left, const PositionType &right) const
Definition: ChromatogramPeak.h:223
Comparator by RT position.
Definition: ChromatogramPeak.h:192
bool operator()(CoordinateType left, CoordinateType right) const
Definition: ChromatogramPeak.h:208
bool operator()(ChromatogramPeak const &left, CoordinateType right) const
Definition: ChromatogramPeak.h:198
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:193
bool operator()(CoordinateType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:203