| OpenMS 2.5.0

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-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: Marc Sturm $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/CONCEPT/Types.h>
38 #include <OpenMS/DATASTRUCTURES/DPosition.h>
39
40 #include <iosfwd>
41 #include <functional>
42
43 namespace OpenMS
44 {
45
54 class OPENMS_DLLAPI Peak2D
55 {
56 public:
57
60
62 typedef float IntensityType;
64 typedef double CoordinateType;
66 typedef DPosition<2> PositionType;
68
71
73 enum DimensionDescription
74 {
75 RT = 0,
76 MZ = 1,
77 DIMENSION = 2
78 };
79
81 static char const * shortDimensionName(UInt const dim);
83 static char const * shortDimensionNameRT();
85 static char const * shortDimensionNameMZ();
86
88 static char const * fullDimensionName(UInt const dim);
90 static char const * fullDimensionNameRT();
92 static char const * fullDimensionNameMZ();
93
95 static char const * shortDimensionUnit(UInt const dim);
97 static char const * shortDimensionUnitRT();
99 static char const * shortDimensionUnitMZ();
100
102 static char const * fullDimensionUnit(UInt const dim);
104 static char const * fullDimensionUnitRT();
106 static char const * fullDimensionUnitMZ();
107
109
110 protected:
111
114
116 static char const * const dimension_name_short_[DIMENSION];
117
119 static char const * const dimension_name_full_[DIMENSION];
120
122 static char const * const dimension_unit_short_[DIMENSION];
123
125 static char const * const dimension_unit_full_[DIMENSION];
126
128
129 public:
130
134 Peak2D() :
135 position_(),
136 intensity_(0)
137 {}
138
140 explicit Peak2D(const PositionType& pos, const IntensityType in) :
141 position_(pos),
142 intensity_(in)
143 {}
144
146 Peak2D(const Peak2D & p) = default;
147
149 Peak2D(Peak2D&&) = default;
150
159 ~Peak2D()
160 {}
162
166 IntensityType getIntensity() const
167 {
168 return intensity_;
169 }
170
172 void setIntensity(IntensityType intensity)
173 {
174 intensity_ = intensity;
175 }
176
178 PositionType const & getPosition() const
179 {
180 return position_;
181 }
182
184 PositionType & getPosition()
185 {
186 return position_;
187 }
188
190 void setPosition(const PositionType & position)
191 {
192 position_ = position;
193 }
194
196 CoordinateType getMZ() const
197 {
198 return position_[MZ];
199 }
200
202 void setMZ(CoordinateType coordinate)
203 {
204 position_[MZ] = coordinate;
205 }
206
208 CoordinateType getRT() const
209 {
210 return position_[RT];
211 }
212
214 void setRT(CoordinateType coordinate)
215 {
216 position_[RT] = coordinate;
217 }
218
220
222 Peak2D & operator=(const Peak2D & rhs) = default;
223
225 Peak2D& operator=(Peak2D&&) & = default;
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
OpenMS::Peak2D::setRT
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition: Peak2D.h:214
OpenMS::Peak2D::getIntensity
IntensityType getIntensity() const
Definition: Peak2D.h:166
OpenMS::Peak2D::operator!=
bool operator!=(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:237
OpenMS::Peak2D
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:54
OpenMS::Peak2D::MZLess::operator()
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:309
OpenMS::Peak2D::IntensityLess::operator()
bool operator()(const Peak2D &left, IntensityType right) const
Definition: Peak2D.h:257
OpenMS::Peak2D::setMZ
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: Peak2D.h:202
OpenMS::Peak2D::IntensityType
float IntensityType
Intensity type.
Definition: Peak2D.h:62
OpenMS::Peak2D::DimensionDescription
DimensionDescription
This enum maps the symbolic names of the dimensions to numbers.
Definition: Peak2D.h:73
OpenMS::Peak2D::position_
PositionType position_
The data point position.
Definition: Peak2D.h:358
seqan::position
Size< TNeedle >::Type position(const PatternAuxData< TNeedle > &dh)
Definition: AhoCorasickAmbiguous.h:561
OpenMS::Peak2D::RTLess::operator()
bool operator()(const Peak2D &left, CoordinateType right) const
Definition: Peak2D.h:283
OpenMS::Peak2D::MZLess::operator()
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:319
Types.h
OpenMS::Peak2D::PositionType
DPosition< 2 > PositionType
Position type.
Definition: Peak2D.h:66
OpenMS::Peak2D::getRT
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:208
OpenMS::Peak2D::RTLess
Comparator by RT position.
Definition: Peak2D.h:275
OpenMS::Peak2D::RTLess::operator()
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:278
OpenMS::Peak2D::CoordinateType
double CoordinateType
Coordinate type (of the position)
Definition: Peak2D.h:64
OpenMS::Peak2D::PositionLess::operator()
bool operator()(const Peak2D &left, const PositionType &right) const
Definition: Peak2D.h:335
OpenMS::Peak2D::RTLess::operator()
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:288
OpenMS::Peak2D::PositionLess
Comparator by position. Lexicographical comparison (first RT then m/z) is done.
Definition: Peak2D.h:327
DPosition.h
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Peak2D::PositionLess::operator()
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:330
OpenMS::Peak2D::IntensityLess::operator()
bool operator()(IntensityType left, const Peak2D &right) const
Definition: Peak2D.h:262
OpenMS::Peak2D::IntensityLess::operator()
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak2D.h:267
OpenMS::Peak2D::MZLess::operator()
bool operator()(CoordinateType left, const Peak2D &right) const
Definition: Peak2D.h:314
OpenMS::Peak2D::MZLess
Comparator by m/z position.
Definition: Peak2D.h:301
OpenMS::Peak2D::PositionLess::operator()
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak2D.h:345
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::DPosition< 2 >
OpenMS::Peak2D::getMZ
CoordinateType getMZ() const
Returns the m/z coordinate (index 1)
Definition: Peak2D.h:196
double
OpenMS::Peak2D::Peak2D
Peak2D()
Definition: Peak2D.h:134
float
OpenMS::Peak2D::intensity_
IntensityType intensity_
The data point intensity.
Definition: Peak2D.h:360
OpenMS::Peak2D::~Peak2D
~Peak2D()
Destructor.
Definition: Peak2D.h:159
OpenMS::Peak2D::RTLess::operator()
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak2D.h:293
OpenMS::Peak2D::IntensityLess::operator()
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:252
OpenMS::Peak2D::getPosition
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak2D.h:178
OpenMS::Peak2D::PositionLess::operator()
bool operator()(const PositionType &left, const Peak2D &right) const
Definition: Peak2D.h:340
OpenMS::Peak2D::getPosition
PositionType & getPosition()
Mutable access to the position.
Definition: Peak2D.h:184
OpenMS::Peak2D::setPosition
void setPosition(const PositionType &position)
Mutable access to the position.
Definition: Peak2D.h:190
OpenMS::Peak2D::setIntensity
void setIntensity(IntensityType intensity)
Non-mutable access to the data point intensity (height)
Definition: Peak2D.h:172
OpenMS::Peak2D::MZLess::operator()
bool operator()(const Peak2D &left, const Peak2D &right) const
Definition: Peak2D.h:304
OpenMS::Peak2D::Peak2D
Peak2D(const PositionType &pos, const IntensityType in)
Member constructor.
Definition: Peak2D.h:140
OpenMS::Peak2D::operator==
bool operator==(const Peak2D &rhs) const
Equality operator.
Definition: Peak2D.h:228
KDTree::operator==
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806