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-2017.
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: Timo Sachsenberg $
32 // $Authors: Florian Zeller $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_TRANSFORMATIONS_RAW2PEAK_PEAKPICKERSH_H
36 #define OPENMS_TRANSFORMATIONS_RAW2PEAK_PEAKPICKERSH_H
37 
42 
43 // TODO: Check if I need this # PeakPickerSH.h
44 #define DEBUG_PEAK_PICKING
45 #undef DEBUG_PEAK_PICKING
46 
47 namespace OpenMS
48 {
49  class OPENMS_DLLAPI PeakPickerSH :
50  public DefaultParamHandler,
51  public ProgressLogger
52  {
53 public:
54  PeakPickerSH();
55 
56  virtual ~PeakPickerSH();
57 
61  void pick(const MSSpectrum & input, MSSpectrum & 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  Peak1D peak;
107  peak.setMZ(cm);
108  peak.setIntensity(intens[i]);
109  output.push_back(peak);
110  }
111  }
112  }
113 
120  void pickExperiment(const PeakMap & input, PeakMap & output);
121  };
122 }
123 
124 #endif
const double k
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
void setMZ(CoordinateType mz)
Mutable access to m/z.
Definition: Peak1D.h:120
void setIntensity(IntensityType intensity)
Mutable access to the data point intensity (height)
Definition: Peak1D.h:111
Definition: PeakPickerSH.h:49
void pick(const MSSpectrum &input, MSSpectrum &output, float fWindowWidth)
Picks peaks in one spectrum.
Definition: PeakPickerSH.h:61
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:55
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:82
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
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

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:03 using doxygen 1.8.13