Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
MassTrace.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-2013.
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: Erhan Kenar $
32 // $Authors: Erhan Kenar, Holger Franken $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_KERNEL_MASSTRACE_H
36 #define OPENMS_KERNEL_MASSTRACE_H
37 
38 #include <OpenMS/KERNEL/Peak2D.h>
40 
41 
42 #include <vector>
43 #include <list>
44 #include <map>
45 
46 
47 namespace OpenMS
48 {
49  typedef Peak2D PeakType;
50 
59  class OPENMS_DLLAPI MassTrace
60  {
61 public:
64  MassTrace();
66 
68  MassTrace(const std::list<PeakType> &, const DoubleReal & scan_time = 1.0);
69 
71  MassTrace(const std::vector<PeakType> &, const DoubleReal & scan_time = 1.0);
72 
74  ~MassTrace();
75 
77  MassTrace(const MassTrace &);
78 
80  MassTrace & operator=(const MassTrace &);
81 
83  PeakType & operator[](const Size & mt_idx);
84  const PeakType & operator[](const Size & mt_idx) const;
85 
86 
90  typedef std::vector<PeakType>::iterator iterator;
91  typedef std::vector<PeakType>::const_iterator const_iterator;
92  typedef std::vector<PeakType>::reverse_iterator reverse_iterator;
93  typedef std::vector<PeakType>::const_reverse_iterator const_reverse_iterator;
94 
96  {
97  return trace_peaks_.begin();
98  }
99 
101  {
102  return trace_peaks_.end();
103  }
104 
106  {
107  return trace_peaks_.begin();
108  }
109 
111  {
112  return trace_peaks_.end();
113  }
114 
116  {
117  return trace_peaks_.rbegin();
118  }
119 
121  {
122  return trace_peaks_.rend();
123  }
124 
126  {
127  return trace_peaks_.rbegin();
128  }
129 
131  {
132  return trace_peaks_.rend();
133  }
134 
138  Size getSize() const
140  {
141  return trace_peaks_.size();
142  }
143 
145  String getLabel() const
146  {
147  return label_;
148  }
149 
151  void setLabel(const String & label)
152  {
153  label_ = label;
154  }
155 
158  {
159  return centroid_mz_;
160  }
161 
163  {
164  return centroid_mz_;
165  }
166 
169  {
170  return centroid_rt_;
171  }
172 
174  {
175  return centroid_rt_;
176  }
177 
179  {
180  return centroid_sd_;
181  }
182 
184  {
185  return centroid_sd_;
186  }
187 
188  void setCentroidSD(const DoubleReal & tmp_sd)
189  {
190  centroid_sd_ = tmp_sd;
191  }
192 
194  {
195  return fwhm_;
196  }
197 
199  {
200  return fwhm_;
201  }
202 
204  {
205  DoubleReal length(0.0);
206 
207  if (trace_peaks_.size() > 1)
208  {
209  length = std::fabs(trace_peaks_.rbegin()->getRT() - trace_peaks_.begin()->getRT());
210  }
211 
212  return length;
213  }
214 
216  {
217  DoubleReal length(0.0);
218 
219  if (trace_peaks_.size() > 1)
220  {
221  length = std::fabs(trace_peaks_.rbegin()->getRT() - trace_peaks_.begin()->getRT());
222  }
223 
224  return length;
225  }
226 
227  std::pair<Size, Size> getFWHMborders()
228  {
229  return std::make_pair(fwhm_start_idx_, fwhm_end_idx_);
230  }
231 
232  std::pair<Size, Size> getFWHMborders() const
233  {
234  return std::make_pair(fwhm_start_idx_, fwhm_end_idx_);
235  }
236 
238  std::vector<DoubleReal> getSmoothedIntensities()
239  {
240  return smoothed_intensities_;
241  }
242 
243  std::vector<DoubleReal> getSmoothedIntensities() const
244  {
245  return smoothed_intensities_;
246  }
247 
249  void setSmoothedIntensities(const std::vector<DoubleReal> & db_vec)
250  {
251  if (trace_peaks_.size() != db_vec.size())
252  {
253  throw Exception::InvalidValue(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Number of smoothed intensities deviates from mass trace size! Aborting...", String(db_vec.size()));
254  }
255 
256  smoothed_intensities_ = db_vec;
257  }
258 
261  {
262  return scan_time_;
263  }
264 
267  DoubleReal computeSmoothedPeakArea();
269 
270  DoubleReal computePeakArea();
271  DoubleReal computePeakArea() const;
272 
273 
275  Size findMaxByIntPeak(bool) const;
276 
278  DoubleReal estimateFWHM(bool);
279 
281  DoubleReal computeFwhmAreaSmooth();
282  DoubleReal computeFwhmArea();
283  DoubleReal computeFwhmAreaSmoothRobust();
284  DoubleReal computeFwhmAreaRobust();
285 
286  DoubleReal getIntensity(bool);
287  DoubleReal getMaxIntensity(bool);
288  DoubleReal getMaxIntensity(bool) const;
289 
291  ConvexHull2D getConvexhull() const;
292 
293 
297  void updateSmoothedMaxRT();
298 
300  void updateWeightedMeanRT();
301 
302  void updateSmoothedWeightedMeanRT();
303 
305  void updateMedianRT();
306 
308  void updateMedianMZ();
309 
311  void updateMeanMZ();
312 
314  void updateWeightedMeanMZ();
315 
316  void updateWeightedMZsd();
317 
318 private:
320  std::vector<PeakType> trace_peaks_;
321 
324 
327 
330 
333 
335  std::vector<DoubleReal> smoothed_intensities_;
336 
338 
341 
344 
345 
347  // Size fwhm_num_scans_;
348  };
349 
350 }
351 
352 #endif // OPENMS_KERNEL_MASSTRACE_H
DoubleReal getFWHM()
Definition: MassTrace.h:193
DoubleReal centroid_rt_
Centroid RT.
Definition: MassTrace.h:329
iterator end()
Definition: MassTrace.h:100
A more convenient string class.
Definition: String.h:56
DoubleReal centroid_mz_
Centroid m/z.
Definition: MassTrace.h:323
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
DoubleReal scan_time_
Scan time (time difference between two consecutive scans)
Definition: MassTrace.h:340
DoubleReal getFWHM() const
Definition: MassTrace.h:198
void setCentroidSD(const DoubleReal &tmp_sd)
Definition: MassTrace.h:188
DoubleReal getTraceLength() const
Definition: MassTrace.h:215
DoubleReal getCentroidSD()
Definition: MassTrace.h:178
Peak2D PeakType
Definition: MassTrace.h:49
DoubleReal fwhm_
Definition: MassTrace.h:337
reverse_iterator rbegin()
Definition: MassTrace.h:115
A 2-dimensional hull representation in [counter]clockwise direction - depending on axis labelling...
Definition: ConvexHull2D.h:75
std::vector< PeakType >::const_iterator const_iterator
Definition: MassTrace.h:91
DoubleReal getCentroidRT() const
Definition: MassTrace.h:173
const_reverse_iterator rbegin() const
Definition: MassTrace.h:125
DoubleReal getCentroidSD() const
Definition: MassTrace.h:183
std::vector< DoubleReal > getSmoothedIntensities()
Gets smoothed intensities (empty if no smoothing was explicitly done beforehand!).
Definition: MassTrace.h:238
std::vector< DoubleReal > getSmoothedIntensities() const
Definition: MassTrace.h:243
DoubleReal getCentroidMZ() const
Definition: MassTrace.h:162
std::vector< PeakType >::iterator iterator
Definition: MassTrace.h:90
DoubleReal centroid_sd_
intensity-weighted STD
Definition: MassTrace.h:326
DoubleReal getScanTime()
Get scan time of mass trace.
Definition: MassTrace.h:260
void setSmoothedIntensities(const std::vector< DoubleReal > &db_vec)
Set smoothed intensities (smoothing is done externally, e.g. by LowessSmoothing). ...
Definition: MassTrace.h:249
std::vector< PeakType >::reverse_iterator reverse_iterator
Definition: MassTrace.h:92
DoubleReal getTraceLength()
Definition: MassTrace.h:203
const_iterator begin() const
Definition: MassTrace.h:105
iterator begin()
Definition: MassTrace.h:95
Size fwhm_end_idx_
Definition: MassTrace.h:343
std::vector< PeakType > trace_peaks_
Actual MassTrace container for doing centroid calculation, peak width estimation etc.
Definition: MassTrace.h:320
std::vector< PeakType >::const_reverse_iterator const_reverse_iterator
Definition: MassTrace.h:93
Invalid value exception.
Definition: Exception.h:336
DoubleReal getCentroidMZ()
Returns the centroid m/z.
Definition: MassTrace.h:157
const_reverse_iterator rend() const
Definition: MassTrace.h:130
reverse_iterator rend()
Definition: MassTrace.h:120
Size fwhm_start_idx_
Definition: MassTrace.h:342
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:144
void setLabel(const String &label)
Sets label of mass trace.
Definition: MassTrace.h:151
std::pair< Size, Size > getFWHMborders()
Definition: MassTrace.h:227
String getLabel() const
Gets label of mass trace.
Definition: MassTrace.h:145
std::pair< Size, Size > getFWHMborders() const
Definition: MassTrace.h:232
String label_
Trace label.
Definition: MassTrace.h:332
DoubleReal getCentroidRT()
Returns the centroid RT.
Definition: MassTrace.h:168
std::vector< DoubleReal > smoothed_intensities_
Container for smoothed intensities. Smoothing must be done externally.
Definition: MassTrace.h:335
A container type that gathers peaks similar in m/z and moving along retention time.
Definition: MassTrace.h:59
const_iterator end() const
Definition: MassTrace.h:110

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:16 using doxygen 1.8.5