OpenMS  2.8.0
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-2021.
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  typedef float IntensityType;
66  typedef double CoordinateType;
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 
93  ~Peak1D() = default;
94 
96 
102  inline IntensityType getIntensity() const { return intensity_; }
104  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
105 
107  inline CoordinateType getMZ() const
108  {
109  return position_[0];
110  }
111 
113  inline void setMZ(CoordinateType mz)
114  {
115  position_[0] = mz;
116  }
117 
119  inline CoordinateType getPos() const
120  {
121  return position_[0];
122  }
123 
125  inline void setPos(CoordinateType pos)
126  {
127  position_[0] = pos;
128  }
129 
131  inline PositionType const & getPosition() const
132  {
133  return position_;
134  }
135 
138  {
139  return position_;
140  }
141 
143  inline void setPosition(PositionType const & position)
144  {
145  position_ = position;
146  }
147 
149 
151  Peak1D & operator=(const Peak1D & rhs) = default;
152 
154  bool operator==(const Peak1D & rhs) const
155  {
156 #pragma clang diagnostic push
157 #pragma clang diagnostic ignored "-Wfloat-equal"
158  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
159 #pragma clang diagnostic pop
160  }
161 
163  bool operator!=(const Peak1D & rhs) const
164  {
165  return !(operator==(rhs));
166  }
167 
175  {
176  inline bool operator()(Peak1D const & left, Peak1D const & right) const
177  {
178  return left.getIntensity() < right.getIntensity();
179  }
180 
181  inline bool operator()(Peak1D const & left, IntensityType right) const
182  {
183  return left.getIntensity() < right;
184  }
185 
186  inline bool operator()(IntensityType left, Peak1D const & right) const
187  {
188  return left < right.getIntensity();
189  }
190 
191  inline bool operator()(IntensityType left, IntensityType right) const
192  {
193  return left < right;
194  }
195 
196  };
197 
199  struct MZLess
200  {
201  inline bool operator()(const Peak1D & left, const Peak1D & right) const
202  {
203  return left.getMZ() < right.getMZ();
204  }
205 
206  inline bool operator()(Peak1D const & left, CoordinateType right) const
207  {
208  return left.getMZ() < right;
209  }
210 
211  inline bool operator()(CoordinateType left, Peak1D const & right) const
212  {
213  return left < right.getMZ();
214  }
215 
216  inline bool operator()(CoordinateType left, CoordinateType right) const
217  {
218  return left < right;
219  }
220 
221  };
222 
225  {
226  inline bool operator()(const Peak1D & left, const Peak1D & right) const
227  {
228  return left.getPosition() < right.getPosition();
229  }
230 
231  inline bool operator()(const Peak1D & left, const PositionType & right) const
232  {
233  return left.getPosition() < right;
234  }
235 
236  inline bool operator()(const PositionType & left, const Peak1D & right) const
237  {
238  return left < right.getPosition();
239  }
240 
241  inline bool operator()(const PositionType & left, const PositionType & right) const
242  {
243  return left < right;
244  }
245 
246  };
248 
249 protected:
253  IntensityType intensity_ = 0.0;
254  };
255 
257  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak1D & point);
258 
259 } // namespace OpenMS
260 
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:54
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:107
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak1D.h:131
DPosition< 1 > PositionType
Position type.
Definition: Peak1D.h:64
Peak1D()=default
Peak1D & operator=(const Peak1D &rhs)=default
Assignment operator.
bool operator!=(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:163
float IntensityType
Intensity type.
Definition: Peak1D.h:62
double CoordinateType
Coordinate type.
Definition: Peak1D.h:66
PositionType position_
The data point position.
Definition: Peak1D.h:251
Peak1D(Peak1D &&) noexcept=default
Peak1D(const Peak1D &p)=default
Copy constructor.
bool operator==(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:154
CoordinateType getPos() const
Alias for getMZ()
Definition: Peak1D.h:119
Peak1D(PositionType a, IntensityType b)
construct with position and intensity
Definition: Peak1D.h:75
IntensityType getIntensity() const
Definition: Peak1D.h:102
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:104
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:113
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:143
void setPos(CoordinateType pos)
Alias for setMZ()
Definition: Peak1D.h:125
IntensityType intensity_
The data point intensity.
Definition: Peak1D.h:253
PositionType & getPosition()
Mutable access to the position.
Definition: Peak1D.h:137
bool operator==(const IDBoostGraph::ProteinGroup &lhs, const IDBoostGraph::ProteinGroup &rhs)
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
Definition: Peak1D.h:175
bool operator()(IntensityType left, Peak1D const &right) const
Definition: Peak1D.h:186
bool operator()(Peak1D const &left, IntensityType right) const
Definition: Peak1D.h:181
bool operator()(Peak1D const &left, Peak1D const &right) const
Definition: Peak1D.h:176
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak1D.h:191
Comparator by m/z position.
Definition: Peak1D.h:200
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak1D.h:216
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:201
bool operator()(CoordinateType left, Peak1D const &right) const
Definition: Peak1D.h:211
bool operator()(Peak1D const &left, CoordinateType right) const
Definition: Peak1D.h:206
Comparator by position. As this class has dimension 1, this is basically an alias for MZLess.
Definition: Peak1D.h:225
bool operator()(const Peak1D &left, const PositionType &right) const
Definition: Peak1D.h:231
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:226
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak1D.h:241
bool operator()(const PositionType &left, const Peak1D &right) const
Definition: Peak1D.h:236