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-2013.
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 <ostream>
42 #include <functional>
43 
44 namespace OpenMS
45 {
46 
55  class OPENMS_DLLAPI Peak2D
56  {
57 public:
58 
61 
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 
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 
180  {
181  return position_;
182  }
183 
185  void setPosition(const PositionType & position)
186  {
187  position_ = position;
188  }
189 
192  {
193  return position_[MZ];
194  }
195 
197  void setMZ(CoordinateType coordinate)
198  {
199  position_[MZ] = coordinate;
200  }
201 
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  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
231  }
232 
234  bool operator!=(const Peak2D & rhs) const
235  {
236  return !(operator==(rhs));
237  }
238 
244  struct IntensityLess :
247  std::binary_function<Peak2D, Peak2D, bool>
248  {
249  bool operator()(const Peak2D & left, const Peak2D & right) const
250  {
251  return left.getIntensity() < right.getIntensity();
252  }
253 
254  bool operator()(const Peak2D & left, IntensityType right) const
255  {
256  return left.getIntensity() < right;
257  }
258 
259  bool operator()(IntensityType left, const Peak2D & right) const
260  {
261  return left < right.getIntensity();
262  }
263 
264  bool operator()(IntensityType left, IntensityType right) const
265  {
266  return left < right;
267  }
268 
269  };
270 
272  struct RTLess :
273  std::binary_function<Peak2D, Peak2D, bool>
274  {
275  bool operator()(const Peak2D & left, const Peak2D & right) const
276  {
277  return left.getRT() < right.getRT();
278  }
279 
280  bool operator()(const Peak2D & left, CoordinateType right) const
281  {
282  return left.getRT() < right;
283  }
284 
285  bool operator()(CoordinateType left, const Peak2D & right) const
286  {
287  return left < right.getRT();
288  }
289 
290  bool operator()(CoordinateType left, CoordinateType right) const
291  {
292  return left < right;
293  }
294 
295  };
296 
298  struct MZLess :
299  std::binary_function<Peak2D, Peak2D, bool>
300  {
301  bool operator()(const Peak2D & left, const Peak2D & right) const
302  {
303  return left.getMZ() < right.getMZ();
304  }
305 
306  bool operator()(const Peak2D & left, CoordinateType right) const
307  {
308  return left.getMZ() < right;
309  }
310 
311  bool operator()(CoordinateType left, const Peak2D & right) const
312  {
313  return left < right.getMZ();
314  }
315 
316  bool operator()(CoordinateType left, CoordinateType right) const
317  {
318  return left < right;
319  }
320 
321  };
322 
324  struct PositionLess :
325  public std::binary_function<Peak2D, Peak2D, bool>
326  {
327  bool operator()(const Peak2D & left, const Peak2D & right) const
328  {
329  return left.getPosition() < right.getPosition();
330  }
331 
332  bool operator()(const Peak2D & left, const PositionType & right) const
333  {
334  return left.getPosition() < right;
335  }
336 
337  bool operator()(const PositionType & left, const Peak2D & right) const
338  {
339  return left < right.getPosition();
340  }
341 
342  bool operator()(const PositionType & left, const PositionType & right) const
343  {
344  return left < right;
345  }
346 
347  };
349 
350  friend OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
351 
352 protected:
353 
358  };
359 
361  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak2D & point);
362 
363 } // namespace OpenMS
364 
365 #endif // OPENMS_KERNEL_PEAK2D_H
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:249
DoubleReal CoordinateType
Coordinate type (of the position)
Definition: Peak2D.h:65
Real IntensityType
Intensity type.
Definition: Peak2D.h:63
float Real
Real type.
Definition: Types.h:109
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:306
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:280
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:342
bool operator()(const PositionType &left, const Peak2D &right) const
Definition: Peak2D.h:337
IntensityType getIntensity() const
Definition: Peak2D.h:161
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:290
std::ostream & operator<<(std::ostream &os, const ItraqQuantifier::ItraqQuantifierStats &stats)
Peak2D & operator=(const Peak2D &rhs)
Assignment operator.
Definition: Peak2D.h:217
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:203
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:324
PositionType position_
The data point position.
Definition: Peak2D.h:355
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
DimensionDescription
This enum maps the symbolic names of the dimensions to numbers.
Definition: Peak2D.h:74
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:285
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:311
bool operator!=(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:234
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
~Peak2D()
Destructor.
Definition: Peak2D.h:154
Comparator by RT position.
Definition: Peak2D.h:272
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:254
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:301
PositionType & getPosition()
Mutable access to the position.
Definition: Peak2D.h:179
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:275
bool operator()(IntensityType left, const Peak2D &right) const
Definition: Peak2D.h:259
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak2D.h:264
bool operator()(const Peak2D &left, const PositionType &right) const
Definition: Peak2D.h:332
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:327
IntensityType intensity_
The data point intensity.
Definition: Peak2D.h:357
Comparator by m/z position.
Definition: Peak2D.h:298
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:316

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:19 using doxygen 1.8.5