OpenMS
MobilityPeak1D.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-2023.
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: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/CONCEPT/Types.h>
39 #include <iosfwd>
40 
41 namespace OpenMS
42 {
50  class OPENMS_DLLAPI MobilityPeak1D
51  {
52  public:
56  enum{ DIMENSION = 1 };
58  using IntensityType = float;
62  using CoordinateType = double;
64 
68  MobilityPeak1D() = default;
69 
71  MobilityPeak1D(PositionType a, IntensityType b) : position_(a), intensity_(b)
72  {
73  }
74 
76  MobilityPeak1D(const MobilityPeak1D& p) = default;
77 
78  // Move constructor
79  MobilityPeak1D(MobilityPeak1D&&) noexcept = default;
80 
82  MobilityPeak1D& operator=(const MobilityPeak1D& rhs) = default;
83 
85  MobilityPeak1D& operator=(MobilityPeak1D&&) noexcept = default;
86 
87 
96  ~MobilityPeak1D() noexcept = default;
97 
99 
105  IntensityType getIntensity() const
106  {
107  return intensity_;
108  }
110  void setIntensity(IntensityType intensity)
111  {
112  intensity_ = intensity;
113  }
114 
117  {
118  return position_[0];
119  }
120 
122  inline void setMobility(CoordinateType mobility)
123  {
124  position_[0] = mobility;
125  }
126 
128  inline CoordinateType getPos() const
129  {
130  return position_[0];
131  }
132 
134  inline void setPos(CoordinateType pos)
135  {
136  position_[0] = pos;
137  }
138 
140  inline PositionType const& getPosition() const
141  {
142  return position_;
143  }
144 
147  {
148  return position_;
149  }
150 
152  inline void setPosition(PositionType const& position)
153  {
154  position_ = position;
155  }
156 
158 
160  bool operator==(const MobilityPeak1D& rhs) const
161  {
162 #pragma clang diagnostic push
163 #pragma clang diagnostic ignored "-Wfloat-equal"
164  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
165 #pragma clang diagnostic pop
166  }
167 
169  bool operator!=(const MobilityPeak1D& rhs) const
170  {
171  return !(operator==(rhs));
172  }
173 
180  struct IntensityLess {
181  inline bool operator()(MobilityPeak1D const& left, MobilityPeak1D const& right) const
182  {
183  return left.getIntensity() < right.getIntensity();
184  }
185 
186  inline bool operator()(MobilityPeak1D const& left, IntensityType right) const
187  {
188  return left.getIntensity() < right;
189  }
190 
191  inline bool operator()(IntensityType left, MobilityPeak1D const& right) const
192  {
193  return left < right.getIntensity();
194  }
195 
196  inline bool operator()(IntensityType left, IntensityType right) const
197  {
198  return left < right;
199  }
200  };
201 
203  struct MobilityLess {
204  inline bool operator()(const MobilityPeak1D& left, const MobilityPeak1D& right) const
205  {
206  return left.getMobility() < right.getMobility();
207  }
208 
209  inline bool operator()(MobilityPeak1D const& left, CoordinateType right) const
210  {
211  return left.getMobility() < right;
212  }
213 
214  inline bool operator()(CoordinateType left, MobilityPeak1D const& right) const
215  {
216  return left < right.getMobility();
217  }
218 
219  inline bool operator()(CoordinateType left, CoordinateType right) const
220  {
221  return left < right;
222  }
223  };
224 
226  struct PositionLess {
227  inline bool operator()(const MobilityPeak1D& left, const MobilityPeak1D& right) const
228  {
229  return left.getPosition() < right.getPosition();
230  }
231 
232  inline bool operator()(const MobilityPeak1D& left, const PositionType& right) const
233  {
234  return left.getPosition() < right;
235  }
236 
237  inline bool operator()(const PositionType& left, const MobilityPeak1D& right) const
238  {
239  return left < right.getPosition();
240  }
241 
242  inline bool operator()(const PositionType& left, const PositionType& right) const
243  {
244  return left < right;
245  }
246  };
248 
249  protected:
251  PositionType position_{};
253  IntensityType intensity_ = 0.0;
254  };
255 
257  OPENMS_DLLAPI std::ostream& operator<<(std::ostream& os, const MobilityPeak1D& point);
258 
259 } // namespace OpenMS
A 1-dimensional raw data mobility point or peak. The unit (ms, 1/K_0, etc) is implicit.
Definition: MobilityPeak1D.h:51
bool operator==(const MobilityPeak1D &rhs) const
Equality operator.
Definition: MobilityPeak1D.h:160
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: MobilityPeak1D.h:140
double CoordinateType
Coordinate type.
Definition: MobilityPeak1D.h:62
bool operator!=(const MobilityPeak1D &rhs) const
Equality operator.
Definition: MobilityPeak1D.h:169
MobilityPeak1D(PositionType a, IntensityType b)
construct with position and intensity
Definition: MobilityPeak1D.h:71
PositionType position_
The data point position.
Definition: MobilityPeak1D.h:251
CoordinateType getPos() const
Alias for getMobility()
Definition: MobilityPeak1D.h:128
IntensityType getIntensity() const
Definition: MobilityPeak1D.h:105
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: MobilityPeak1D.h:110
void setMobility(CoordinateType mobility)
Mutable access to mobility.
Definition: MobilityPeak1D.h:122
CoordinateType getMobility() const
Non-mutable access to m/z.
Definition: MobilityPeak1D.h:116
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: MobilityPeak1D.h:152
void setPos(CoordinateType pos)
Alias for setMobility()
Definition: MobilityPeak1D.h:134
IntensityType intensity_
The data point intensity.
Definition: MobilityPeak1D.h:253
MobilityPeak1D(MobilityPeak1D &&) noexcept=default
MobilityPeak1D(const MobilityPeak1D &p)=default
Copy constructor.
PositionType & getPosition()
Mutable access to the position.
Definition: MobilityPeak1D.h:146
float IntensityType
Intensity type.
Definition: MobilityPeak1D.h:58
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Definition: MobilityPeak1D.h:180
bool operator()(MobilityPeak1D const &left, MobilityPeak1D const &right) const
Definition: MobilityPeak1D.h:181
bool operator()(MobilityPeak1D const &left, IntensityType right) const
Definition: MobilityPeak1D.h:186
bool operator()(IntensityType left, MobilityPeak1D const &right) const
Definition: MobilityPeak1D.h:191
bool operator()(IntensityType left, IntensityType right) const
Definition: MobilityPeak1D.h:196
Comparator by mobility position.
Definition: MobilityPeak1D.h:203
bool operator()(CoordinateType left, MobilityPeak1D const &right) const
Definition: MobilityPeak1D.h:214
bool operator()(CoordinateType left, CoordinateType right) const
Definition: MobilityPeak1D.h:219
bool operator()(const MobilityPeak1D &left, const MobilityPeak1D &right) const
Definition: MobilityPeak1D.h:204
bool operator()(MobilityPeak1D const &left, CoordinateType right) const
Definition: MobilityPeak1D.h:209
Comparator by position. As this class has dimension 1, this is basically an alias for MobilityLess.
Definition: MobilityPeak1D.h:226
bool operator()(const PositionType &left, const PositionType &right) const
Definition: MobilityPeak1D.h:242
bool operator()(const MobilityPeak1D &left, const MobilityPeak1D &right) const
Definition: MobilityPeak1D.h:227
bool operator()(const MobilityPeak1D &left, const PositionType &right) const
Definition: MobilityPeak1D.h:232
bool operator()(const PositionType &left, const MobilityPeak1D &right) const
Definition: MobilityPeak1D.h:237