OpenMS
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-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: Timo Sachsenberg$
32 // $Authors: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 #include <OpenMS/CONCEPT/Types.h>
39 
40 #include <iosfwd>
41 
42 namespace OpenMS
43 {
44 
53  class OPENMS_DLLAPI Peak1D
54  {
55 public:
56 
60  enum {DIMENSION = 1};
62  using IntensityType = float;
66  using CoordinateType = double;
68 
72  inline Peak1D() = default;
73 
76  position_(a),
77  intensity_(b)
78  {}
79 
81  Peak1D(const Peak1D & p) = default;
82 
83  Peak1D(Peak1D&&) noexcept = default;
84 
86  Peak1D& operator=(const Peak1D& rhs) = default;
87 
89  Peak1D& operator=(Peak1D&&) noexcept = default;
90 
99  ~Peak1D() = default;
100 
102 
108  inline IntensityType getIntensity() const { return intensity_; }
110  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
111 
113  inline CoordinateType getMZ() const
114  {
115  return position_[0];
116  }
117 
119  inline void setMZ(CoordinateType mz)
120  {
121  position_[0] = mz;
122  }
123 
125  inline CoordinateType getPos() const
126  {
127  return position_[0];
128  }
129 
131  inline void setPos(CoordinateType pos)
132  {
133  position_[0] = pos;
134  }
135 
137  inline PositionType const & getPosition() const
138  {
139  return position_;
140  }
141 
144  {
145  return position_;
146  }
147 
149  inline void setPosition(PositionType const & position)
150  {
151  position_ = position;
152  }
153 
155 
157  bool operator==(const Peak1D & rhs) const
158  {
159 #pragma clang diagnostic push
160 #pragma clang diagnostic ignored "-Wfloat-equal"
161  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
162 #pragma clang diagnostic pop
163  }
164 
166  bool operator!=(const Peak1D & rhs) const
167  {
168  return !(operator==(rhs));
169  }
170 
178  {
179  inline bool operator()(Peak1D const & left, Peak1D const & right) const
180  {
181  return left.getIntensity() < right.getIntensity();
182  }
183 
184  inline bool operator()(Peak1D const & left, IntensityType right) const
185  {
186  return left.getIntensity() < right;
187  }
188 
189  inline bool operator()(IntensityType left, Peak1D const & right) const
190  {
191  return left < right.getIntensity();
192  }
193 
194  inline bool operator()(IntensityType left, IntensityType right) const
195  {
196  return left < right;
197  }
198 
199  };
200 
202  struct MZLess
203  {
204  inline bool operator()(const Peak1D & left, const Peak1D & right) const
205  {
206  return left.getMZ() < right.getMZ();
207  }
208 
209  inline bool operator()(Peak1D const & left, CoordinateType right) const
210  {
211  return left.getMZ() < right;
212  }
213 
214  inline bool operator()(CoordinateType left, Peak1D const & right) const
215  {
216  return left < right.getMZ();
217  }
218 
219  inline bool operator()(CoordinateType left, CoordinateType right) const
220  {
221  return left < right;
222  }
223 
224  };
225 
228  {
229  inline bool operator()(const Peak1D & left, const Peak1D & right) const
230  {
231  return left.getPosition() < right.getPosition();
232  }
233 
234  inline bool operator()(const Peak1D & left, const PositionType & right) const
235  {
236  return left.getPosition() < right;
237  }
238 
239  inline bool operator()(const PositionType & left, const Peak1D & right) const
240  {
241  return left < right.getPosition();
242  }
243 
244  inline bool operator()(const PositionType & left, const PositionType & right) const
245  {
246  return left < right;
247  }
248 
249  };
251 
252 protected:
256  IntensityType intensity_ = 0.0;
257  };
258 
260  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak1D & point);
261 
262 } // namespace OpenMS
263 
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:113
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak1D.h:137
Peak1D()=default
double CoordinateType
Coordinate type.
Definition: Peak1D.h:66
bool operator!=(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:166
PositionType position_
The data point position.
Definition: Peak1D.h:254
Peak1D(Peak1D &&) noexcept=default
Peak1D(const Peak1D &p)=default
Copy constructor.
bool operator==(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:157
CoordinateType getPos() const
Alias for getMZ()
Definition: Peak1D.h:125
Peak1D(PositionType a, IntensityType b)
construct with position and intensity
Definition: Peak1D.h:75
IntensityType getIntensity() const
Definition: Peak1D.h:108
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:110
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:119
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:149
void setPos(CoordinateType pos)
Alias for setMZ()
Definition: Peak1D.h:131
IntensityType intensity_
The data point intensity.
Definition: Peak1D.h:256
PositionType & getPosition()
Mutable access to the position.
Definition: Peak1D.h:143
float IntensityType
Intensity type.
Definition: Peak1D.h:62
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: Peak1D.h:178
bool operator()(IntensityType left, Peak1D const &right) const
Definition: Peak1D.h:189
bool operator()(Peak1D const &left, IntensityType right) const
Definition: Peak1D.h:184
bool operator()(Peak1D const &left, Peak1D const &right) const
Definition: Peak1D.h:179
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak1D.h:194
Comparator by m/z position.
Definition: Peak1D.h:203
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak1D.h:219
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:204
bool operator()(CoordinateType left, Peak1D const &right) const
Definition: Peak1D.h:214
bool operator()(Peak1D const &left, CoordinateType right) const
Definition: Peak1D.h:209
Comparator by position. As this class has dimension 1, this is basically an alias for MZLess.
Definition: Peak1D.h:228
bool operator()(const Peak1D &left, const PositionType &right) const
Definition: Peak1D.h:234
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:229
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak1D.h:244
bool operator()(const PositionType &left, const Peak1D &right) const
Definition: Peak1D.h:239