Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
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-2017.
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 #ifndef OPENMS_KERNEL_CHROMATOGRAMPEAK_H
36 #define OPENMS_KERNEL_CHROMATOGRAMPEAK_H
37 
38 #include <OpenMS/CONCEPT/Types.h>
40 
41 #include <ostream>
42 #include <functional>
43 
44 namespace OpenMS
45 {
46 
55  class OPENMS_DLLAPI ChromatogramPeak
56  {
57 public:
62  enum {DIMENSION = 1};
65  typedef double IntensityType;
69  typedef double CoordinateType;
71 
76  inline ChromatogramPeak() :
78  position_(),
79  intensity_(0)
80  {}
81 
83  inline ChromatogramPeak(const ChromatogramPeak & p) :
84  position_(p.position_),
85  intensity_(p.intensity_)
86  {}
87 
97  {}
99 
104 
106  inline IntensityType getIntensity() const { return intensity_; }
108  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
109 
111  inline CoordinateType getRT() const
112  {
113  return position_[0];
114  }
115 
117  inline void setRT(CoordinateType rt)
118  {
119  position_[0] = rt;
120  }
121 
123  inline CoordinateType getPos() const
124  {
125  return position_[0];
126  }
127 
129  inline void setPos(CoordinateType pos)
130  {
131  position_[0] = pos;
132  }
133 
135  inline CoordinateType getMZ() const
136  {
137  return position_[0];
138  }
139 
141  inline void setMZ(CoordinateType rt)
142  {
143  position_[0] = rt;
144  }
145 
147  inline PositionType const & getPosition() const
148  {
149  return position_;
150  }
151 
153  inline PositionType & getPosition()
154  {
155  return position_;
156  }
157 
159  inline void setPosition(PositionType const & position)
160  {
161  position_ = position;
162  }
163 
165 
168  {
169  if (this == &rhs) return *this;
170 
171  intensity_ = rhs.intensity_;
172  position_ = rhs.position_;
173 
174  return *this;
175  }
176 
178  inline bool operator==(const ChromatogramPeak & rhs) const
179  {
180 #pragma clang diagnostic push
181 #pragma clang diagnostic ignored "-Wfloat-equal"
182  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
183 #pragma clang diagnostic pop
184  }
185 
187  inline bool operator!=(const ChromatogramPeak & rhs) const
188  {
189  return !(operator==(rhs));
190  }
191 
199  struct IntensityLess :
201  std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
202  {
203  inline bool operator()(ChromatogramPeak const & left, ChromatogramPeak const & right) const
204  {
205  return left.getIntensity() < right.getIntensity();
206  }
207 
208  inline bool operator()(ChromatogramPeak const & left, IntensityType right) const
209  {
210  return left.getIntensity() < right;
211  }
212 
213  inline bool operator()(IntensityType left, ChromatogramPeak const & right) const
214  {
215  return left < right.getIntensity();
216  }
217 
218  inline bool operator()(IntensityType left, IntensityType right) const
219  {
220  return left < right;
221  }
222 
223  };
224 
226  struct RTLess :
227  public std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
228  {
229  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
230  {
231  return left.getRT() < right.getPos();
232  }
233 
234  inline bool operator()(ChromatogramPeak const & left, CoordinateType right) const
235  {
236  return left.getRT() < right;
237  }
238 
239  inline bool operator()(CoordinateType left, ChromatogramPeak const & right) const
240  {
241  return left < right.getRT();
242  }
243 
244  inline bool operator()(CoordinateType left, CoordinateType right) const
245  {
246  return left < right;
247  }
248 
249  };
250 
252  struct PositionLess :
253  public std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
254  {
255  inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
256  {
257  return left.getPosition() < right.getPosition();
258  }
259 
260  inline bool operator()(const ChromatogramPeak & left, const PositionType & right) const
261  {
262  return left.getPosition() < right;
263  }
264 
265  inline bool operator()(const PositionType & left, const ChromatogramPeak & right) const
266  {
267  return left < right.getPosition();
268  }
269 
270  inline bool operator()(const PositionType & left, const PositionType & right) const
271  {
272  return left < right;
273  }
274  };
276 protected:
278  PositionType position_;
280  IntensityType intensity_;
281  };
282 
284  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChromatogramPeak & point);
285 
286 } // namespace OpenMS
287 
288 #endif // OPENMS_KERNEL_CHROMATOGRAMPEAK_H
void setRT(CoordinateType rt)
Mutable access to RT.
Definition: ChromatogramPeak.h:117
ChromatogramPeak(const ChromatogramPeak &p)
Copy constructor.
Definition: ChromatogramPeak.h:83
void setPos(CoordinateType pos)
Alias for setRT()
Definition: ChromatogramPeak.h:129
bool operator!=(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:187
bool operator()(const PositionType &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:265
PositionType position_
The data point position.
Definition: ChromatogramPeak.h:278
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
~ChromatogramPeak()
Destructor.
Definition: ChromatogramPeak.h:96
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
bool operator==(const ChromatogramPeak &rhs) const
Equality operator.
Definition: ChromatogramPeak.h:178
ChromatogramPeak & operator=(const ChromatogramPeak &rhs)
Assignment operator.
Definition: ChromatogramPeak.h:167
double CoordinateType
Coordinate type.
Definition: ChromatogramPeak.h:69
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:229
Comparator by position. As this class has dimension 1, this is basically an alias for RTLess...
Definition: ChromatogramPeak.h:252
DPosition< 1 > PositionType
Position type.
Definition: ChromatogramPeak.h:67
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition: ChromatogramPeak.h:255
PositionType & getPosition()
Mutable access to the position.
Definition: ChromatogramPeak.h:153
CoordinateType getMZ() const
Alias for getRT()
Definition: ChromatogramPeak.h:135
bool operator()(CoordinateType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:239
CoordinateType getPos() const
Alias for getRT()
Definition: ChromatogramPeak.h:123
bool operator()(const ChromatogramPeak &left, const PositionType &right) const
Definition: ChromatogramPeak.h:260
CoordinateType getRT() const
Non-mutable access to RT.
Definition: ChromatogramPeak.h:111
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
bool operator()(ChromatogramPeak const &left, CoordinateType right) const
Definition: ChromatogramPeak.h:234
bool operator()(CoordinateType left, CoordinateType right) const
Definition: ChromatogramPeak.h:244
Comparator by intensity.
Definition: ChromatogramPeak.h:200
bool operator()(const PositionType &left, const PositionType &right) const
Definition: ChromatogramPeak.h:270
double IntensityType
Intensity type.
Definition: ChromatogramPeak.h:65
bool operator()(ChromatogramPeak const &left, IntensityType right) const
Definition: ChromatogramPeak.h:208
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:108
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: ChromatogramPeak.h:147
A 1-dimensional raw data point or peak for chromatograms.
Definition: ChromatogramPeak.h:55
IntensityType intensity_
The data point intensity.
Definition: ChromatogramPeak.h:280
IntensityType getIntensity() const
Non-mutable access to the data point intensity (height)
Definition: ChromatogramPeak.h:106
void setMZ(CoordinateType rt)
Alias for setRT()
Definition: ChromatogramPeak.h:141
bool operator()(IntensityType left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:213
Comparator by RT position.
Definition: ChromatogramPeak.h:226
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: ChromatogramPeak.h:159
bool operator()(ChromatogramPeak const &left, ChromatogramPeak const &right) const
Definition: ChromatogramPeak.h:203
bool operator()(IntensityType left, IntensityType right) const
Definition: ChromatogramPeak.h:218

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:21:59 using doxygen 1.8.13