Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

ChromatogramPeak.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Andreas Bertsch $
00032 // $Authors: Andreas Bertsch $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_KERNEL_CHROMATOGRAMPEAK_H
00036 #define OPENMS_KERNEL_CHROMATOGRAMPEAK_H
00037 
00038 #include <OpenMS/CONCEPT/Types.h>
00039 #include <OpenMS/DATASTRUCTURES/DPosition.h>
00040 
00041 #include <ostream>
00042 #include <functional>
00043 
00044 namespace OpenMS
00045 {
00046 
00055   class OPENMS_DLLAPI ChromatogramPeak
00056   {
00057 public:
00062 
00063     enum {DIMENSION = 1};
00065     typedef DoubleReal IntensityType;
00067     typedef DPosition<1> PositionType;
00069     typedef DoubleReal CoordinateType;
00071 
00076 
00077     inline ChromatogramPeak() :
00078       position_(),
00079       intensity_(0)
00080     {}
00081 
00083     inline ChromatogramPeak(const ChromatogramPeak & p) :
00084       position_(p.position_),
00085       intensity_(p.intensity_)
00086     {}
00087 
00096     ~ChromatogramPeak()
00097     {}
00099 
00104 
00106     inline IntensityType getIntensity() const { return intensity_; }
00108     inline void setIntensity(IntensityType intensity) { intensity_ = intensity; }
00109 
00111     inline CoordinateType getRT() const
00112     {
00113       return position_[0];
00114     }
00115 
00117     inline void setRT(CoordinateType rt)
00118     {
00119       position_[0] = rt;
00120     }
00121 
00123     inline CoordinateType getPos() const
00124     {
00125       return position_[0];
00126     }
00127 
00129     inline void setPos(CoordinateType pos)
00130     {
00131       position_[0] = pos;
00132     }
00133 
00135     inline CoordinateType getMZ() const
00136     {
00137       return position_[0];
00138     }
00139 
00141     inline void setMZ(CoordinateType rt)
00142     {
00143       position_[0] = rt;
00144     }
00145 
00147     inline PositionType const & getPosition() const
00148     {
00149       return position_;
00150     }
00151 
00153     inline PositionType & getPosition()
00154     {
00155       return position_;
00156     }
00157 
00159     inline void setPosition(PositionType const & position)
00160     {
00161       position_ = position;
00162     }
00163 
00165 
00167     inline ChromatogramPeak & operator=(const ChromatogramPeak & rhs)
00168     {
00169       if (this == &rhs) return *this;
00170 
00171       intensity_ = rhs.intensity_;
00172       position_ = rhs.position_;
00173 
00174       return *this;
00175     }
00176 
00178     inline bool operator==(const ChromatogramPeak & rhs) const
00179     {
00180       return intensity_ == rhs.intensity_ && position_ == rhs.position_;
00181     }
00182 
00184     inline bool operator!=(const ChromatogramPeak & rhs) const
00185     {
00186       return !(operator==(rhs));
00187     }
00188 
00196 
00197     struct IntensityLess :
00198       std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
00199     {
00200       inline bool operator()(ChromatogramPeak const & left, ChromatogramPeak const & right) const
00201       {
00202         return left.getIntensity() < right.getIntensity();
00203       }
00204 
00205       inline bool operator()(ChromatogramPeak const & left, IntensityType right) const
00206       {
00207         return left.getIntensity() < right;
00208       }
00209 
00210       inline bool operator()(IntensityType left, ChromatogramPeak const & right) const
00211       {
00212         return left < right.getIntensity();
00213       }
00214 
00215       inline bool operator()(IntensityType left, IntensityType right) const
00216       {
00217         return left < right;
00218       }
00219 
00220     };
00221 
00223     struct RTLess :
00224       public std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
00225     {
00226       inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
00227       {
00228         return left.getRT() < right.getPos();
00229       }
00230 
00231       inline bool operator()(ChromatogramPeak const & left, CoordinateType right) const
00232       {
00233         return left.getRT() < right;
00234       }
00235 
00236       inline bool operator()(CoordinateType left, ChromatogramPeak const & right) const
00237       {
00238         return left < right.getRT();
00239       }
00240 
00241       inline bool operator()(CoordinateType left, CoordinateType right) const
00242       {
00243         return left < right;
00244       }
00245 
00246     };
00247 
00249     struct PositionLess :
00250       public std::binary_function<ChromatogramPeak, ChromatogramPeak, bool>
00251     {
00252       inline bool operator()(const ChromatogramPeak & left, const ChromatogramPeak & right) const
00253       {
00254         return left.getPosition() < right.getPosition();
00255       }
00256 
00257       inline bool operator()(const ChromatogramPeak & left, const PositionType & right) const
00258       {
00259         return left.getPosition() < right;
00260       }
00261 
00262       inline bool operator()(const PositionType & left, const ChromatogramPeak & right) const
00263       {
00264         return left < right.getPosition();
00265       }
00266 
00267       inline bool operator()(const PositionType & left, const PositionType & right) const
00268       {
00269         return left < right;
00270       }
00271     };
00273 protected:
00275     PositionType    position_;
00277     IntensityType intensity_;
00278   };
00279 
00281   OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os, const ChromatogramPeak & point);
00282 
00283 } // namespace OpenMS
00284 
00285 #endif // OPENMS_KERNEL_CHROMATOGRAMPEAK_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:37 using doxygen 1.7.1