OpenMS
MobilityPeak1D.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
11 #include <OpenMS/CONCEPT/Types.h>
13 #include <iosfwd>
14 
15 namespace OpenMS
16 {
24  class OPENMS_DLLAPI MobilityPeak1D
25  {
26  public:
30  enum{ DIMENSION = 1 };
32  using IntensityType = float;
36  using CoordinateType = double;
38 
42  MobilityPeak1D() = default;
43 
45  MobilityPeak1D(PositionType a, IntensityType b) : position_(a), intensity_(b)
46  {
47  }
48 
50  MobilityPeak1D(const MobilityPeak1D& p) = default;
51 
52  // Move constructor
53  MobilityPeak1D(MobilityPeak1D&&) noexcept = default;
54 
56  MobilityPeak1D& operator=(const MobilityPeak1D& rhs) = default;
57 
59  MobilityPeak1D& operator=(MobilityPeak1D&&) noexcept = default;
60 
61 
70  ~MobilityPeak1D() noexcept = default;
71 
73 
79  IntensityType getIntensity() const
80  {
81  return intensity_;
82  }
84  void setIntensity(IntensityType intensity)
85  {
86  intensity_ = intensity;
87  }
88 
90  inline CoordinateType getMobility() const
91  {
92  return position_[0];
93  }
94 
96  inline void setMobility(CoordinateType mobility)
97  {
98  position_[0] = mobility;
99  }
100 
102  inline CoordinateType getPos() const
103  {
104  return position_[0];
105  }
106 
108  inline void setPos(CoordinateType pos)
109  {
110  position_[0] = pos;
111  }
112 
114  inline PositionType const& getPosition() const
115  {
116  return position_;
117  }
118 
121  {
122  return position_;
123  }
124 
126  inline void setPosition(PositionType const& position)
127  {
128  position_ = position;
129  }
130 
132 
134  bool operator==(const MobilityPeak1D& rhs) const
135  {
136 #pragma clang diagnostic push
137 #pragma clang diagnostic ignored "-Wfloat-equal"
138  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
139 #pragma clang diagnostic pop
140  }
141 
143  bool operator!=(const MobilityPeak1D& rhs) const
144  {
145  return !(operator==(rhs));
146  }
147 
154  struct IntensityLess {
155  inline bool operator()(MobilityPeak1D const& left, MobilityPeak1D const& right) const
156  {
157  return left.getIntensity() < right.getIntensity();
158  }
159 
160  inline bool operator()(MobilityPeak1D const& left, IntensityType right) const
161  {
162  return left.getIntensity() < right;
163  }
164 
165  inline bool operator()(IntensityType left, MobilityPeak1D const& right) const
166  {
167  return left < right.getIntensity();
168  }
169 
170  inline bool operator()(IntensityType left, IntensityType right) const
171  {
172  return left < right;
173  }
174  };
175 
177  struct MobilityLess {
178  inline bool operator()(const MobilityPeak1D& left, const MobilityPeak1D& right) const
179  {
180  return left.getMobility() < right.getMobility();
181  }
182 
183  inline bool operator()(MobilityPeak1D const& left, CoordinateType right) const
184  {
185  return left.getMobility() < right;
186  }
187 
188  inline bool operator()(CoordinateType left, MobilityPeak1D const& right) const
189  {
190  return left < right.getMobility();
191  }
192 
193  inline bool operator()(CoordinateType left, CoordinateType right) const
194  {
195  return left < right;
196  }
197  };
198 
200  struct PositionLess {
201  inline bool operator()(const MobilityPeak1D& left, const MobilityPeak1D& right) const
202  {
203  return left.getPosition() < right.getPosition();
204  }
205 
206  inline bool operator()(const MobilityPeak1D& left, const PositionType& right) const
207  {
208  return left.getPosition() < right;
209  }
210 
211  inline bool operator()(const PositionType& left, const MobilityPeak1D& right) const
212  {
213  return left < right.getPosition();
214  }
215 
216  inline bool operator()(const PositionType& left, const PositionType& right) const
217  {
218  return left < right;
219  }
220  };
222 
223  protected:
225  PositionType position_{};
227  IntensityType intensity_ = 0.0;
228  };
229 
231  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const MobilityPeak1D& point);
232 
233 } // namespace OpenMS
A 1-dimensional raw data mobility point or peak. The unit (ms, 1/K_0, etc) is implicit.
Definition: MobilityPeak1D.h:25
bool operator==(const MobilityPeak1D &rhs) const
Equality operator.
Definition: MobilityPeak1D.h:134
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: MobilityPeak1D.h:114
double CoordinateType
Coordinate type.
Definition: MobilityPeak1D.h:36
bool operator!=(const MobilityPeak1D &rhs) const
Equality operator.
Definition: MobilityPeak1D.h:143
MobilityPeak1D(PositionType a, IntensityType b)
construct with position and intensity
Definition: MobilityPeak1D.h:45
PositionType position_
The data point position.
Definition: MobilityPeak1D.h:225
CoordinateType getPos() const
Alias for getMobility()
Definition: MobilityPeak1D.h:102
IntensityType getIntensity() const
Definition: MobilityPeak1D.h:79
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: MobilityPeak1D.h:84
void setMobility(CoordinateType mobility)
Mutable access to mobility.
Definition: MobilityPeak1D.h:96
CoordinateType getMobility() const
Non-mutable access to m/z.
Definition: MobilityPeak1D.h:90
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: MobilityPeak1D.h:126
void setPos(CoordinateType pos)
Alias for setMobility()
Definition: MobilityPeak1D.h:108
IntensityType intensity_
The data point intensity.
Definition: MobilityPeak1D.h:227
MobilityPeak1D(MobilityPeak1D &&) noexcept=default
MobilityPeak1D(const MobilityPeak1D &p)=default
Copy constructor.
PositionType & getPosition()
Mutable access to the position.
Definition: MobilityPeak1D.h:120
float IntensityType
Intensity type.
Definition: MobilityPeak1D.h:32
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Definition: MobilityPeak1D.h:154
bool operator()(MobilityPeak1D const &left, MobilityPeak1D const &right) const
Definition: MobilityPeak1D.h:155
bool operator()(MobilityPeak1D const &left, IntensityType right) const
Definition: MobilityPeak1D.h:160
bool operator()(IntensityType left, MobilityPeak1D const &right) const
Definition: MobilityPeak1D.h:165
bool operator()(IntensityType left, IntensityType right) const
Definition: MobilityPeak1D.h:170
Comparator by mobility position.
Definition: MobilityPeak1D.h:177
bool operator()(CoordinateType left, MobilityPeak1D const &right) const
Definition: MobilityPeak1D.h:188
bool operator()(CoordinateType left, CoordinateType right) const
Definition: MobilityPeak1D.h:193
bool operator()(const MobilityPeak1D &left, const MobilityPeak1D &right) const
Definition: MobilityPeak1D.h:178
bool operator()(MobilityPeak1D const &left, CoordinateType right) const
Definition: MobilityPeak1D.h:183
Comparator by position. As this class has dimension 1, this is basically an alias for MobilityLess.
Definition: MobilityPeak1D.h:200
bool operator()(const PositionType &left, const PositionType &right) const
Definition: MobilityPeak1D.h:216
bool operator()(const MobilityPeak1D &left, const MobilityPeak1D &right) const
Definition: MobilityPeak1D.h:201
bool operator()(const MobilityPeak1D &left, const PositionType &right) const
Definition: MobilityPeak1D.h:206
bool operator()(const PositionType &left, const MobilityPeak1D &right) const
Definition: MobilityPeak1D.h:211