All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
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 = default;
132 
134  bool operator!=(const Peak1D & rhs) const
135  {
136  return !(operator==(rhs));
137  }
138 
146  {
147  inline bool operator()(Peak1D const & left, Peak1D const & right) const
148  {
149  return left.getIntensity() < right.getIntensity();
150  }
151 
152  inline bool operator()(Peak1D const & left, IntensityType right) const
153  {
154  return left.getIntensity() < right;
155  }
156 
157  inline bool operator()(IntensityType left, Peak1D const & right) const
158  {
159  return left < right.getIntensity();
160  }
161 
162  inline bool operator()(IntensityType left, IntensityType right) const
163  {
164  return left < right;
165  }
166 
167  };
168 
170  struct MZLess
171  {
172  inline bool operator()(const Peak1D & left, const Peak1D & right) const
173  {
174  return left.getMZ() < right.getMZ();
175  }
176 
177  inline bool operator()(Peak1D const & left, CoordinateType right) const
178  {
179  return left.getMZ() < right;
180  }
181 
182  inline bool operator()(CoordinateType left, Peak1D const & right) const
183  {
184  return left < right.getMZ();
185  }
186 
187  inline bool operator()(CoordinateType left, CoordinateType right) const
188  {
189  return left < right;
190  }
191 
192  };
193 
196  {
197  inline bool operator()(const Peak1D & left, const Peak1D & right) const
198  {
199  return left.getPosition() < right.getPosition();
200  }
201 
202  inline bool operator()(const Peak1D & left, const PositionType & right) const
203  {
204  return left.getPosition() < right;
205  }
206 
207  inline bool operator()(const PositionType & left, const Peak1D & right) const
208  {
209  return left < right.getPosition();
210  }
211 
212  inline bool operator()(const PositionType & left, const PositionType & right) const
213  {
214  return left < right;
215  }
216 
217  };
219 
220 protected:
224  IntensityType intensity_ = 0.0;
225  };
226 
228  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak1D & point);
229 
230 } // namespace OpenMS
231 
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:134
PositionType position_
The data point position.
Definition: Peak1D.h:222
Peak1D(Peak1D &&) noexcept=default
Peak1D(const Peak1D &p)=default
Copy constructor.
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
bool operator==(const Peak1D &rhs) const =default
Equality operator.
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
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:146
bool operator()(IntensityType left, Peak1D const &right) const
Definition: Peak1D.h:157
bool operator()(Peak1D const &left, IntensityType right) const
Definition: Peak1D.h:152
bool operator()(Peak1D const &left, Peak1D const &right) const
Definition: Peak1D.h:147
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak1D.h:162
Comparator by m/z position.
Definition: Peak1D.h:171
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak1D.h:187
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:172
bool operator()(CoordinateType left, Peak1D const &right) const
Definition: Peak1D.h:182
bool operator()(Peak1D const &left, CoordinateType right) const
Definition: Peak1D.h:177
Comparator by position. As this class has dimension 1, this is basically an alias for MZLess.
Definition: Peak1D.h:196
bool operator()(const Peak1D &left, const PositionType &right) const
Definition: Peak1D.h:202
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:197
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak1D.h:212
bool operator()(const PositionType &left, const Peak1D &right) const
Definition: Peak1D.h:207