OpenMS  2.6.0
ChromatogramPeak.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-2020.
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: Andreas Bertsch $
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 
53  class OPENMS_DLLAPI ChromatogramPeak
54  {
55 public:
60  enum {DIMENSION = 1};
63  typedef double IntensityType;
67  typedef double CoordinateType;
69 
74  inline ChromatogramPeak() :
76  position_(),
77  intensity_(0)
78  {}
79 
81  inline ChromatogramPeak(const ChromatogramPeak & p) :
82  position_(p.position_),
83  intensity_(p.intensity_)
84  {}
85 
87  inline ChromatogramPeak(const PositionType retention_time, const IntensityType intensity) :
88  position_(retention_time),
89  intensity_(intensity)
90  {}
91 
101  {}
103 
108 
110  inline IntensityType getIntensity() const { return intensity_; }
112  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
113 
115  inline CoordinateType getRT() const
116  {
117  return position_[0];
118  }
119 
121  inline void setRT(CoordinateType rt)
122  {
123  position_[0] = rt;
124  }
125 
127  inline CoordinateType getPos() const
128  {
129  return position_[0];
130  }
131 
133  inline void setPos(CoordinateType pos)
134  {
135  position_[0] = pos;
136  }
137 
139  inline CoordinateType getMZ() const
140  {
141  return position_[0];
142  }
143 
145  inline void setMZ(CoordinateType rt)
146  {
147  position_[0] = rt;
148  }
149 
151  inline PositionType const & getPosition() const
152  {
153  return position_;
154  }
155 
158  {
159  return position_;
160  }
161 
163  inline void setPosition(PositionType const & position)
164  {
165  position_ = position;
166  }
167 
169 
172  {
173  if (this == &rhs) return *this;
174 
175  intensity_ = rhs.intensity_;
176  position_ = rhs.position_;
177 
178  return *this;
179  }
180 
182  inline bool operator==(const ChromatogramPeak & rhs) const
183  {
184 #pragma clang diagnostic push
185 #pragma clang diagnostic ignored "-Wfloat-equal"
186  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
187 #pragma clang diagnostic pop
188  }
189 
191  inline bool operator!=(const ChromatogramPeak & rhs) const
192  {
193  return !(operator==(rhs));
194  }
195 
203  struct IntensityLess :
205  std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
206  {
207  inline bool operator()(ChromatogramPeak const & left, ChromatogramPeak const & right) const
208  {
209  return left.getIntensity() < right.getIntensity();
210  }
211 
212  inline bool operator()(ChromatogramPeak const & left, IntensityType right) const
213  {
214  return left.getIntensity() < right;
215  }
216 
217  inline bool operator()(IntensityType left, ChromatogramPeak const & right) const
218  {
219  return left < right.getIntensity();
220  }
221 
222  inline bool operator()(IntensityType left, IntensityType right) const
223  {
224  return left < right;
225  }
226 
227  };
228 
230  struct RTLess :
231  public std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
232  {
233  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
234  {
235  return left.getRT() < right.getPos();
236  }
237 
238  inline bool operator()(ChromatogramPeak const & left, CoordinateType right) const
239  {
240  return left.getRT() < right;
241  }
242 
243  inline bool operator()(CoordinateType left, ChromatogramPeak const & right) const
244  {
245  return left < right.getRT();
246  }
247 
248  inline bool operator()(CoordinateType left, CoordinateType right) const
249  {
250  return left < right;
251  }
252 
253  };
254 
256  struct PositionLess :
257  public std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
258  {
259  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
260  {
261  return left.getPosition() < right.getPosition();
262  }
263 
264  inline bool operator()(const ChromatogramPeak & left, const PositionType & right) const
265  {
266  return left.getPosition() < right;
267  }
268 
269  inline bool operator()(const PositionType & left, const ChromatogramPeak & right) const
270  {
271  return left < right.getPosition();
272  }
273 
274  inline bool operator()(const PositionType & left, const PositionType & right) const
275  {
276  return left < right;
277  }
278  };
280 protected:
285  };
286 
288  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChromatogramPeak & point);
289 
290 } // namespace OpenMS
291 
OpenMS::ChromatogramPeak::ChromatogramPeak
ChromatogramPeak(const ChromatogramPeak &p)
Copy constructor.
Definition: ChromatogramPeak.h:81
double
DPosition.h
Types.h
OpenMS::ChromatogramPeak::ChromatogramPeak
ChromatogramPeak(const PositionType retention_time, const IntensityType intensity)
Constructor with position and intensity.
Definition: ChromatogramPeak.h:87
OpenMS::ChromatogramPeak::PositionLess::operator()
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:259
OpenMS::ChromatogramPeak::operator=
ChromatogramPeak & operator=(const ChromatogramPeak &rhs)
Assignment operator.
Definition: ChromatogramPeak.h:171
OpenMS::ChromatogramPeak::PositionLess::operator()
bool operator()(const PositionType &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:269
OpenMS::ChromatogramPeak::IntensityLess::operator()
bool operator()(IntensityType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:217
OpenMS::ChromatogramPeak::setPos
void setPos(CoordinateType pos)
Alias for setRT()
Definition: ChromatogramPeak.h:133
OpenMS::ChromatogramPeak::RTLess::operator()
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:233
OpenMS::ChromatogramPeak::getMZ
CoordinateType getMZ() const
Alias for getRT()
Definition: ChromatogramPeak.h:139
OpenMS::ChromatogramPeak::setIntensity
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:112
OpenMS::ChromatogramPeak::position_
PositionType position_
The data point position.
Definition: ChromatogramPeak.h:282
OpenMS::ChromatogramPeak::getPosition
const PositionType & getPosition() const
Non-mutable access to the position.
Definition: ChromatogramPeak.h:151
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::ChromatogramPeak::~ChromatogramPeak
~ChromatogramPeak()
Destructor.
Definition: ChromatogramPeak.h:100
OpenMS::ChromatogramPeak::RTLess
Comparator by RT position.
Definition: ChromatogramPeak.h:230
OpenMS::ChromatogramPeak::getPos
CoordinateType getPos() const
Alias for getRT()
Definition: ChromatogramPeak.h:127
OpenMS::ChromatogramPeak::RTLess::operator()
bool operator()(ChromatogramPeak const &left, CoordinateType right) const
Definition: ChromatogramPeak.h:238
OpenMS::ChromatogramPeak::RTLess::operator()
bool operator()(CoordinateType left, CoordinateType right) const
Definition: ChromatogramPeak.h:248
OpenMS::ChromatogramPeak::IntensityLess::operator()
bool operator()(IntensityType left, IntensityType right) const
Definition: ChromatogramPeak.h:222
OpenMS::ChromatogramPeak::PositionLess
Comparator by position. As this class has dimension 1, this is basically an alias for RTLess.
Definition: ChromatogramPeak.h:256
OpenMS::ChromatogramPeak::PositionLess::operator()
bool operator()(const ChromatogramPeak &left, const PositionType &right) const
Definition: ChromatogramPeak.h:264
OpenMS::ChromatogramPeak
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:53
OpenMS::ChromatogramPeak::PositionType
DPosition< 1 > PositionType
Position type.
Definition: ChromatogramPeak.h:65
OpenMS::ChromatogramPeak::PositionLess::operator()
bool operator()(const PositionType &left, const PositionType &right) const
Definition: ChromatogramPeak.h:274
OpenMS::ChromatogramPeak::operator==
bool operator==(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:182
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS::DPosition< 1 >
OpenMS::ChromatogramPeak::getRT
CoordinateType getRT() const
Non-mutable access to RT.
Definition: ChromatogramPeak.h:115
OpenMS::ChromatogramPeak::setMZ
void setMZ(CoordinateType rt)
Alias for setRT()
Definition: ChromatogramPeak.h:145
OpenMS::ChromatogramPeak::IntensityLess::operator()
bool operator()(ChromatogramPeak const &left, IntensityType right) const
Definition: ChromatogramPeak.h:212
OpenMS::Internal::operator==
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
OpenMS::ChromatogramPeak::intensity_
IntensityType intensity_
The data point intensity.
Definition: ChromatogramPeak.h:284
OpenMS::ChromatogramPeak::getIntensity
IntensityType getIntensity() const
Non-mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:110
OpenMS::ChromatogramPeak::setRT
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:121
OpenMS::ChromatogramPeak::operator!=
bool operator!=(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:191
OpenMS::ChromatogramPeak::IntensityLess::operator()
bool operator()(ChromatogramPeak const &left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:207
OpenMS::ChromatogramPeak::CoordinateType
double CoordinateType
Coordinate type.
Definition: ChromatogramPeak.h:67
OpenMS::ChromatogramPeak::getPosition
PositionType & getPosition()
Mutable access to the position.
Definition: ChromatogramPeak.h:157
seqan::position
Size< TNeedle >::Type position(const PatternAuxData< TNeedle > &dh)
Definition: AhoCorasickAmbiguous.h:561
OpenMS::ChromatogramPeak::RTLess::operator()
bool operator()(CoordinateType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:243
OpenMS::ChromatogramPeak::setPosition
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: ChromatogramPeak.h:163
OpenMS::ChromatogramPeak::IntensityType
double IntensityType
Intensity type.
Definition: ChromatogramPeak.h:63