OpenMS
ChromatogramPeak.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: 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 = default;
145 
147  inline bool operator!=(const ChromatogramPeak & rhs) const
148  {
149  return !(operator==(rhs));
150  }
151 
161  {
162  inline bool operator()(ChromatogramPeak const & left, ChromatogramPeak const & right) const
163  {
164  return left.getIntensity() < right.getIntensity();
165  }
166 
167  inline bool operator()(ChromatogramPeak const & left, IntensityType right) const
168  {
169  return left.getIntensity() < right;
170  }
171 
172  inline bool operator()(IntensityType left, ChromatogramPeak const & right) const
173  {
174  return left < right.getIntensity();
175  }
176 
177  inline bool operator()(IntensityType left, IntensityType right) const
178  {
179  return left < right;
180  }
181 
182  };
183 
185  struct RTLess
186  {
187  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
188  {
189  return left.getRT() < right.getPos();
190  }
191 
192  inline bool operator()(ChromatogramPeak const & left, CoordinateType right) const
193  {
194  return left.getRT() < right;
195  }
196 
197  inline bool operator()(CoordinateType left, ChromatogramPeak const & right) const
198  {
199  return left < right.getRT();
200  }
201 
202  inline bool operator()(CoordinateType left, CoordinateType right) const
203  {
204  return left < right;
205  }
206 
207  };
208 
211  {
212  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
213  {
214  return left.getPosition() < right.getPosition();
215  }
216 
217  inline bool operator()(const ChromatogramPeak & left, const PositionType & right) const
218  {
219  return left.getPosition() < right;
220  }
221 
222  inline bool operator()(const PositionType & left, const ChromatogramPeak & right) const
223  {
224  return left < right.getPosition();
225  }
226 
227  inline bool operator()(const PositionType & left, const PositionType & right) const
228  {
229  return left < right;
230  }
231  };
233 protected:
238  };
239 
241  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChromatogramPeak & point);
242 
243 } // namespace OpenMS
244 
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:235
~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:147
bool operator==(const ChromatogramPeak &rhs) const =default
Equality operator.
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:237
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:161
bool operator()(ChromatogramPeak const &left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:162
bool operator()(ChromatogramPeak const &left, IntensityType right) const
Definition: ChromatogramPeak.h:167
bool operator()(IntensityType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:172
bool operator()(IntensityType left, IntensityType right) const
Definition: ChromatogramPeak.h:177
Comparator by position. As this class has dimension 1, this is basically an alias for RTLess.
Definition: ChromatogramPeak.h:211
bool operator()(const PositionType &left, const PositionType &right) const
Definition: ChromatogramPeak.h:227
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:212
bool operator()(const PositionType &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:222
bool operator()(const ChromatogramPeak &left, const PositionType &right) const
Definition: ChromatogramPeak.h:217
Comparator by RT position.
Definition: ChromatogramPeak.h:186
bool operator()(CoordinateType left, CoordinateType right) const
Definition: ChromatogramPeak.h:202
bool operator()(ChromatogramPeak const &left, CoordinateType right) const
Definition: ChromatogramPeak.h:192
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:187
bool operator()(CoordinateType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:197