OpenMS  2.5.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 <ostream>
41 #include <functional>
42 
43 namespace OpenMS
44 {
45 
54  class OPENMS_DLLAPI ChromatogramPeak
55  {
56 public:
61  enum {DIMENSION = 1};
64  typedef double IntensityType;
68  typedef double CoordinateType;
70 
75  inline ChromatogramPeak() :
77  position_(),
78  intensity_(0)
79  {}
80 
82  inline ChromatogramPeak(const ChromatogramPeak & p) :
83  position_(p.position_),
84  intensity_(p.intensity_)
85  {}
86 
88  inline ChromatogramPeak(const PositionType retention_time, const IntensityType intensity) :
89  position_(retention_time),
90  intensity_(intensity)
91  {}
92 
102  {}
104 
109 
111  inline IntensityType getIntensity() const { return intensity_; }
113  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
114 
116  inline CoordinateType getRT() const
117  {
118  return position_[0];
119  }
120 
122  inline void setRT(CoordinateType rt)
123  {
124  position_[0] = rt;
125  }
126 
128  inline CoordinateType getPos() const
129  {
130  return position_[0];
131  }
132 
134  inline void setPos(CoordinateType pos)
135  {
136  position_[0] = pos;
137  }
138 
140  inline CoordinateType getMZ() const
141  {
142  return position_[0];
143  }
144 
146  inline void setMZ(CoordinateType rt)
147  {
148  position_[0] = rt;
149  }
150 
152  inline PositionType const & getPosition() const
153  {
154  return position_;
155  }
156 
159  {
160  return position_;
161  }
162 
164  inline void setPosition(PositionType const & position)
165  {
166  position_ = position;
167  }
168 
170 
173  {
174  if (this == &rhs) return *this;
175 
176  intensity_ = rhs.intensity_;
177  position_ = rhs.position_;
178 
179  return *this;
180  }
181 
183  inline bool operator==(const ChromatogramPeak & rhs) const
184  {
185 #pragma clang diagnostic push
186 #pragma clang diagnostic ignored "-Wfloat-equal"
187  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
188 #pragma clang diagnostic pop
189  }
190 
192  inline bool operator!=(const ChromatogramPeak & rhs) const
193  {
194  return !(operator==(rhs));
195  }
196 
204  struct IntensityLess :
206  std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
207  {
208  inline bool operator()(ChromatogramPeak const & left, ChromatogramPeak const & right) const
209  {
210  return left.getIntensity() < right.getIntensity();
211  }
212 
213  inline bool operator()(ChromatogramPeak const & left, IntensityType right) const
214  {
215  return left.getIntensity() < right;
216  }
217 
218  inline bool operator()(IntensityType left, ChromatogramPeak const & right) const
219  {
220  return left < right.getIntensity();
221  }
222 
223  inline bool operator()(IntensityType left, IntensityType right) const
224  {
225  return left < right;
226  }
227 
228  };
229 
231  struct RTLess :
232  public std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
233  {
234  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
235  {
236  return left.getRT() < right.getPos();
237  }
238 
239  inline bool operator()(ChromatogramPeak const & left, CoordinateType right) const
240  {
241  return left.getRT() < right;
242  }
243 
244  inline bool operator()(CoordinateType left, ChromatogramPeak const & right) const
245  {
246  return left < right.getRT();
247  }
248 
249  inline bool operator()(CoordinateType left, CoordinateType right) const
250  {
251  return left < right;
252  }
253 
254  };
255 
257  struct PositionLess :
258  public std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
259  {
260  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
261  {
262  return left.getPosition() < right.getPosition();
263  }
264 
265  inline bool operator()(const ChromatogramPeak & left, const PositionType & right) const
266  {
267  return left.getPosition() < right;
268  }
269 
270  inline bool operator()(const PositionType & left, const ChromatogramPeak & right) const
271  {
272  return left < right.getPosition();
273  }
274 
275  inline bool operator()(const PositionType & left, const PositionType & right) const
276  {
277  return left < right;
278  }
279  };
281 protected:
286  };
287 
289  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChromatogramPeak & point);
290 
291 } // namespace OpenMS
292 
OpenMS::ChromatogramPeak::ChromatogramPeak
ChromatogramPeak(const ChromatogramPeak &p)
Copy constructor.
Definition: ChromatogramPeak.h:82
double
DPosition.h
Types.h
OpenMS::ChromatogramPeak::ChromatogramPeak
ChromatogramPeak(const PositionType retention_time, const IntensityType intensity)
Constructor with position and intensity.
Definition: ChromatogramPeak.h:88
OpenMS::ChromatogramPeak::PositionLess::operator()
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:260
OpenMS::ChromatogramPeak::operator=
ChromatogramPeak & operator=(const ChromatogramPeak &rhs)
Assignment operator.
Definition: ChromatogramPeak.h:172
OpenMS::ChromatogramPeak::PositionLess::operator()
bool operator()(const PositionType &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:270
OpenMS::ChromatogramPeak::IntensityLess::operator()
bool operator()(IntensityType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:218
OpenMS::ChromatogramPeak::setPos
void setPos(CoordinateType pos)
Alias for setRT()
Definition: ChromatogramPeak.h:134
OpenMS::ChromatogramPeak::RTLess::operator()
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:234
OpenMS::ChromatogramPeak::getMZ
CoordinateType getMZ() const
Alias for getRT()
Definition: ChromatogramPeak.h:140
OpenMS::ChromatogramPeak::setIntensity
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:113
OpenMS::ChromatogramPeak::position_
PositionType position_
The data point position.
Definition: ChromatogramPeak.h:283
OpenMS::ChromatogramPeak::getPosition
const PositionType & getPosition() const
Non-mutable access to the position.
Definition: ChromatogramPeak.h:152
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::ChromatogramPeak::~ChromatogramPeak
~ChromatogramPeak()
Destructor.
Definition: ChromatogramPeak.h:101
OpenMS::ChromatogramPeak::RTLess
Comparator by RT position.
Definition: ChromatogramPeak.h:231
OpenMS::ChromatogramPeak::getPos
CoordinateType getPos() const
Alias for getRT()
Definition: ChromatogramPeak.h:128
OpenMS::ChromatogramPeak::RTLess::operator()
bool operator()(ChromatogramPeak const &left, CoordinateType right) const
Definition: ChromatogramPeak.h:239
OpenMS::ChromatogramPeak::RTLess::operator()
bool operator()(CoordinateType left, CoordinateType right) const
Definition: ChromatogramPeak.h:249
OpenMS::ChromatogramPeak::IntensityLess::operator()
bool operator()(IntensityType left, IntensityType right) const
Definition: ChromatogramPeak.h:223
OpenMS::ChromatogramPeak::PositionLess
Comparator by position. As this class has dimension 1, this is basically an alias for RTLess.
Definition: ChromatogramPeak.h:257
OpenMS::ChromatogramPeak::PositionLess::operator()
bool operator()(const ChromatogramPeak &left, const PositionType &right) const
Definition: ChromatogramPeak.h:265
OpenMS::ChromatogramPeak
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:54
OpenMS::ChromatogramPeak::PositionType
DPosition< 1 > PositionType
Position type.
Definition: ChromatogramPeak.h:66
OpenMS::ChromatogramPeak::PositionLess::operator()
bool operator()(const PositionType &left, const PositionType &right) const
Definition: ChromatogramPeak.h:275
OpenMS::ChromatogramPeak::operator==
bool operator==(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:183
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:116
OpenMS::ChromatogramPeak::setMZ
void setMZ(CoordinateType rt)
Alias for setRT()
Definition: ChromatogramPeak.h:146
OpenMS::ChromatogramPeak::IntensityLess::operator()
bool operator()(ChromatogramPeak const &left, IntensityType right) const
Definition: ChromatogramPeak.h:213
KDTree::operator==
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
OpenMS::ChromatogramPeak::intensity_
IntensityType intensity_
The data point intensity.
Definition: ChromatogramPeak.h:285
OpenMS::ChromatogramPeak::getIntensity
IntensityType getIntensity() const
Non-mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:111
OpenMS::ChromatogramPeak::setRT
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:122
OpenMS::ChromatogramPeak::operator!=
bool operator!=(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:192
OpenMS::ChromatogramPeak::IntensityLess::operator()
bool operator()(ChromatogramPeak const &left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:208
OpenMS::ChromatogramPeak::CoordinateType
double CoordinateType
Coordinate type.
Definition: ChromatogramPeak.h:68
OpenMS::ChromatogramPeak::getPosition
PositionType & getPosition()
Mutable access to the position.
Definition: ChromatogramPeak.h:158
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:244
OpenMS::ChromatogramPeak::setPosition
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: ChromatogramPeak.h:164
OpenMS::ChromatogramPeak::IntensityType
double IntensityType
Intensity type.
Definition: ChromatogramPeak.h:64