OpenMS
Peak1D.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- 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 
11 #include <OpenMS/CONCEPT/Types.h>
13 
14 #include <iosfwd>
15 
16 namespace OpenMS
17 {
18 
27  class OPENMS_DLLAPI Peak1D
28  {
29 public:
30 
34  enum {DIMENSION = 1};
36  using IntensityType = float;
40  using CoordinateType = double;
42 
46  inline Peak1D() = default;
47 
50  position_(a),
51  intensity_(b)
52  {}
53 
55  Peak1D(const Peak1D & p) = default;
56 
57  Peak1D(Peak1D&&) noexcept = default;
58 
60  Peak1D& operator=(const Peak1D& rhs) = default;
61 
63  Peak1D& operator=(Peak1D&&) noexcept = default;
64 
73  ~Peak1D() = default;
74 
76 
82  inline IntensityType getIntensity() const { return intensity_; }
84  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
85 
87  inline CoordinateType getMZ() const
88  {
89  return position_[0];
90  }
91 
93  inline void setMZ(CoordinateType mz)
94  {
95  position_[0] = mz;
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 
131  bool operator==(const Peak1D & rhs) const
132  {
133 #pragma clang diagnostic push
134 #pragma clang diagnostic ignored "-Wfloat-equal"
135  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
136 #pragma clang diagnostic pop
137  }
138 
140  bool operator!=(const Peak1D & rhs) const
141  {
142  return !(operator==(rhs));
143  }
144 
152  {
153  inline bool operator()(Peak1D const & left, Peak1D const & right) const
154  {
155  return left.getIntensity() < right.getIntensity();
156  }
157 
158  inline bool operator()(Peak1D const & left, IntensityType right) const
159  {
160  return left.getIntensity() < right;
161  }
162 
163  inline bool operator()(IntensityType left, Peak1D const & right) const
164  {
165  return left < right.getIntensity();
166  }
167 
168  inline bool operator()(IntensityType left, IntensityType right) const
169  {
170  return left < right;
171  }
172 
173  };
174 
176  struct MZLess
177  {
178  inline bool operator()(const Peak1D & left, const Peak1D & right) const
179  {
180  return left.getMZ() < right.getMZ();
181  }
182 
183  inline bool operator()(Peak1D const & left, CoordinateType right) const
184  {
185  return left.getMZ() < right;
186  }
187 
188  inline bool operator()(CoordinateType left, Peak1D const & right) const
189  {
190  return left < right.getMZ();
191  }
192 
193  inline bool operator()(CoordinateType left, CoordinateType right) const
194  {
195  return left < right;
196  }
197 
198  };
199 
202  {
203  inline bool operator()(const Peak1D & left, const Peak1D & right) const
204  {
205  return left.getPosition() < right.getPosition();
206  }
207 
208  inline bool operator()(const Peak1D & left, const PositionType & right) const
209  {
210  return left.getPosition() < right;
211  }
212 
213  inline bool operator()(const PositionType & left, const Peak1D & right) const
214  {
215  return left < right.getPosition();
216  }
217 
218  inline bool operator()(const PositionType & left, const PositionType & right) const
219  {
220  return left < right;
221  }
222 
223  };
225 
226 protected:
230  IntensityType intensity_ = 0.0;
231  };
232 
234  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak1D & point);
235 
236 } // namespace OpenMS
237 
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:28
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:87
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak1D.h:111
Peak1D()=default
double CoordinateType
Coordinate type.
Definition: Peak1D.h:40
bool operator!=(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:140
PositionType position_
The data point position.
Definition: Peak1D.h:228
Peak1D(Peak1D &&) noexcept=default
Peak1D(const Peak1D &p)=default
Copy constructor.
bool operator==(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:131
CoordinateType getPos() const
Alias for getMZ()
Definition: Peak1D.h:99
Peak1D(PositionType a, IntensityType b)
construct with position and intensity
Definition: Peak1D.h:49
IntensityType getIntensity() const
Definition: Peak1D.h:82
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:84
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:93
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:123
void setPos(CoordinateType pos)
Alias for setMZ()
Definition: Peak1D.h:105
IntensityType intensity_
The data point intensity.
Definition: Peak1D.h:230
PositionType & getPosition()
Mutable access to the position.
Definition: Peak1D.h:117
float IntensityType
Intensity type.
Definition: Peak1D.h:36
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)
Definition: Peak1D.h:152
bool operator()(IntensityType left, Peak1D const &right) const
Definition: Peak1D.h:163
bool operator()(Peak1D const &left, IntensityType right) const
Definition: Peak1D.h:158
bool operator()(Peak1D const &left, Peak1D const &right) const
Definition: Peak1D.h:153
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak1D.h:168
Comparator by m/z position.
Definition: Peak1D.h:177
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak1D.h:193
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:178
bool operator()(CoordinateType left, Peak1D const &right) const
Definition: Peak1D.h:188
bool operator()(Peak1D const &left, CoordinateType right) const
Definition: Peak1D.h:183
Comparator by position. As this class has dimension 1, this is basically an alias for MZLess.
Definition: Peak1D.h:202
bool operator()(const Peak1D &left, const PositionType &right) const
Definition: Peak1D.h:208
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:203
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak1D.h:218
bool operator()(const PositionType &left, const Peak1D &right) const
Definition: Peak1D.h:213