| OpenMS 2.5.0

Peak1D.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 Peak1D
55 {
56 public:
57
61 enum {DIMENSION = 1};
63 typedef float IntensityType;
65 typedef DPosition<1> PositionType;
67 typedef double CoordinateType;
69
73 inline Peak1D() :
74 position_(),
75 intensity_(0)
76 {}
77
79 inline Peak1D(PositionType a, IntensityType b) :
80 position_(a),
81 intensity_(b)
82 {}
83
85 inline Peak1D(const Peak1D & p) :
86 position_(p.position_),
87 intensity_(p.intensity_)
88 {}
89
90 Peak1D(Peak1D&&) noexcept = default;
91
100 ~Peak1D()
101 {}
102
104
108 inline IntensityType getIntensity() const { return intensity_; }
112 inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
113
115 inline CoordinateType getMZ() const
116 {
117 return position_[0];
118 }
119
121 inline void setMZ(CoordinateType mz)
122 {
123 position_[0] = mz;
124 }
125
127 inline CoordinateType getPos() const
128 {
129 return position_[0];
130 }
131
133 inline void setPos(CoordinateType pos)
134 {
135 position_[0] = pos;
136 }
137
139 inline PositionType const & getPosition() const
140 {
141 return position_;
142 }
143
145 inline PositionType & getPosition()
146 {
147 return position_;
148 }
149
151 inline void setPosition(PositionType const & position)
152 {
153 position_ = position;
154 }
155
157
159 inline Peak1D & operator=(const Peak1D & rhs)
160 {
161 if (this == &rhs) return *this;
162
163 intensity_ = rhs.intensity_;
164 position_ = rhs.position_;
165
166 return *this;
167 }
168
170 inline bool operator==(const Peak1D & rhs) const
171 {
172 #pragma clang diagnostic push
173 #pragma clang diagnostic ignored "-Wfloat-equal"
174 return intensity_ == rhs.intensity_ && position_ == rhs.position_;
175 #pragma clang diagnostic pop
176 }
177
179 inline bool operator!=(const Peak1D & rhs) const
180 {
181 return !(operator==(rhs));
182 }
183
188 struct IntensityLess :
191 std::binary_function<Peak1D, Peak1D, bool>
192 {
193 inline bool operator()(Peak1D const & left, Peak1D const & right) const
194 {
195 return left.getIntensity() < right.getIntensity();
196 }
197
198 inline bool operator()(Peak1D const & left, IntensityType right) const
199 {
200 return left.getIntensity() < right;
201 }
202
203 inline bool operator()(IntensityType left, Peak1D const & right) const
204 {
205 return left < right.getIntensity();
206 }
207
208 inline bool operator()(IntensityType left, IntensityType right) const
209 {
210 return left < right;
211 }
212
213 };
214
216 struct MZLess :
217 public std::binary_function<Peak1D, Peak1D, bool>
218 {
219 inline bool operator()(const Peak1D & left, const Peak1D & right) const
220 {
221 return left.getMZ() < right.getMZ();
222 }
223
224 inline bool operator()(Peak1D const & left, CoordinateType right) const
225 {
226 return left.getMZ() < right;
227 }
228
229 inline bool operator()(CoordinateType left, Peak1D const & right) const
230 {
231 return left < right.getMZ();
232 }
233
234 inline bool operator()(CoordinateType left, CoordinateType right) const
235 {
236 return left < right;
237 }
238
239 };
240
242 struct PositionLess :
243 public std::binary_function<Peak1D, Peak1D, bool>
244 {
245 inline bool operator()(const Peak1D & left, const Peak1D & right) const
246 {
247 return left.getPosition() < right.getPosition();
248 }
249
250 inline bool operator()(const Peak1D & left, const PositionType & right) const
251 {
252 return left.getPosition() < right;
253 }
254
255 inline bool operator()(const PositionType & left, const Peak1D & right) const
256 {
257 return left < right.getPosition();
258 }
259
260 inline bool operator()(const PositionType & left, const PositionType & right) const
261 {
262 return left < right;
263 }
264
265 };
267
268 protected:
270 PositionType position_;
272 IntensityType intensity_;
273 };
274
276 OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak1D & point);
277
278 } // namespace OpenMS
279
OpenMS::Peak1D::getPosition
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak1D.h:139
OpenMS::Peak1D::IntensityLess::operator()
bool operator()(IntensityType left, Peak1D const &right) const
Definition: Peak1D.h:203
OpenMS::Peak1D::getIntensity
IntensityType getIntensity() const
Definition: Peak1D.h:110
OpenMS::Peak1D::operator==
bool operator==(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:170
OpenMS::Peak1D::MZLess::operator()
bool operator()(CoordinateType left, Peak1D const &right) const
Definition: Peak1D.h:229
OpenMS::Peak1D::Peak1D
Peak1D(const Peak1D &p)
Copy constructor.
Definition: Peak1D.h:85
OpenMS::Peak1D::intensity_
IntensityType intensity_
The data point intensity.
Definition: Peak1D.h:272
OpenMS::Peak1D::IntensityLess::operator()
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak1D.h:208
OpenMS::Peak1D::IntensityType
float IntensityType
Intensity type.
Definition: Peak1D.h:63
OpenMS::Peak1D::setIntensity
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:112
seqan::position
Size< TNeedle >::Type position(const PatternAuxData< TNeedle > &dh)
Definition: AhoCorasickAmbiguous.h:561
OpenMS::Peak1D::getMZ
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:115
OpenMS::Peak1D::Peak1D
Peak1D()
Definition: Peak1D.h:73
OpenMS::Peak1D::setPosition
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:151
OpenMS::Peak1D::PositionLess::operator()
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:245
Types.h
OpenMS::Peak1D::PositionLess::operator()
bool operator()(const PositionType &left, const Peak1D &right) const
Definition: Peak1D.h:255
OpenMS::Peak1D::setMZ
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:121
OpenMS::Peak1D::PositionLess::operator()
bool operator()(const Peak1D &left, const PositionType &right) const
Definition: Peak1D.h:250
OpenMS::Peak1D::Peak1D
Peak1D(PositionType a, IntensityType b)
construct with position and intensity
Definition: Peak1D.h:79
OpenMS::Peak1D::position_
PositionType position_
The data point position.
Definition: Peak1D.h:270
OpenMS::Peak1D::PositionLess
Comparator by position. As this class has dimension 1, this is basically an alias for MZLess...
Definition: Peak1D.h:242
OpenMS::Peak1D::MZLess::operator()
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak1D.h:234
OpenMS::Peak1D
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
DPosition.h
OpenMS::operator<<
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Peak1D::operator=
Peak1D & operator=(const Peak1D &rhs)
Assignment operator.
Definition: Peak1D.h:159
OpenMS::Peak1D::MZLess
Comparator by m/z position.
Definition: Peak1D.h:216
OpenMS::Peak1D::PositionLess::operator()
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak1D.h:260
OpenMS::Peak1D::operator!=
bool operator!=(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:179
OpenMS::Peak1D::IntensityLess::operator()
bool operator()(Peak1D const &left, IntensityType right) const
Definition: Peak1D.h:198
OpenMS::Peak1D::CoordinateType
double CoordinateType
Coordinate type.
Definition: Peak1D.h:67
OpenMS::Peak1D::PositionType
DPosition< 1 > PositionType
Position type.
Definition: Peak1D.h:65
OpenMS::DPosition< 1 >
OpenMS::Peak1D::MZLess::operator()
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:219
double
float
OpenMS::Peak1D::IntensityLess::operator()
bool operator()(Peak1D const &left, Peak1D const &right) const
Definition: Peak1D.h:193
OpenMS::Peak1D::getPosition
PositionType & getPosition()
Mutable access to the position.
Definition: Peak1D.h:145
OpenMS::Peak1D::MZLess::operator()
bool operator()(Peak1D const &left, CoordinateType right) const
Definition: Peak1D.h:224
KDTree::operator==
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
OpenMS::Peak1D::setPos
void setPos(CoordinateType pos)
Alias for setMZ()
Definition: Peak1D.h:133
OpenMS::Peak1D::getPos
CoordinateType getPos() const
Alias for getMZ()
Definition: Peak1D.h:127