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

MRMTransitionGroup.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: Hannes Roest $
00032 // $Authors: Hannes Roest $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_KERNEL_MRMTRANSITIONGROUP_H
00036 #define OPENMS_KERNEL_MRMTRANSITIONGROUP_H
00037 
00038 #include <OpenMS/KERNEL/MRMFeature.h>
00039 #include <boost/numeric/conversion/cast.hpp>
00040 
00041 namespace OpenMS
00042 {
00055   template <typename SpectrumType, typename TransitionType>
00056   class MRMTransitionGroup
00057   {
00058 
00059 public:
00060 
00062 
00063 
00064     typedef std::vector<MRMFeature> MRMFeatureListType;
00066     typedef std::vector<TransitionType> TransitionsType;
00068     typedef typename SpectrumType::PeakType PeakType;
00070 
00072     MRMTransitionGroup()
00073     {
00074     }
00075 
00077     MRMTransitionGroup(const MRMTransitionGroup & rhs) :
00078       tr_gr_id_(rhs.tr_gr_id_),
00079       transitions_(rhs.transitions_),
00080       chromatograms_(rhs.chromatograms_),
00081       cons_features_(rhs.cons_features_),
00082       chromatogram_map_(rhs.chromatogram_map_),
00083       transition_map_(rhs.transition_map_)
00084     {
00085     }
00086 
00088     virtual ~MRMTransitionGroup()
00089     {
00090     }
00091 
00092     MRMTransitionGroup & operator=(const MRMTransitionGroup & rhs)
00093     {
00094       if (&rhs != this)
00095       {
00096         tr_gr_id_ = rhs.tr_gr_id_;
00097         transitions_ = rhs.transitions_;
00098         chromatograms_ = rhs.chromatograms_;
00099         cons_features_ = rhs.cons_features_;
00100 
00101         transition_map_ = rhs.transition_map_;
00102         chromatogram_map_ = rhs.chromatogram_map_;
00103       }
00104       return *this;
00105     }
00106 
00107     inline Size size() const
00108     {
00109       return chromatograms_.size();
00110     }
00111 
00112     inline const String & getTransitionGroupID() const
00113     {
00114       return tr_gr_id_;
00115     }
00116 
00117     inline void setTransitionGroupID(const String & tr_gr_id)
00118     {
00119       tr_gr_id_ = tr_gr_id;
00120     }
00121 
00122     inline const std::vector<TransitionType> & getTransitions() const
00123     {
00124       return transitions_;
00125     }
00126 
00127     inline std::vector<TransitionType> & getTransitionsMuteable()
00128     {
00129       return transitions_;
00130     }
00131 
00132     inline void addTransition(const TransitionType & transition, String key)
00133     {
00134       transitions_.push_back(transition);
00135       transition_map_[key] = boost::numeric_cast<int>(transitions_.size()) - 1;
00136     }
00137 
00138     inline const TransitionType & getTransition(String key) 
00139     {
00140       return transitions_[transition_map_[key]];
00141     }
00142 
00143     inline bool hasTransition(String key)
00144     {
00145       return transition_map_.find(key) != transition_map_.end();
00146     }
00147 
00148     inline const std::vector<SpectrumType> & getChromatograms() const
00149     {
00150       return chromatograms_;
00151     }
00152 
00153     inline std::vector<SpectrumType> & getChromatograms()
00154     {
00155       return chromatograms_;
00156     }
00157 
00158     inline void addChromatogram(SpectrumType & chromatogram, String key)
00159     {
00160       chromatograms_.push_back(chromatogram);
00161       chromatogram_map_[key] = boost::numeric_cast<int>(chromatograms_.size()) - 1;
00162     }
00163 
00164     inline SpectrumType & getChromatogram(String key)
00165     {
00166       return chromatograms_[chromatogram_map_[key]];
00167     }
00168 
00169     inline bool hasChromatogram(String key)
00170     {
00171       return chromatogram_map_.find(key) != chromatogram_map_.end();
00172     }
00173 
00174     inline const std::vector<MRMFeature> & getFeatures() const
00175     {
00176       return cons_features_;
00177     }
00178 
00179     inline std::vector<MRMFeature> & getFeaturesMuteable()
00180     {
00181       return cons_features_;
00182     }
00183 
00184     inline void addFeature(MRMFeature & feature)
00185     {
00186       cons_features_.push_back(feature);
00187     }
00188 
00189     void getLibraryIntensity(std::vector<double> & result) const
00190     {
00191       for (typename TransitionsType::const_iterator it = transitions_.begin(); it != transitions_.end(); ++it)
00192       {
00193         result.push_back(it->getLibraryIntensity());
00194       }
00195       for (Size i = 0; i < result.size(); i++)
00196       {
00197         // the library intensity should never be below zero
00198         if (result[i] < 0.0) 
00199         {
00200           result[i] = 0.0;
00201         }
00202       }
00203     }
00204 
00205 protected:
00206 
00208     String tr_gr_id_;
00209 
00211     TransitionsType transitions_;
00212 
00214     std::vector<SpectrumType> chromatograms_;
00215 
00217     MRMFeatureListType cons_features_;
00218 
00219     std::map<String, int> chromatogram_map_;
00220     std::map<String, int> transition_map_;
00221 
00222   };
00223 }
00224 #endif

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