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-2013.
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: Stephan Aiche$
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 <ostream>
42 #include <functional>
43 
44 namespace OpenMS
45 {
46 
55  class OPENMS_DLLAPI Peak1D
56  {
57 public:
58 
62  enum {DIMENSION = 1};
70 
74  inline Peak1D() :
75  position_(),
76  intensity_(0)
77  {}
78 
80  inline Peak1D(const Peak1D & p) :
81  position_(p.position_),
82  intensity_(p.intensity_)
83  {}
84 
94  {}
95 
97 
101  inline IntensityType getIntensity() const { return intensity_; }
105  inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
106 
108  inline CoordinateType getMZ() const
109  {
110  return position_[0];
111  }
112 
114  inline void setMZ(CoordinateType mz)
115  {
116  position_[0] = mz;
117  }
118 
120  inline CoordinateType getPos() const
121  {
122  return position_[0];
123  }
124 
126  inline void setPos(CoordinateType pos)
127  {
128  position_[0] = pos;
129  }
130 
132  inline PositionType const & getPosition() const
133  {
134  return position_;
135  }
136 
139  {
140  return position_;
141  }
142 
144  inline void setPosition(PositionType const & position)
145  {
146  position_ = position;
147  }
148 
150 
152  inline Peak1D & operator=(const Peak1D & rhs)
153  {
154  if (this == &rhs) return *this;
155 
156  intensity_ = rhs.intensity_;
157  position_ = rhs.position_;
158 
159  return *this;
160  }
161 
163  inline bool operator==(const Peak1D & rhs) const
164  {
165  return intensity_ == rhs.intensity_ && position_ == rhs.position_;
166  }
167 
169  inline bool operator!=(const Peak1D & rhs) const
170  {
171  return !(operator==(rhs));
172  }
173 
178  struct IntensityLess :
181  std::binary_function<Peak1D, Peak1D, bool>
182  {
183  inline bool operator()(Peak1D const & left, Peak1D const & right) const
184  {
185  return left.getIntensity() < right.getIntensity();
186  }
187 
188  inline bool operator()(Peak1D const & left, IntensityType right) const
189  {
190  return left.getIntensity() < right;
191  }
192 
193  inline bool operator()(IntensityType left, Peak1D const & right) const
194  {
195  return left < right.getIntensity();
196  }
197 
198  inline bool operator()(IntensityType left, IntensityType right) const
199  {
200  return left < right;
201  }
202 
203  };
204 
206  struct MZLess :
207  public std::binary_function<Peak1D, Peak1D, bool>
208  {
209  inline bool operator()(const Peak1D & left, const Peak1D & right) const
210  {
211  return left.getMZ() < right.getMZ();
212  }
213 
214  inline bool operator()(Peak1D const & left, CoordinateType right) const
215  {
216  return left.getMZ() < right;
217  }
218 
219  inline bool operator()(CoordinateType left, Peak1D const & right) const
220  {
221  return left < right.getMZ();
222  }
223 
224  inline bool operator()(CoordinateType left, CoordinateType right) const
225  {
226  return left < right;
227  }
228 
229  };
230 
232  struct PositionLess :
233  public std::binary_function<Peak1D, Peak1D, bool>
234  {
235  inline bool operator()(const Peak1D & left, const Peak1D & right) const
236  {
237  return left.getPosition() < right.getPosition();
238  }
239 
240  inline bool operator()(const Peak1D & left, const PositionType & right) const
241  {
242  return left.getPosition() < right;
243  }
244 
245  inline bool operator()(const PositionType & left, const Peak1D & right) const
246  {
247  return left < right.getPosition();
248  }
249 
250  inline bool operator()(const PositionType & left, const PositionType & right) const
251  {
252  return left < right;
253  }
254 
255  };
257 
258 protected:
263  };
264 
266  OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const Peak1D & point);
267 
268 } // namespace OpenMS
269 
270 #endif // OPENMS_KERNEL_PEAK1D_H
Peak1D & operator=(const Peak1D &rhs)
Assignment operator.
Definition: Peak1D.h:152
float Real
Real type.
Definition: Types.h:109
bool operator()(const Peak1D &left, const Peak1D &right) const
Definition: Peak1D.h:235
PositionType & getPosition()
Mutable access to the position.
Definition: Peak1D.h:138
IntensityType getIntensity() const
Definition: Peak1D.h:103
PositionType const & getPosition() const
Non-mutable access to the position.
Definition: Peak1D.h:132
bool operator()(IntensityType left, Peak1D const &right) const
Definition: Peak1D.h:193
bool operator()(IntensityType left, IntensityType right) const
Definition: Peak1D.h:198
CoordinateType getMZ() const
Non-mutable access to m/z.
Definition: Peak1D.h:108
std::ostream & operator<<(std::ostream &os, const ItraqQuantifier::ItraqQuantifierStats &stats)
bool operator()(const PositionType &left, const Peak1D &right) const
Definition: Peak1D.h:245
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:114
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:105
bool operator()(const Peak1D &left, const Peak1D &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:232
bool operator()(Peak1D const &left, CoordinateType right) const
Definition: Peak1D.h:214
bool operator==(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:163
Peak1D()
Definition: Peak1D.h:74
bool operator()(const PositionType &left, const PositionType &right) const
Definition: Peak1D.h:250
PositionType position_
The data point position.
Definition: Peak1D.h:260
Real IntensityType
Intensity type.
Definition: Peak1D.h:64
void setPosition(PositionType const &position)
Mutable access to the position.
Definition: Peak1D.h:144
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:55
Peak1D(const Peak1D &p)
Copy constructor.
Definition: Peak1D.h:80
CoordinateType getPos() const
Alias for getMZ()
Definition: Peak1D.h:120
DoubleReal CoordinateType
Coordinate type.
Definition: Peak1D.h:68
Comparator that allows to compare the indices of two peaks by their intensity.
Definition: FeaFiModule.h:56
Comparator by m/z position.
Definition: Peak1D.h:206
bool operator()(Peak1D const &left, IntensityType right) const
Definition: Peak1D.h:188
bool operator!=(const Peak1D &rhs) const
Equality operator.
Definition: Peak1D.h:169
bool operator()(Peak1D const &left, Peak1D const &right) const
Definition: Peak1D.h:183
bool operator()(CoordinateType left, Peak1D const &right) const
Definition: Peak1D.h:219
IntensityType intensity_
The data point intensity.
Definition: Peak1D.h:262
bool operator()(const Peak1D &left, const PositionType &right) const
Definition: Peak1D.h:240
void setPos(CoordinateType pos)
Alias for setMZ()
Definition: Peak1D.h:126
bool operator()(CoordinateType left, CoordinateType right) const
Definition: Peak1D.h:224
DPosition< 1 > PositionType
Position type.
Definition: Peak1D.h:66
~Peak1D()
Destructor.
Definition: Peak1D.h:93

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:19 using doxygen 1.8.5