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

MassTrace.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: Erhan Kenar $
00032 // $Authors: Erhan Kenar, Holger Franken $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_KERNEL_MASSTRACE_H
00036 #define OPENMS_KERNEL_MASSTRACE_H
00037 
00038 #include <OpenMS/KERNEL/Peak2D.h>
00039 #include <OpenMS/KERNEL/FeatureMap.h>
00040 
00041 
00042 #include <vector>
00043 #include <list>
00044 #include <map>
00045 
00046 
00047 namespace OpenMS
00048 {
00049   typedef Peak2D PeakType;
00050 
00059   class OPENMS_DLLAPI MassTrace
00060   {
00061 public:
00064 
00065     MassTrace();
00066 
00068     MassTrace(const std::list<PeakType> &, const DoubleReal & scan_time = 1.0);
00069 
00071     MassTrace(const std::vector<PeakType> &, const DoubleReal & scan_time = 1.0);
00072 
00074     ~MassTrace();
00075 
00077     MassTrace(const MassTrace &);
00078 
00080     MassTrace & operator=(const MassTrace &);
00081 
00083     PeakType & operator[](const Size & mt_idx);
00084     const PeakType & operator[](const Size & mt_idx) const;
00085 
00086 
00090     typedef std::vector<PeakType>::iterator iterator;
00091     typedef std::vector<PeakType>::const_iterator const_iterator;
00092     typedef std::vector<PeakType>::reverse_iterator reverse_iterator;
00093     typedef std::vector<PeakType>::const_reverse_iterator const_reverse_iterator;
00094 
00095     iterator begin()
00096     {
00097       return trace_peaks_.begin();
00098     }
00099 
00100     iterator end()
00101     {
00102       return trace_peaks_.end();
00103     }
00104 
00105     const_iterator begin() const
00106     {
00107       return trace_peaks_.begin();
00108     }
00109 
00110     const_iterator end() const
00111     {
00112       return trace_peaks_.end();
00113     }
00114 
00115     reverse_iterator rbegin()
00116     {
00117       return trace_peaks_.rbegin();
00118     }
00119 
00120     reverse_iterator rend()
00121     {
00122       return trace_peaks_.rend();
00123     }
00124 
00125     const_reverse_iterator rbegin() const
00126     {
00127       return trace_peaks_.rbegin();
00128     }
00129 
00130     const_reverse_iterator rend() const
00131     {
00132       return trace_peaks_.rend();
00133     }
00134 
00138 
00139     Size getSize() const
00140     {
00141       return trace_peaks_.size();
00142     }
00143 
00145     String getLabel() const
00146     {
00147       return label_;
00148     }
00149 
00151     void setLabel(const String & label)
00152     {
00153       label_ = label;
00154     }
00155 
00157     DoubleReal getCentroidMZ()
00158     {
00159       return centroid_mz_;
00160     }
00161 
00162     DoubleReal getCentroidMZ() const
00163     {
00164       return centroid_mz_;
00165     }
00166 
00168     DoubleReal getCentroidRT()
00169     {
00170       return centroid_rt_;
00171     }
00172 
00173     DoubleReal getCentroidRT() const
00174     {
00175       return centroid_rt_;
00176     }
00177 
00178     DoubleReal getCentroidSD()
00179     {
00180       return centroid_sd_;
00181     }
00182 
00183     DoubleReal getCentroidSD() const
00184     {
00185       return centroid_sd_;
00186     }
00187 
00188     void setCentroidSD(const DoubleReal & tmp_sd)
00189     {
00190       centroid_sd_ = tmp_sd;
00191     }
00192 
00193     DoubleReal getFWHM()
00194     {
00195         return fwhm_;
00196     }
00197 
00198     DoubleReal getFWHM() const
00199     {
00200         return fwhm_;
00201     }
00202 
00203     DoubleReal getTraceLength()
00204     {
00205         DoubleReal length(0.0);
00206 
00207         if (trace_peaks_.size() > 1)
00208         {
00209             length = std::fabs(trace_peaks_.rbegin()->getRT() - trace_peaks_.begin()->getRT());
00210         }
00211 
00212         return length;
00213     }
00214 
00215     DoubleReal getTraceLength() const
00216     {
00217         DoubleReal length(0.0);
00218 
00219         if (trace_peaks_.size() > 1)
00220         {
00221             length = std::fabs(trace_peaks_.rbegin()->getRT() - trace_peaks_.begin()->getRT());
00222         }
00223 
00224         return length;
00225     }
00226 
00227     std::pair<Size, Size> getFWHMborders()
00228     {
00229       return std::make_pair(fwhm_start_idx_, fwhm_end_idx_);
00230     }
00231 
00232     std::pair<Size, Size> getFWHMborders() const
00233     {
00234       return std::make_pair(fwhm_start_idx_, fwhm_end_idx_);
00235     }
00236 
00238     std::vector<DoubleReal> getSmoothedIntensities()
00239     {
00240       return smoothed_intensities_;
00241     }
00242 
00243     std::vector<DoubleReal> getSmoothedIntensities() const
00244     {
00245       return smoothed_intensities_;
00246     }
00247 
00249     void setSmoothedIntensities(const std::vector<DoubleReal> & db_vec)
00250     {
00251       if (trace_peaks_.size() != db_vec.size())
00252       {
00253         throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Number of smoothed intensities deviates from mass trace size! Aborting...", String(db_vec.size()));
00254       }
00255 
00256       smoothed_intensities_ = db_vec;
00257     }
00258 
00260     DoubleReal getScanTime()
00261     {
00262       return scan_time_;
00263     }
00264 
00267 
00268     DoubleReal computeSmoothedPeakArea();
00269 
00270     DoubleReal computePeakArea();
00271     DoubleReal computePeakArea() const;
00272 
00273 
00275     Size findMaxByIntPeak(bool) const;
00276 
00278     DoubleReal estimateFWHM(bool);
00279 
00281     DoubleReal computeFwhmAreaSmooth();
00282     DoubleReal computeFwhmArea();
00283     DoubleReal computeFwhmAreaSmoothRobust();
00284     DoubleReal computeFwhmAreaRobust();
00285 
00286     DoubleReal getIntensity(bool);
00287     DoubleReal getMaxIntensity(bool);
00288     DoubleReal getMaxIntensity(bool) const;
00289 
00291     ConvexHull2D getConvexhull() const;
00292 
00293 
00297     void updateSmoothedMaxRT();
00298 
00300     void updateWeightedMeanRT();
00301 
00302     void updateSmoothedWeightedMeanRT();
00303 
00305     void updateMedianRT();
00306 
00308     void updateMedianMZ();
00309 
00311     void updateMeanMZ();
00312 
00314     void updateWeightedMeanMZ();
00315 
00316     void updateWeightedMZsd();
00317 
00318 private:
00320     std::vector<PeakType> trace_peaks_;
00321 
00323     DoubleReal centroid_mz_;
00324 
00326     DoubleReal centroid_sd_;
00327 
00329     DoubleReal centroid_rt_;
00330 
00332     String label_;
00333 
00335     std::vector<DoubleReal> smoothed_intensities_;
00336 
00337     DoubleReal fwhm_;
00338 
00340     DoubleReal scan_time_;
00341 
00342     Size fwhm_start_idx_;
00343     Size fwhm_end_idx_;
00344 
00345 
00347     // Size fwhm_num_scans_;
00348   };
00349 
00350 }
00351 
00352 #endif // OPENMS_KERNEL_MASSTRACE_H

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