Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
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-2017.
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 #ifndef OPENMS_KERNEL_PEAK1D_H
36 #define OPENMS_KERNEL_PEAK1D_H
37 
38 #include <OpenMS/CONCEPT/Types.h>
40 
41 #include <iosfwd>
42 #include <functional>
43 
44 namespace OpenMS
45 {
46 
55  class OPENMS_DLLAPI Peak1D
56  {
57 public:
58 
62  enum {DIMENSION = 1};
64  typedef float IntensityType;
68  typedef double CoordinateType;
70 
74  inline Peak1D() :
75  position_(),
76  intensity_(0)
77  {}
78 
80  inline Peak1D(PositionType a, IntensityType b) :
81  position_(a),
82  intensity_(b)
83  {}
84 
86  inline Peak1D(const Peak1D & p) :
87  position_(p.position_),
88  intensity_(p.intensity_)
89  {}
90 
100  {}
101 
103 
107  inline IntensityType getIntensity() const { return intensity_; }
111  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
112 
114  inline CoordinateType getMZ() const
115  {
116  return position_[0];
117  }
118 
120  inline void setMZ(CoordinateType mz)
121  {
122  position_[0] = mz;
123  }
124 
126  inline CoordinateType getPos() const
127  {
128  return position_[0];
129  }
130 
132  inline void setPos(CoordinateType pos)
133  {
134  position_[0] = pos;
135  }
136 
138  inline PositionType const & getPosition() const
139  {
140  return position_;
141  }
142 
144  inline PositionType & getPosition()
145  {
146  return position_;
147  }
148 
150  inline void setPosition(PositionType const & position)
151  {
152  position_ = position;
153  }
154 
156 
158  inline Peak1D & operator=(const Peak1D & rhs)
159  {
160  if (this == &rhs) return *this;
161 
162  intensity_ = rhs.intensity_;
163  position_ = rhs.position_;
164 
165  return *this;
166  }
167 
169  inline bool operator==(const Peak1D & rhs) const
170  {
171 #pragma clang diagnostic push
172 #pragma clang diagnostic ignored "-Wfloat-equal"
173  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
174 #pragma clang diagnostic pop
175  }
176 
178  inline bool operator!=(const Peak1D & rhs) const
179  {
180  return !(operator==(rhs));
181  }
182 
187  struct IntensityLess :
190  std::binary_function<Peak1D, Peak1D, bool>
191  {
192  inline bool operator()(Peak1D const & left, Peak1D const & right) const
193  {
194  return left.getIntensity() < right.getIntensity();
195  }
196 
197  inline bool operator()(Peak1D const & left, IntensityType right) const
198  {
199  return left.getIntensity() < right;
200  }
201 
202  inline bool operator()(IntensityType left, Peak1D const & right) const
203  {
204  return left < right.getIntensity();
205  }
206 
207  inline bool operator()(IntensityType left, IntensityType right) const
208  {
209  return left < right;
210  }
211 
212  };
213 
215  struct MZLess :
216  public std::binary_function<Peak1D, Peak1D, bool>
217  {
218  inline bool operator()(const Peak1D & left, const Peak1D & right) const
219  {
220  return left.getMZ() < right.getMZ();
221  }
222 
223  inline bool operator()(Peak1D const & left, CoordinateType right) const
224  {
225  return left.getMZ() < right;
226  }
227 
228  inline bool operator()(CoordinateType left, Peak1D const & right) const
229  {
230  return left < right.getMZ();
231  }
232 
233  inline bool operator()(CoordinateType left, CoordinateType right) const
234  {
235  return left < right;
236  }
237 
238  };
239 
241  struct PositionLess :
242  public std::binary_function<Peak1D, Peak1D, bool>
243  {
244  inline bool operator()(const Peak1D & left, const Peak1D & right) const
245  {
246  return left.getPosition() < right.getPosition();
247  }
248 
249  inline bool operator()(const Peak1D & left, const PositionType & right) const
250  {
251  return left.getPosition() < right;
252  }
253 
254  inline bool operator()(const PositionType & left, const Peak1D & right) const
255  {
256  return left < right.getPosition();
257  }
258 
259  inline bool operator()(const PositionType & left, const PositionType & right) const
260  {
261  return left < right;
262  }
263 
264  };
266 
267 protected:
269  PositionType position_;
271  IntensityType intensity_;
272  };
273 
275  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak1D & point);
276 
277 } // namespace OpenMS
278 
279 #endif // OPENMS_KERNEL_PEAK1D_H
Peak1D & operator=(const Peak1D &rhs)
Assignment operator.
Definition: Peak1D.h:158
bool operator()(Peak1D const &left, IntensityType right) const
Definition: Peak1D.h:197
bool operator()(Peak1D const &left, CoordinateType right) const
Definition: Peak1D.h:223
PositionType & getPosition()
Mutable access to the position.
Definition: Peak1D.h:144
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:114
bool operator()(const Peak1D &left, const PositionType &right) const
Definition: Peak1D.h:249
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:218
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak1D.h:138
bool operator==(_Iterator< _Val, _Ref, _Ptr > const &, _Iterator< _Val, _Ref, _Ptr > const &)
Definition: KDTree.h:806
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak1D.h:207
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
bool operator==(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:169
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:120
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:111
bool operator!=(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:178
Comparator by position. As this class has dimension 1, this is basically an alias for MZLess...
Definition: Peak1D.h:241
bool operator()(const PositionType &left, const Peak1D &right) const
Definition: Peak1D.h:254
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak1D.h:259
Peak1D()
Definition: Peak1D.h:74
double CoordinateType
Coordinate type.
Definition: Peak1D.h:68
bool operator()(Peak1D const &left, Peak1D const &right) const
Definition: Peak1D.h:192
PositionType position_
The data point position.
Definition: Peak1D.h:269
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:150
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:55
std::ostream & operator<<(std::ostream &os, const AccurateMassSearchResult &amsr)
CoordinateType getPos() const
Alias for getMZ()
Definition: Peak1D.h:126
Peak1D(const Peak1D &p)
Copy constructor.
Definition: Peak1D.h:86
Comparator by m/z position.
Definition: Peak1D.h:215
Definition: Peak1D.h:189
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:244
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak1D.h:233
Peak1D(PositionType a, IntensityType b)
construct with position and intensity
Definition: Peak1D.h:80
bool operator()(CoordinateType left, Peak1D const &right) const
Definition: Peak1D.h:228
float IntensityType
Intensity type.
Definition: Peak1D.h:64
IntensityType intensity_
The data point intensity.
Definition: Peak1D.h:271
void setPos(CoordinateType pos)
Alias for setMZ()
Definition: Peak1D.h:132
bool operator()(IntensityType left, Peak1D const &right) const
Definition: Peak1D.h:202
DPosition< 1 > PositionType
Position type.
Definition: Peak1D.h:66
IntensityType getIntensity() const
Definition: Peak1D.h:109
~Peak1D()
Destructor.
Definition: Peak1D.h:99

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:03 using doxygen 1.8.13