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

IMSIsotopeDistribution.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: Stephan Aiche $
00032 // $Authors: Anton Pervukhin <Anton.Pervukhin@CeBiTec.Uni-Bielefeld.DE> $
00033 // --------------------------------------------------------------------------
00034 //
00035 
00036 #ifndef OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_IMSISOTOPEDISTRIBUTION_H
00037 #define OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_IMSISOTOPEDISTRIBUTION_H
00038 
00039 #include <vector>
00040 #include <ostream>
00041 #include <algorithm>
00042 
00043 #include <OpenMS/config.h>
00044 
00045 namespace OpenMS
00046 {
00047 
00048   namespace ims
00049   {
00050 
00088     class OPENMS_DLLAPI IMSIsotopeDistribution
00089     {
00090 
00091 public:
00093       typedef double mass_type;
00094 
00096       typedef double abundance_type;
00097 
00099       typedef unsigned int nominal_mass_type;
00100 
00102       struct Peak
00103       {
00104         Peak(mass_type mass = 0.0, abundance_type abundance = 0.0) :
00105           mass(mass), abundance(abundance)
00106         {}
00107 
00108         bool operator==(const Peak & peak) const
00109         {
00110           return peak.mass == mass && peak.abundance == abundance;
00111         }
00112 
00113         mass_type mass;
00114         abundance_type abundance;
00115       };
00116 
00118       typedef Peak peak_type;
00119 
00121       typedef std::vector<peak_type> peaks_container;
00122 
00124       typedef peaks_container::iterator peaks_iterator;
00125 
00127       typedef peaks_container::const_iterator const_peaks_iterator;
00128 
00130       typedef peaks_container::size_type size_type;
00131 
00133       typedef std::vector<mass_type> masses_container;
00134 
00136       typedef masses_container::iterator masses_iterator;
00137 
00139       typedef masses_container::const_iterator const_masses_iterator;
00140 
00142       typedef std::vector<abundance_type> abundances_container;
00143 
00145       typedef abundances_container::iterator abundances_iterator;
00146 
00148       typedef abundances_container::const_iterator const_abundances_iterator;
00149 
00151       static abundance_type ABUNDANCES_SUM_ERROR;
00152 
00154       static size_type SIZE;
00155 
00157       explicit IMSIsotopeDistribution(nominal_mass_type nominalMass = 0) :
00158         nominal_mass_(nominalMass)
00159       {}
00160 
00162       explicit IMSIsotopeDistribution(mass_type mass) :
00163         nominal_mass_(0)
00164       {
00165         peaks_.push_back(peaks_container::value_type(mass, 1.0));
00166       }
00167 
00169       IMSIsotopeDistribution(const peaks_container & peaks,
00170                              nominal_mass_type nominalMass = 0) :
00171         peaks_(peaks),
00172         nominal_mass_(nominalMass)
00173       {}
00174 
00176       IMSIsotopeDistribution(const IMSIsotopeDistribution & distribution) :
00177         peaks_(distribution.peaks_),
00178         nominal_mass_(distribution.nominal_mass_)
00179       {}
00180 
00182       ~IMSIsotopeDistribution()
00183       {}
00184 
00191       size_type size() const { return std::min(peaks_.size(), SIZE); }
00192 
00199       IMSIsotopeDistribution & operator=(
00200         const IMSIsotopeDistribution & distribution);
00201 
00209       bool operator==(const IMSIsotopeDistribution & distribution) const;
00210 
00218       bool operator!=(const IMSIsotopeDistribution & distribution) const;
00219 
00230       IMSIsotopeDistribution & operator*=(
00231         const IMSIsotopeDistribution & distribution);
00232 
00243       IMSIsotopeDistribution & operator*=(unsigned int pow);
00244 
00251       mass_type getMass(size_type i) const
00252       {
00253         return peaks_[i].mass + nominal_mass_ + i;
00254       }
00255 
00262       abundance_type getAbundance(size_type i) const
00263       {
00264         return peaks_[i].abundance;
00265       }
00266 
00272       mass_type getAverageMass() const;
00273 
00279       nominal_mass_type getNominalMass() const { return nominal_mass_; }
00280 
00286       void setNominalMass(nominal_mass_type nominalMass)
00287       {
00288         this->nominal_mass_ = nominalMass;
00289       }
00290 
00296       masses_container getMasses() const;
00297 
00303       abundances_container getAbundances() const;
00304 
00310       void normalize();
00311 
00317       bool empty() const { return peaks_.empty(); }
00318 
00319 private:
00321       peaks_container peaks_;
00322 
00324       nominal_mass_type nominal_mass_;
00325 
00327       void setMinimumSize_();
00328     };
00329 
00336     OPENMS_DLLAPI std::ostream & operator<<(std::ostream & os,
00337                                             const IMSIsotopeDistribution & distribution);
00338 
00339   } // namespace ims
00340 } // namespace OpenMS
00341 
00342 #endif // OPENMS_CHEMISTRY_MASSDECOMPOSITION_IMS_ISOTOPE_DISTRIBUTION_H

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