Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Peak2D.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-2015.
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: Stephan Aiche$
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_KERNEL_PEAK2D_H
36 #define OPENMS_KERNEL_PEAK2D_H
37 
38 #include <OpenMS/CONCEPT/Types.h>
40 
41 #include <iosfwd>
42 #include <functional>
43 
44 namespace OpenMS
45 {
46 
55  class OPENMS_DLLAPI Peak2D
56  {
57 public:
58 
61 
63  typedef float IntensityType;
65  typedef double CoordinateType;
69 
72 
75  {
76  RT = 0,
77  MZ = 1,
78  DIMENSION = 2
79  };
80 
82  static char const * shortDimensionName(UInt const dim);
84  static char const * shortDimensionNameRT();
86  static char const * shortDimensionNameMZ();
87 
89  static char const * fullDimensionName(UInt const dim);
91  static char const * fullDimensionNameRT();
93  static char const * fullDimensionNameMZ();
94 
96  static char const * shortDimensionUnit(UInt const dim);
98  static char const * shortDimensionUnitRT();
100  static char const * shortDimensionUnitMZ();
101 
103  static char const * fullDimensionUnit(UInt const dim);
105  static char const * fullDimensionUnitRT();
107  static char const * fullDimensionUnitMZ();
108 
110 
111 protected:
112 
115 
117  static char const * const dimension_name_short_[DIMENSION];
118 
120  static char const * const dimension_name_full_[DIMENSION];
121 
123  static char const * const dimension_unit_short_[DIMENSION];
124 
126  static char const * const dimension_unit_full_[DIMENSION];
127 
129 
130 public:
131 
135  Peak2D() :
136  position_(),
137  intensity_(0)
138  {}
139 
141  Peak2D(const Peak2D & p) :
142  position_(p.position_),
143  intensity_(p.intensity_)
144  {}
145 
155  {}
157 
161  IntensityType getIntensity() const
162  {
163  return intensity_;
164  }
165 
167  void setIntensity(IntensityType intensity)
168  {
169  intensity_ = intensity;
170  }
171 
173  PositionType const & getPosition() const
174  {
175  return position_;
176  }
177 
179  PositionType & getPosition()
180  {
181  return position_;
182  }
183 
185  void setPosition(const PositionType & position)
186  {
187  position_ = position;
188  }
189 
191  CoordinateType getMZ() const
192  {
193  return position_[MZ];
194  }
195 
197  void setMZ(CoordinateType coordinate)
198  {
199  position_[MZ] = coordinate;
200  }
201 
203  CoordinateType getRT() const
204  {
205  return position_[RT];
206  }
207 
209  void setRT(CoordinateType coordinate)
210  {
211  position_[RT] = coordinate;
212  }
213 
215 
217  Peak2D & operator=(const Peak2D & rhs)
218  {
219  if (this == &rhs) return *this;
220 
221  intensity_ = rhs.intensity_;
222  position_ = rhs.position_;
223 
224  return *this;
225  }
226 
228  bool operator==(const Peak2D & rhs) const
229  {
230 #pragma clang diagnostic push
231 #pragma clang diagnostic ignored "-Wfloat-equal"
232  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
233 #pragma clang diagnostic pop
234  }
235 
237  bool operator!=(const Peak2D & rhs) const
238  {
239  return !(operator==(rhs));
240  }
241 
247  struct IntensityLess :
250  std::binary_function<Peak2D, Peak2D, bool>
251  {
252  bool operator()(const Peak2D & left, const Peak2D & right) const
253  {
254  return left.getIntensity() < right.getIntensity();
255  }
256 
257  bool operator()(const Peak2D & left, IntensityType right) const
258  {
259  return left.getIntensity() < right;
260  }
261 
262  bool operator()(IntensityType left, const Peak2D & right) const
263  {
264  return left < right.getIntensity();
265  }
266 
267  bool operator()(IntensityType left, IntensityType right) const
268  {
269  return left < right;
270  }
271 
272  };
273 
275  struct RTLess :
276  std::binary_function<Peak2D, Peak2D, bool>
277  {
278  bool operator()(const Peak2D & left, const Peak2D & right) const
279  {
280  return left.getRT() < right.getRT();
281  }
282 
283  bool operator()(const Peak2D & left, CoordinateType right) const
284  {
285  return left.getRT() < right;
286  }
287 
288  bool operator()(CoordinateType left, const Peak2D & right) const
289  {
290  return left < right.getRT();
291  }
292 
293  bool operator()(CoordinateType left, CoordinateType right) const
294  {
295  return left < right;
296  }
297 
298  };
299 
301  struct MZLess :
302  std::binary_function<Peak2D, Peak2D, bool>
303  {
304  bool operator()(const Peak2D & left, const Peak2D & right) const
305  {
306  return left.getMZ() < right.getMZ();
307  }
308 
309  bool operator()(const Peak2D & left, CoordinateType right) const
310  {
311  return left.getMZ() < right;
312  }
313 
314  bool operator()(CoordinateType left, const Peak2D & right) const
315  {
316  return left < right.getMZ();
317  }
318 
319  bool operator()(CoordinateType left, CoordinateType right) const
320  {
321  return left < right;
322  }
323 
324  };
325 
327  struct PositionLess :
328  public std::binary_function<Peak2D, Peak2D, bool>
329  {
330  bool operator()(const Peak2D & left, const Peak2D & right) const
331  {
332  return left.getPosition() < right.getPosition();
333  }
334 
335  bool operator()(const Peak2D & left, const PositionType & right) const
336  {
337  return left.getPosition() < right;
338  }
339 
340  bool operator()(const PositionType & left, const Peak2D & right) const
341  {
342  return left < right.getPosition();
343  }
344 
345  bool operator()(const PositionType & left, const PositionType & right) const
346  {
347  return left < right;
348  }
349 
350  };
352 
353  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
354 
355 protected:
356 
358  PositionType position_;
360  IntensityType intensity_;
361  };
362 
364  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
365 
366 } // namespace OpenMS
367 
368 #endif // OPENMS_KERNEL_PEAK2D_H
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:252
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak2D.h:173
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:309
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:283
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: Peak2D.h:197
DPosition< 2 > PositionType
Position type.
Definition: Peak2D.h:67
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak2D.h:345
bool operator()(const PositionType &left, const Peak2D &right) const
Definition: Peak2D.h:340
IntensityType getIntensity() const
Definition: Peak2D.h:161
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:293
Peak2D & operator=(const Peak2D &rhs)
Assignment operator.
Definition: Peak2D.h:217
double CoordinateType
Coordinate type (of the position)
Definition: Peak2D.h:65
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:203
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void setIntensity(IntensityType intensity)
Non-mutable access to the data point intensity (height)
Definition: Peak2D.h:167
Peak2D()
Definition: Peak2D.h:135
Comparator by position. Lexicographical comparison (first RT then m/z) is done.
Definition: Peak2D.h:327
PositionType position_
The data point position.
Definition: Peak2D.h:358
bool operator==(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:228
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition: Peak2D.h:209
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:288
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:314
bool operator!=(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:237
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Peak2D(const Peak2D &p)
Copy constructor.
Definition: Peak2D.h:141
Comparator that allows to compare the indices of two peaks by their intensity.
Definition: FeaFiModule.h:56
void setPosition(const PositionType &position)
Mutable access to the position.
Definition: Peak2D.h:185
float IntensityType
Intensity type.
Definition: Peak2D.h:63
DimensionDescription
This enum maps the symbolic names of the dimensions to numbers.
Definition: Peak2D.h:74
~Peak2D()
Destructor.
Definition: Peak2D.h:154
Comparator by RT position.
Definition: Peak2D.h:275
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: Peak2D.h:191
bool operator()(const Peak2D &left, IntensityType right) const
Definition: Peak2D.h:257
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:304
PositionType & getPosition()
Mutable access to the position.
Definition: Peak2D.h:179
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:278
bool operator()(IntensityType left, const Peak2D &right) const
Definition: Peak2D.h:262
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak2D.h:267
bool operator()(const Peak2D &left, const PositionType &right) const
Definition: Peak2D.h:335
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:330
IntensityType intensity_
The data point intensity.
Definition: Peak2D.h:360
Comparator by m/z position.
Definition: Peak2D.h:301
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:319

OpenMS / TOPP release 2.0.0 Documentation generated on Fri May 29 2015 17:20:28 using doxygen 1.8.9.1