Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
PeakPickerSH.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-2015.
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: Florian Zeller $
32 // $Authors: Florian Zeller $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_PEAKPICKERSH_H
36 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_PEAKPICKERSH_H
37 
41 
42 // TODO: Check if I need this # PeakPickerSH.h
43 #define DEBUG_PEAK_PICKING
44 #undef DEBUG_PEAK_PICKING
45 
46 namespace OpenMS
47 {
48  class OPENMS_DLLAPI PeakPickerSH :
49  public DefaultParamHandler,
50  public ProgressLogger
51  {
52 public:
53  PeakPickerSH();
54 
55  virtual ~PeakPickerSH();
56 
60  template <typename PeakType>
61  void pick(const MSSpectrum<PeakType> & input, MSSpectrum<PeakType> & output, float fWindowWidth)
62  {
63  int i, hw, j;
64  double cm, toti, min_dh;
65 
66  // Hack: Prepare data structures for Lukas' algorithm
67  std::vector<double> masses, intens;
68  // TODO: Probably we could save some time when we resize the vectors... # PeakPickerSH.cpp
69  //masses.resize(input.size());
70  //intens.resize(input.size());
71  for (Size k = 0; k < input.size() - 1; ++k)
72  {
73  // Lukas requires a minimum of intensity (=50). His vectors do not contain
74  // other data, so I strip the low ones out right here.
75  // TODO: Read 50.0 from parameters # PeakPickerSH.cpp
76  if (input[k].getIntensity() >= 50.0)
77  {
78  masses.push_back(input[k].getMZ());
79  intens.push_back(input[k].getIntensity());
80  }
81  }
82 
83  min_dh = 50.0; // min height
84  hw = fWindowWidth / 2;
85 
86  for (i = 2; i < (int)masses.size() - 2; i++)
87  {
88 
89  // Peak must be concave in the interval [i-2 .. i+2]
90  if (intens[i] > min_dh && intens[i] > intens[i - 1] + min_dh && intens[i] >= intens[i + 1] && intens[i - 1] > intens[i - 2] + min_dh && intens[i + 1] >= intens[i + 2])
91  {
92 
93  cm = 0.0; // centroid mass:
94  toti = 0.0; // total intensity:
95 
96  for (j = -hw; j <= hw; j++)
97  {
98  double inte = intens[i - j];
99  double mz = masses[i - j];
100 
101  cm += inte * mz;
102  toti += (double) intens[i - j];
103  }
104  cm = cm / toti; // Centre of gravity = centroid
105 
106  PeakType peak;
107  peak.setMZ(cm);
108  peak.setIntensity(intens[i]);
109  output.push_back(peak);
110  }
111  }
112  }
113 
120  void pickExperiment(const MSExperiment<> & input, MSExperiment<> & output);
121  };
122 }
123 
124 #endif
const double k
A 2-dimensional raw data point or peak.
Definition: Peak2D.h:55
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: Peak2D.h:197
Definition: PeakPickerSH.h:48
void setIntensity(IntensityType intensity)
Non-mutable access to the data point intensity (height)
Definition: Peak2D.h:167
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:55
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
void pick(const MSSpectrum< PeakType > &input, MSSpectrum< PeakType > &output, float fWindowWidth)
Picks peaks in one spectrum.
Definition: PeakPickerSH.h:61

OpenMS / TOPP release 2.0.0 Documentation generated on Wed Mar 30 2016 16:18:41 using doxygen 1.8.5