Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
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
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