OpenMS
Loading...
Searching...
No Matches
Peak1D.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: Marc Sturm $
7// --------------------------------------------------------------------------
8
9#pragma once
10
14
15#include <iosfwd>
16#include <functional>
17
18namespace OpenMS
19{
20
29 class OPENMS_DLLAPI Peak1D
30 {
31public:
32
36 enum {DIMENSION = 1};
38 using IntensityType = float;
42 using CoordinateType = double;
44
48 inline Peak1D() = default;
49
52 position_(a),
53 intensity_(b)
54 {}
55
57 Peak1D(const Peak1D & p) = default;
58
59 Peak1D(Peak1D&&) noexcept = default;
60
62 Peak1D& operator=(const Peak1D& rhs) = default;
63
65 Peak1D& operator=(Peak1D&&) noexcept = default;
66
75 ~Peak1D() = default;
76
78
84 inline IntensityType getIntensity() const { return intensity_; }
86 inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
87
89 inline CoordinateType getMZ() const
90 {
91 return position_[0];
92 }
93
95 inline void setMZ(CoordinateType mz)
96 {
97 position_[0] = mz;
98 }
99
101 inline CoordinateType getPos() const
102 {
103 return position_[0];
104 }
105
107 inline void setPos(CoordinateType pos)
108 {
109 position_[0] = pos;
110 }
111
113 inline PositionType const & getPosition() const
114 {
115 return position_;
116 }
117
120 {
121 return position_;
122 }
123
125 inline void setPosition(PositionType const & position)
126 {
127 position_ = position;
128 }
129
131
133 bool operator==(const Peak1D& rhs) const = default;
134
136 bool operator!=(const Peak1D & rhs) const
137 {
138 return !(operator==(rhs));
139 }
140
148 {
149 inline bool operator()(Peak1D const & left, Peak1D const & right) const
150 {
151 return left.getIntensity() < right.getIntensity();
152 }
153
154 inline bool operator()(Peak1D const & left, IntensityType right) const
155 {
156 return left.getIntensity() < right;
157 }
158
159 inline bool operator()(IntensityType left, Peak1D const & right) const
160 {
161 return left < right.getIntensity();
162 }
163
164 inline bool operator()(IntensityType left, IntensityType right) const
165 {
166 return left < right;
167 }
168
169 };
170
172 struct MZLess
173 {
174 inline bool operator()(const Peak1D & left, const Peak1D & right) const
175 {
176 return left.getMZ() < right.getMZ();
177 }
178
179 inline bool operator()(Peak1D const & left, CoordinateType right) const
180 {
181 return left.getMZ() < right;
182 }
183
184 inline bool operator()(CoordinateType left, Peak1D const & right) const
185 {
186 return left < right.getMZ();
187 }
188
189 inline bool operator()(CoordinateType left, CoordinateType right) const
190 {
191 return left < right;
192 }
193
194 };
195
198 {
199 inline bool operator()(const Peak1D & left, const Peak1D & right) const
200 {
201 return left.getPosition() < right.getPosition();
202 }
203
204 inline bool operator()(const Peak1D & left, const PositionType & right) const
205 {
206 return left.getPosition() < right;
207 }
208
209 inline bool operator()(const PositionType & left, const Peak1D & right) const
210 {
211 return left < right.getPosition();
212 }
213
214 inline bool operator()(const PositionType & left, const PositionType & right) const
215 {
216 return left < right;
217 }
218
219 };
221
222protected:
226 IntensityType intensity_ = 0.0;
227 };
228
230 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak1D & point);
231
232} // namespace OpenMS
233
234// Hash function specialization for Peak1D
235namespace std
236{
237 template<>
238 struct hash<OpenMS::Peak1D>
239 {
240 std::size_t operator()(const OpenMS::Peak1D& p) const noexcept
241 {
242 std::size_t seed = OpenMS::hash_float(p.getMZ());
243 OpenMS::hash_combine(seed, OpenMS::hash_float(p.getIntensity()));
244 return seed;
245 }
246 };
247} // namespace std
248
A 1-dimensional raw data point or peak.
Definition Peak1D.h:30
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition Peak1D.h:89
Peak1D()=default
double CoordinateType
Coordinate type.
Definition Peak1D.h:42
bool operator!=(const Peak1D &rhs) const
Equality operator.
Definition Peak1D.h:136
PositionType const & getPosition() const
Non-mutable access to the position.
Definition Peak1D.h:113
PositionType position_
The data point position.
Definition Peak1D.h:224
Peak1D(Peak1D &&) noexcept=default
Peak1D(const Peak1D &p)=default
Copy constructor.
CoordinateType getPos() const
Alias for getMZ()
Definition Peak1D.h:101
Peak1D(PositionType a, IntensityType b)
construct with position and intensity
Definition Peak1D.h:51
IntensityType getIntensity() const
Definition Peak1D.h:84
bool operator==(const Peak1D &rhs) const =default
Equality operator.
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition Peak1D.h:86
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition Peak1D.h:95
PositionType & getPosition()
Mutable access to the position.
Definition Peak1D.h:119
void setPosition(PositionType const &position)
Mutable access to the position.
Definition Peak1D.h:125
void setPos(CoordinateType pos)
Alias for setMZ()
Definition Peak1D.h:107
float IntensityType
Intensity type.
Definition Peak1D.h:38
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.
Definition Peak1D.h:148
bool operator()(IntensityType left, Peak1D const &right) const
Definition Peak1D.h:159
bool operator()(Peak1D const &left, IntensityType right) const
Definition Peak1D.h:154
bool operator()(Peak1D const &left, Peak1D const &right) const
Definition Peak1D.h:149
bool operator()(IntensityType left, IntensityType right) const
Definition Peak1D.h:164
Comparator by m/z position.
Definition Peak1D.h:173
bool operator()(CoordinateType left, CoordinateType right) const
Definition Peak1D.h:189
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition Peak1D.h:174
bool operator()(CoordinateType left, Peak1D const &right) const
Definition Peak1D.h:184
bool operator()(Peak1D const &left, CoordinateType right) const
Definition Peak1D.h:179
Comparator by position. As this class has dimension 1, this is basically an alias for MZLess.
Definition Peak1D.h:198
bool operator()(const Peak1D &left, const PositionType &right) const
Definition Peak1D.h:204
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition Peak1D.h:199
bool operator()(const PositionType &left, const PositionType &right) const
Definition Peak1D.h:214
bool operator()(const PositionType &left, const Peak1D &right) const
Definition Peak1D.h:209
std::size_t operator()(const OpenMS::Peak1D &p) const noexcept
Definition Peak1D.h:240