Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
MRMTransitionGroup.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2016.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Hannes Roest $
32 // $Authors: Hannes Roest $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_KERNEL_MRMTRANSITIONGROUP_H
36 #define OPENMS_KERNEL_MRMTRANSITIONGROUP_H
37 
39 #include <boost/numeric/conversion/cast.hpp>
40 
41 namespace OpenMS
42 {
55  template <typename SpectrumType, typename TransitionType>
57  {
58 
59 public:
60 
62 
63  typedef std::vector<MRMFeature> MRMFeatureListType;
66  typedef std::vector<TransitionType> TransitionsType;
68  typedef typename SpectrumType::PeakType PeakType;
70 
73  {
74  }
75 
78  tr_gr_id_(rhs.tr_gr_id_),
86  {
87  }
88 
91  {
92  }
93 
95  {
96  if (&rhs != this)
97  {
98  tr_gr_id_ = rhs.tr_gr_id_;
106  }
107  return *this;
108  }
109 
110  inline Size size() const
111  {
112  return chromatograms_.size();
113  }
114 
115  inline const String & getTransitionGroupID() const
116  {
117  return tr_gr_id_;
118  }
119 
120  inline void setTransitionGroupID(const String & tr_gr_id)
121  {
122  tr_gr_id_ = tr_gr_id;
123  }
124 
125  inline const std::vector<TransitionType> & getTransitions() const
126  {
127  return transitions_;
128  }
129 
130  inline std::vector<TransitionType> & getTransitionsMuteable()
131  {
132  return transitions_;
133  }
134 
135  inline void addTransition(const TransitionType & transition, String key)
136  {
137  transitions_.push_back(transition);
138  transition_map_[key] = boost::numeric_cast<int>(transitions_.size()) - 1;
139  }
140 
141  inline const TransitionType & getTransition(String key)
142  {
143  return transitions_[transition_map_[key]];
144  }
145 
146  inline bool hasTransition(String key)
147  {
148  return transition_map_.find(key) != transition_map_.end();
149  }
150 
151  inline const std::vector<SpectrumType> & getChromatograms() const
152  {
153  return chromatograms_;
154  }
155 
156  inline std::vector<SpectrumType> & getChromatograms()
157  {
158  return chromatograms_;
159  }
160 
161  inline void addChromatogram(SpectrumType & chromatogram, String key)
162  {
163  chromatograms_.push_back(chromatogram);
164  chromatogram_map_[key] = boost::numeric_cast<int>(chromatograms_.size()) - 1;
165  }
166 
167  inline SpectrumType & getChromatogram(String key)
168  {
169  return chromatograms_[chromatogram_map_[key]];
170  }
171 
172  inline bool hasChromatogram(String key) const
173  {
174  return chromatogram_map_.find(key) != chromatogram_map_.end();
175  }
176 
187  inline void addPrecursorChromatogram(SpectrumType & chromatogram, String key)
188  {
189  precursor_chromatograms_.push_back(chromatogram);
190  precursor_chromatogram_map_[key] = boost::numeric_cast<int>(precursor_chromatograms_.size()) - 1;
191  }
192 
193  inline SpectrumType & getPrecursorChromatogram(String key)
194  {
196  }
197 
198  inline bool hasPrecursorChromatogram(String key) const
199  {
201  }
202 
203  inline const std::vector<MRMFeature> & getFeatures() const
204  {
205  return cons_features_;
206  }
207 
208  inline std::vector<MRMFeature> & getFeaturesMuteable()
209  {
210  return cons_features_;
211  }
212 
213  inline void addFeature(MRMFeature & feature)
214  {
215  cons_features_.push_back(feature);
216  }
217 
218  void getLibraryIntensity(std::vector<double> & result) const
219  {
220  for (typename TransitionsType::const_iterator it = transitions_.begin(); it != transitions_.end(); ++it)
221  {
222  result.push_back(it->getLibraryIntensity());
223  }
224  for (Size i = 0; i < result.size(); i++)
225  {
226  // the library intensity should never be below zero
227  if (result[i] < 0.0)
228  {
229  result[i] = 0.0;
230  }
231  }
232  }
233 
234  MRMTransitionGroup subset(std::vector<std::string> tr_ids)
235  {
236  MRMTransitionGroup transition_group_subset;
237  transition_group_subset.setTransitionGroupID(tr_gr_id_);
238 
239  for (typename TransitionsType::const_iterator tr_it = transitions_.begin(); tr_it != transitions_.end(); ++tr_it)
240  {
241  if (std::find(tr_ids.begin(), tr_ids.end(), tr_it->getNativeID()) != tr_ids.end())
242  {
243  if (this->hasTransition(tr_it->getNativeID()))
244  {
245  transition_group_subset.addTransition(*tr_it, tr_it->getNativeID());
246  }
247  if (this->hasChromatogram(tr_it->getNativeID()))
248  {
249  transition_group_subset.addChromatogram(chromatograms_[chromatogram_map_[tr_it->getNativeID()]], tr_it->getNativeID());
250  }
251  }
252  }
253 
254  for (std::vector< MRMFeature >::iterator tgf_it = cons_features_.begin(); tgf_it != cons_features_.end(); ++tgf_it)
255  {
256  MRMFeature mf;
257  mf.setIntensity(tgf_it->getIntensity());
258  mf.setRT(tgf_it->getRT());
259  std::vector<String> metavalues;
260  tgf_it->getKeys(metavalues);
261  for (std::vector<String>::iterator key_it = metavalues.begin(); key_it != metavalues.end(); ++key_it)
262  {
263  mf.setMetaValue(*key_it,tgf_it->getMetaValue(*key_it));
264  }
265  for (typename TransitionsType::const_iterator tr_it = transitions_.begin(); tr_it != transitions_.end(); ++tr_it)
266  {
267  if (std::find(tr_ids.begin(), tr_ids.end(), tr_it->getNativeID()) != tr_ids.end())
268  {
269  mf.addFeature(tgf_it->getFeature(tr_it->getNativeID()),tr_it->getNativeID());
270  }
271  }
272  std::vector<String> pf_ids;
273  tgf_it->getPrecursorFeatureIDs(pf_ids);
274  for (std::vector<String>::iterator pf_ids_it = pf_ids.begin(); pf_ids_it != pf_ids.end(); ++pf_ids_it)
275  {
276  mf.addPrecursorFeature(tgf_it->getPrecursorFeature(*pf_ids_it),*pf_ids_it);
277  }
278  transition_group_subset.addFeature(mf);
279  }
280 
281  return transition_group_subset;
282  }
283 
284  MRMTransitionGroup subsetDependent(std::vector<std::string> tr_ids)
285  {
286  MRMTransitionGroup transition_group_subset;
287  transition_group_subset.setTransitionGroupID(tr_gr_id_);
288 
289  for (typename TransitionsType::const_iterator tr_it = transitions_.begin(); tr_it != transitions_.end(); ++tr_it)
290  {
291  if (std::find(tr_ids.begin(), tr_ids.end(), tr_it->getNativeID()) != tr_ids.end())
292  {
293  transition_group_subset.addTransition(*tr_it, tr_it->getNativeID());
294  transition_group_subset.addChromatogram(chromatograms_[chromatogram_map_[tr_it->getNativeID()]], tr_it->getNativeID());
295  }
296  }
297 
298  for (std::vector< MRMFeature >::iterator tgf_it = cons_features_.begin(); tgf_it != cons_features_.end(); ++tgf_it)
299  {
300  transition_group_subset.addFeature(*tgf_it);
301  }
302 
303  return transition_group_subset;
304  }
305 
306 protected:
307 
310 
312  TransitionsType transitions_;
313 
315  std::vector<SpectrumType> chromatograms_;
316 
318  std::vector<SpectrumType> precursor_chromatograms_;
319 
321  MRMFeatureListType cons_features_;
322 
323  std::map<String, int> chromatogram_map_;
324  std::map<String, int> precursor_chromatogram_map_;
325  std::map<String, int> transition_map_;
326 
327  };
328 }
329 #endif
std::vector< TransitionType > TransitionsType
List of Reaction Monitoring transitions (meta data) type.
Definition: MRMTransitionGroup.h:66
MRMTransitionGroup(const MRMTransitionGroup &rhs)
Copy Constructor.
Definition: MRMTransitionGroup.h:77
std::map< String, int > transition_map_
Definition: MRMTransitionGroup.h:325
void setMetaValue(const String &name, const DataValue &value)
Sets the DataValue corresponding to a name.
TransitionsType transitions_
transition list
Definition: MRMTransitionGroup.h:312
const std::vector< TransitionType > & getTransitions() const
Definition: MRMTransitionGroup.h:125
String tr_gr_id_
transition group id (peak group id)
Definition: MRMTransitionGroup.h:309
A more convenient string class.
Definition: String.h:57
bool hasChromatogram(String key) const
Definition: MRMTransitionGroup.h:172
Size size() const
Definition: MRMTransitionGroup.h:110
std::map< String, int > chromatogram_map_
Definition: MRMTransitionGroup.h:323
MRMTransitionGroup subset(std::vector< std::string > tr_ids)
Definition: MRMTransitionGroup.h:234
const std::vector< MRMFeature > & getFeatures() const
Definition: MRMTransitionGroup.h:203
bool hasTransition(String key)
Definition: MRMTransitionGroup.h:146
const std::vector< SpectrumType > & getChromatograms() const
Definition: MRMTransitionGroup.h:151
SpectrumType & getPrecursorChromatogram(String key)
Definition: MRMTransitionGroup.h:193
Peak2D PeakType
Definition: MassTrace.h:48
void getLibraryIntensity(std::vector< double > &result) const
Definition: MRMTransitionGroup.h:218
MRMFeatureListType cons_features_
feature list
Definition: MRMTransitionGroup.h:321
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
SpectrumType::PeakType PeakType
Peak type.
Definition: MRMTransitionGroup.h:68
void setIntensity(IntensityType intensity)
Non-mutable access to the data point intensity (height)
Definition: Peak2D.h:173
MRMTransitionGroup subsetDependent(std::vector< std::string > tr_ids)
Definition: MRMTransitionGroup.h:284
The representation of a transition group that has information about the individual chromatograms as w...
Definition: MRMTransitionGroup.h:56
MRMTransitionGroup & operator=(const MRMTransitionGroup &rhs)
Definition: MRMTransitionGroup.h:94
void addFeature(Feature &feature, const String &key)
Adds an feature from a single chromatogram into the feature.
std::vector< SpectrumType > precursor_chromatograms_
precursor chromatogram list
Definition: MRMTransitionGroup.h:318
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition: Peak2D.h:215
std::vector< MRMFeature > MRMFeatureListType
Type definitions.
Definition: MRMTransitionGroup.h:64
void addChromatogram(SpectrumType &chromatogram, String key)
Definition: MRMTransitionGroup.h:161
std::vector< MRMFeature > & getFeaturesMuteable()
Definition: MRMTransitionGroup.h:208
void addPrecursorChromatogram(SpectrumType &chromatogram, String key)
Definition: MRMTransitionGroup.h:187
void addTransition(const TransitionType &transition, String key)
Definition: MRMTransitionGroup.h:135
void addFeature(MRMFeature &feature)
Definition: MRMTransitionGroup.h:213
std::vector< SpectrumType > chromatograms_
chromatogram list
Definition: MRMTransitionGroup.h:315
void addPrecursorFeature(Feature &feature, const String &key)
Adds a precursor feature from a single chromatogram into the feature.
bool hasPrecursorChromatogram(String key) const
Definition: MRMTransitionGroup.h:198
void setTransitionGroupID(const String &tr_gr_id)
Definition: MRMTransitionGroup.h:120
SpectrumType & getChromatogram(String key)
Definition: MRMTransitionGroup.h:167
MRMTransitionGroup()
Constructor.
Definition: MRMTransitionGroup.h:72
std::vector< TransitionType > & getTransitionsMuteable()
Definition: MRMTransitionGroup.h:130
A multi-chromatogram MRM feature.
Definition: MRMFeature.h:50
const String & getTransitionGroupID() const
Definition: MRMTransitionGroup.h:115
std::vector< SpectrumType > & getChromatograms()
Definition: MRMTransitionGroup.h:156
virtual ~MRMTransitionGroup()
Destructor.
Definition: MRMTransitionGroup.h:90
const TransitionType & getTransition(String key)
Definition: MRMTransitionGroup.h:141
std::map< String, int > precursor_chromatogram_map_
Definition: MRMTransitionGroup.h:324

OpenMS / TOPP release 2.0.0 Documentation generated on Tue Jan 31 2017 06:39:48 using doxygen 1.8.8