OpenMS
Loading...
Searching...
No Matches
ChromatogramPeak.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Andreas Bertsch $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14
15#include <iosfwd>
16#include <functional>
17
18namespace OpenMS
19{
20
28 class OPENMS_DLLAPI ChromatogramPeak
29 {
30public:
36 enum {DIMENSION = 1};
38 typedef double IntensityType;
42 typedef double CoordinateType;
44
51 position_(),
52 intensity_(0)
53 {}
54
56 ChromatogramPeak(const ChromatogramPeak & p) = default;
57
59 inline ChromatogramPeak(const PositionType retention_time, const IntensityType intensity) :
60 position_(retention_time),
61 intensity_(intensity)
62 {}
63
75
80
82 inline IntensityType getIntensity() const { return intensity_; }
84 inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
85
87 inline CoordinateType getRT() const
88 {
89 return position_[0];
90 }
91
93 inline void setRT(CoordinateType rt)
94 {
95 position_[0] = rt;
96 }
97
99 inline CoordinateType getPos() const
100 {
101 return position_[0];
102 }
103
105 inline void setPos(CoordinateType pos)
106 {
107 position_[0] = pos;
108 }
109
111 inline PositionType const & getPosition() const
112 {
113 return position_;
114 }
115
118 {
119 return position_;
120 }
121
123 inline void setPosition(PositionType const & position)
124 {
125 position_ = position;
126 }
127
129
132
134 inline bool operator==(const ChromatogramPeak& rhs) const = default;
135
137 inline bool operator!=(const ChromatogramPeak & rhs) const
138 {
139 return !(operator==(rhs));
140 }
141
151 {
152 inline bool operator()(ChromatogramPeak const & left, ChromatogramPeak const & right) const
153 {
154 return left.getIntensity() < right.getIntensity();
155 }
156
157 inline bool operator()(ChromatogramPeak const & left, IntensityType right) const
158 {
159 return left.getIntensity() < right;
160 }
161
162 inline bool operator()(IntensityType left, ChromatogramPeak const & right) const
163 {
164 return left < right.getIntensity();
165 }
166
167 inline bool operator()(IntensityType left, IntensityType right) const
168 {
169 return left < right;
170 }
171
172 };
173
175 struct RTLess
176 {
177 inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
178 {
179 return left.getRT() < right.getPos();
180 }
181
182 inline bool operator()(ChromatogramPeak const & left, CoordinateType right) const
183 {
184 return left.getRT() < right;
185 }
186
187 inline bool operator()(CoordinateType left, ChromatogramPeak const & right) const
188 {
189 return left < right.getRT();
190 }
191
192 inline bool operator()(CoordinateType left, CoordinateType right) const
193 {
194 return left < right;
195 }
196
197 };
198
201 {
202 inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
203 {
204 return left.getPosition() < right.getPosition();
205 }
206
207 inline bool operator()(const ChromatogramPeak & left, const PositionType & right) const
208 {
209 return left.getPosition() < right;
210 }
211
212 inline bool operator()(const PositionType & left, const ChromatogramPeak & right) const
213 {
214 return left < right.getPosition();
215 }
216
217 inline bool operator()(const PositionType & left, const PositionType & right) const
218 {
219 return left < right;
220 }
221 };
223protected:
228 };
229
231 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChromatogramPeak & point);
232
233} // namespace OpenMS
234
235// Hash function specialization for ChromatogramPeak
236namespace std
237{
238 template<>
239 struct hash<OpenMS::ChromatogramPeak>
240 {
241 std::size_t operator()(const OpenMS::ChromatogramPeak& p) const noexcept
242 {
243 std::size_t seed = OpenMS::hash_float(p.getRT());
244 OpenMS::hash_combine(seed, OpenMS::hash_float(p.getIntensity()));
245 return seed;
246 }
247 };
248} // namespace std
249
A 1-dimensional raw data point or peak for chromatograms.
Definition ChromatogramPeak.h:29
ChromatogramPeak(const ChromatogramPeak &p)=default
Copy constructor.
DPosition< 1 > PositionType
Position type.
Definition ChromatogramPeak.h:40
ChromatogramPeak & operator=(const ChromatogramPeak &rhs)=default
Assignment operator.
PositionType const & getPosition() const
Non-mutable access to the position.
Definition ChromatogramPeak.h:111
ChromatogramPeak(const PositionType retention_time, const IntensityType intensity)
Constructor with position and intensity.
Definition ChromatogramPeak.h:59
double CoordinateType
Coordinate type.
Definition ChromatogramPeak.h:42
PositionType position_
The data point position.
Definition ChromatogramPeak.h:225
~ChromatogramPeak()
Destructor.
Definition ChromatogramPeak.h:72
CoordinateType getPos() const
Alias for getRT()
Definition ChromatogramPeak.h:99
IntensityType getIntensity() const
Non-mutable access to the data point intensity (height)
Definition ChromatogramPeak.h:82
void setRT(CoordinateType rt)
Mutable access to RT.
Definition ChromatogramPeak.h:93
bool operator!=(const ChromatogramPeak &rhs) const
Equality operator.
Definition ChromatogramPeak.h:137
bool operator==(const ChromatogramPeak &rhs) const =default
Equality operator.
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition ChromatogramPeak.h:84
PositionType & getPosition()
Mutable access to the position.
Definition ChromatogramPeak.h:117
double IntensityType
Intensity type.
Definition ChromatogramPeak.h:38
void setPosition(PositionType const &position)
Mutable access to the position.
Definition ChromatogramPeak.h:123
void setPos(CoordinateType pos)
Alias for setRT()
Definition ChromatogramPeak.h:105
IntensityType intensity_
The data point intensity.
Definition ChromatogramPeak.h:227
ChromatogramPeak()
Default constructor.
Definition ChromatogramPeak.h:50
CoordinateType getRT() const
Non-mutable access to RT.
Definition ChromatogramPeak.h:87
Representation of a coordinate in D-dimensional space.
Definition DPosition.h:32
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
void hash_combine(std::size_t &seed, std::size_t value) noexcept
Combine a hash value with additional data using golden ratio mixing.
Definition HashUtils.h:87
std::size_t hash_float(T value) noexcept
Hash for a floating point type (float or double).
Definition HashUtils.h:142
STL namespace.
Comparator by intensity.
Definition ChromatogramPeak.h:151
bool operator()(ChromatogramPeak const &left, ChromatogramPeak const &right) const
Definition ChromatogramPeak.h:152
bool operator()(ChromatogramPeak const &left, IntensityType right) const
Definition ChromatogramPeak.h:157
bool operator()(IntensityType left, ChromatogramPeak const &right) const
Definition ChromatogramPeak.h:162
bool operator()(IntensityType left, IntensityType right) const
Definition ChromatogramPeak.h:167
Comparator by position. As this class has dimension 1, this is basically an alias for RTLess.
Definition ChromatogramPeak.h:201
bool operator()(const PositionType &left, const PositionType &right) const
Definition ChromatogramPeak.h:217
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition ChromatogramPeak.h:202
bool operator()(const PositionType &left, const ChromatogramPeak &right) const
Definition ChromatogramPeak.h:212
bool operator()(const ChromatogramPeak &left, const PositionType &right) const
Definition ChromatogramPeak.h:207
Comparator by RT position.
Definition ChromatogramPeak.h:176
bool operator()(CoordinateType left, CoordinateType right) const
Definition ChromatogramPeak.h:192
bool operator()(ChromatogramPeak const &left, CoordinateType right) const
Definition ChromatogramPeak.h:182
bool operator()(const ChromatogramPeak &left, const ChromatogramPeak &right) const
Definition ChromatogramPeak.h:177
bool operator()(CoordinateType left, ChromatogramPeak const &right) const
Definition ChromatogramPeak.h:187
std::size_t operator()(const OpenMS::ChromatogramPeak &p) const noexcept
Definition ChromatogramPeak.h:241