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-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: 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  explicit Peak2D(const PositionType& pos, const IntensityType in) :
142  position_(pos),
143  intensity_(in)
144  {}
145 
147  Peak2D(const Peak2D & p) :
148  position_(p.position_),
149  intensity_(p.intensity_)
150  {}
151 
161  {}
163 
167  IntensityType getIntensity() const
168  {
169  return intensity_;
170  }
171 
173  void setIntensity(IntensityType intensity)
174  {
175  intensity_ = intensity;
176  }
177 
179  PositionType const & getPosition() const
180  {
181  return position_;
182  }
183 
185  PositionType & getPosition()
186  {
187  return position_;
188  }
189 
191  void setPosition(const PositionType & position)
192  {
193  position_ = position;
194  }
195 
197  CoordinateType getMZ() const
198  {
199  return position_[MZ];
200  }
201 
203  void setMZ(CoordinateType coordinate)
204  {
205  position_[MZ] = coordinate;
206  }
207 
209  CoordinateType getRT() const
210  {
211  return position_[RT];
212  }
213 
215  void setRT(CoordinateType coordinate)
216  {
217  position_[RT] = coordinate;
218  }
219 
221 
223  Peak2D & operator=(const Peak2D & rhs)
224  {
225  if (this == &rhs) return *this;
226 
227  intensity_ = rhs.intensity_;
228  position_ = rhs.position_;
229 
230  return *this;
231  }
232 
234  bool operator==(const Peak2D & rhs) const
235  {
236 #pragma clang diagnostic push
237 #pragma clang diagnostic ignored "-Wfloat-equal"
238  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
239 #pragma clang diagnostic pop
240  }
241 
243  bool operator!=(const Peak2D & rhs) const
244  {
245  return !(operator==(rhs));
246  }
247 
253  struct IntensityLess :
256  std::binary_function<Peak2D, Peak2D, bool>
257  {
258  bool operator()(const Peak2D & left, const Peak2D & right) const
259  {
260  return left.getIntensity() < right.getIntensity();
261  }
262 
263  bool operator()(const Peak2D & left, IntensityType right) const
264  {
265  return left.getIntensity() < right;
266  }
267 
268  bool operator()(IntensityType left, const Peak2D & right) const
269  {
270  return left < right.getIntensity();
271  }
272 
273  bool operator()(IntensityType left, IntensityType right) const
274  {
275  return left < right;
276  }
277 
278  };
279 
281  struct RTLess :
282  std::binary_function<Peak2D, Peak2D, bool>
283  {
284  bool operator()(const Peak2D & left, const Peak2D & right) const
285  {
286  return left.getRT() < right.getRT();
287  }
288 
289  bool operator()(const Peak2D & left, CoordinateType right) const
290  {
291  return left.getRT() < right;
292  }
293 
294  bool operator()(CoordinateType left, const Peak2D & right) const
295  {
296  return left < right.getRT();
297  }
298 
299  bool operator()(CoordinateType left, CoordinateType right) const
300  {
301  return left < right;
302  }
303 
304  };
305 
307  struct MZLess :
308  std::binary_function<Peak2D, Peak2D, bool>
309  {
310  bool operator()(const Peak2D & left, const Peak2D & right) const
311  {
312  return left.getMZ() < right.getMZ();
313  }
314 
315  bool operator()(const Peak2D & left, CoordinateType right) const
316  {
317  return left.getMZ() < right;
318  }
319 
320  bool operator()(CoordinateType left, const Peak2D & right) const
321  {
322  return left < right.getMZ();
323  }
324 
325  bool operator()(CoordinateType left, CoordinateType right) const
326  {
327  return left < right;
328  }
329 
330  };
331 
333  struct PositionLess :
334  public std::binary_function<Peak2D, Peak2D, bool>
335  {
336  bool operator()(const Peak2D & left, const Peak2D & right) const
337  {
338  return left.getPosition() < right.getPosition();
339  }
340 
341  bool operator()(const Peak2D & left, const PositionType & right) const
342  {
343  return left.getPosition() < right;
344  }
345 
346  bool operator()(const PositionType & left, const Peak2D & right) const
347  {
348  return left < right.getPosition();
349  }
350 
351  bool operator()(const PositionType & left, const PositionType & right) const
352  {
353  return left < right;
354  }
355 
356  };
358 
359  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
360 
361 protected:
362 
364  PositionType position_;
366  IntensityType intensity_;
367  };
368 
370  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
371 
372 } // namespace OpenMS
373 
374 #endif // OPENMS_KERNEL_PEAK2D_H
Peak2D(const PositionType &pos, const IntensityType in)
Member constructor.
Definition: Peak2D.h:141
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:310
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:203
DPosition< 2 > PositionType
Position type.
Definition: Peak2D.h:67
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:320
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
bool operator()(IntensityType left, const Peak2D &right) const
Definition: Peak2D.h:268
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:258
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:289
Peak2D & operator=(const Peak2D &rhs)
Assignment operator.
Definition: Peak2D.h:223
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
double CoordinateType
Coordinate type (of the position)
Definition: Peak2D.h:65
Definition: Peak2D.h:255
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
IntensityType getIntensity() const
Definition: Peak2D.h:167
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak2D.h:351
void setIntensity(IntensityType intensity)
Non-mutable access to the data point intensity (height)
Definition: Peak2D.h:173
Peak2D()
Definition: Peak2D.h:135
Comparator by position. Lexicographical comparison (first RT then m/z) is done.
Definition: Peak2D.h:333
PositionType position_
The data point position.
Definition: Peak2D.h:364
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:336
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition: Peak2D.h:215
DimensionDescription
This enum maps the symbolic names of the dimensions to numbers.
Definition: Peak2D.h:74
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak2D.h:273
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: Peak2D.h:197
bool operator!=(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:243
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Peak2D(const Peak2D &p)
Copy constructor.
Definition: Peak2D.h:147
void setPosition(const PositionType &position)
Mutable access to the position.
Definition: Peak2D.h:191
float IntensityType
Intensity type.
Definition: Peak2D.h:63
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:325
~Peak2D()
Destructor.
Definition: Peak2D.h:160
Comparator by RT position.
Definition: Peak2D.h:281
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:209
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:315
PositionType & getPosition()
Mutable access to the position.
Definition: Peak2D.h:185
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:294
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak2D.h:179
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:284
bool operator()(const Peak2D &left, IntensityType right) const
Definition: Peak2D.h:263
bool operator()(const Peak2D &left, const PositionType &right) const
Definition: Peak2D.h:341
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:299
IntensityType intensity_
The data point intensity.
Definition: Peak2D.h:366
Comparator by m/z position.
Definition: Peak2D.h:307
bool operator()(const PositionType &left, const Peak2D &right) const
Definition: Peak2D.h:346
bool operator==(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:234

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