| OpenMS 2.5.0

OptimizePeakDeconvolution.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-2020.
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: $
33 // --------------------------------------------------------------------------
34 //
35
36 #pragma once
37
38 #include <OpenMS/TRANSFORMATIONS/RAW2PEAK/PeakShape.h>
39 #include <OpenMS/TRANSFORMATIONS/RAW2PEAK/OptimizePick.h>
40 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
41
42 //#define DEBUG_DECONV
43 #include <vector>
44
45 namespace OpenMS
46 {
47
48 namespace OptimizationFunctions
49 {
50
57 struct OPENMS_DLLAPI PenaltyFactorsIntensity :
58 public PenaltyFactors
59 {
60 PenaltyFactorsIntensity() :
61 PenaltyFactors(), height(0){}
62 PenaltyFactorsIntensity(const PenaltyFactorsIntensity & p) :
63 PenaltyFactors(p), height(p.height) {}
64 inline PenaltyFactorsIntensity & operator=(const PenaltyFactorsIntensity & p)
65 {
66 height = p.height;
67 pos = p.pos;
68 lWidth = p.lWidth;
69 rWidth = p.rWidth;
70
71 return *this;
72 }
73
74 ~PenaltyFactorsIntensity(){}
75
76 double height;
77
78
79 };
80
81
82
83 } //namespace OptimizationFunctions
84
96 class OPENMS_DLLAPI OptimizePeakDeconvolution :
97 public DefaultParamHandler
98 {
99 public:
103 typedef std::vector<Peak1D> RawDataVector;
104 typedef RawDataVector::iterator PeakIterator;
106
110 struct Data
111 {
112 std::vector<PeakShape> peaks;
113 std::vector<double> positions;
114 std::vector<double> signal;
115 OptimizationFunctions::PenaltyFactorsIntensity penalties;
116 Int charge;
117 };
118
119
120
124 OptimizePeakDeconvolution();
126
128 OptimizePeakDeconvolution(const OptimizePeakDeconvolution & opt) :
129 DefaultParamHandler(opt),
130 penalties_(opt.penalties_),
131 charge_(opt.charge_){}
132
134 ~OptimizePeakDeconvolution() override{}
136
140 inline OptimizePeakDeconvolution & operator=(const OptimizePeakDeconvolution & opt)
141 {
142 DefaultParamHandler::operator=(opt);
143 penalties_ = opt.penalties_;
144 charge_ = opt.charge_;
145
146 return *this;
147 }
148
150
151
155 inline const OptimizationFunctions::PenaltyFactorsIntensity & getPenalties() const { return penalties_; }
158 inline void setPenalties(const OptimizationFunctions::PenaltyFactorsIntensity & penalties)
159 {
160 penalties_ = penalties;
161 param_.setValue("penalties:left_width", penalties_.lWidth);
162 param_.setValue("penalties:right_width", penalties_.rWidth);
163 param_.setValue("penalties:height", penalties_.height);
164 param_.setValue("penalties:position", penalties_.pos);
165 }
166
168 inline Int getCharge() const { return charge_; }
170 inline void setCharge(const Int charge) { charge_ = charge; }
172
173
175 bool optimize(std::vector<PeakShape> & peaks, Data & data);
176 Size getNumberOfPeaks_(Int charge, std::vector<PeakShape> & temp_shapes, Data & data);
177
178 protected:
179 // Penalty factors for some parameter in the optimization
180 OptimizationFunctions::PenaltyFactorsIntensity penalties_;
181
183 Int charge_;
184
186 static const double dist_;
187
189 void setNumberOfPeaks_(Data & data, const std::vector<PeakShape> & temp_shapes, Int charge);
190
191 void updateMembers_() override;
192 }; // class
193
194 } // namespace OpenMS
195
196
OpenMS::OptimizationFunctions::PenaltyFactors::lWidth
double lWidth
Penalty factor for the peak shape&#39;s left width parameter.
Definition: OptimizePick.h:82
OpenMS::OptimizePeakDeconvolution::Data::signal
std::vector< double > signal
Definition: OptimizePeakDeconvolution.h:114
OpenMS::OptimizationFunctions::PenaltyFactorsIntensity::~PenaltyFactorsIntensity
~PenaltyFactorsIntensity()
Definition: OptimizePeakDeconvolution.h:74
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
OpenMS::OptimizationFunctions::PenaltyFactorsIntensity::height
double height
Definition: OptimizePeakDeconvolution.h:76
OpenMS::OptimizePeakDeconvolution::operator=
OptimizePeakDeconvolution & operator=(const OptimizePeakDeconvolution &opt)
Definition: OptimizePeakDeconvolution.h:140
OpenMS::OptimizationFunctions::PenaltyFactors
Class for the penalty factors used during the optimization.
Definition: OptimizePick.h:62
OpenMS::OptimizePeakDeconvolution::dist_
static const double dist_
distance between two isotopic peaks
Definition: OptimizePeakDeconvolution.h:186
OpenMS::OptimizationFunctions::PenaltyFactorsIntensity::operator=
PenaltyFactorsIntensity & operator=(const PenaltyFactorsIntensity &p)
Definition: OptimizePeakDeconvolution.h:64
OpenMS::OptimizePeakDeconvolution::RawDataVector
std::vector< Peak1D > RawDataVector
Definition: OptimizePeakDeconvolution.h:103
OpenMS::OptimizePeakDeconvolution::setPenalties
void setPenalties(const OptimizationFunctions::PenaltyFactorsIntensity &penalties)
Mutable access to the penalty parameter.
Definition: OptimizePeakDeconvolution.h:158
OpenMS::OptimizePeakDeconvolution::setCharge
void setCharge(const Int charge)
Mutable access to the charge.
Definition: OptimizePeakDeconvolution.h:170
OpenMS::OptimizePeakDeconvolution::OptimizePeakDeconvolution
OptimizePeakDeconvolution(const OptimizePeakDeconvolution &opt)
Copy-Constructor.
Definition: OptimizePeakDeconvolution.h:128
OpenMS::OptimizePeakDeconvolution::~OptimizePeakDeconvolution
~OptimizePeakDeconvolution() override
Destructor.
Definition: OptimizePeakDeconvolution.h:134
OpenMS::OptimizePeakDeconvolution::penalties_
OptimizationFunctions::PenaltyFactorsIntensity penalties_
Definition: OptimizePeakDeconvolution.h:180
OpenMS::OptimizationFunctions::PenaltyFactorsIntensity
Class for the penalty factors used during the optimization.
Definition: OptimizePeakDeconvolution.h:57
OpenMS::OptimizePeakDeconvolution::Data
Class containing the data needed for optimization.
Definition: OptimizePeakDeconvolution.h:110
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OptimizePick.h
OpenMS::OptimizationFunctions::PenaltyFactorsIntensity::PenaltyFactorsIntensity
PenaltyFactorsIntensity()
Definition: OptimizePeakDeconvolution.h:60
OpenMS::OptimizePeakDeconvolution::Data::penalties
OptimizationFunctions::PenaltyFactorsIntensity penalties
Definition: OptimizePeakDeconvolution.h:115
OpenMS::OptimizePeakDeconvolution::getCharge
Int getCharge() const
Non-mutable access to the charge.
Definition: OptimizePeakDeconvolution.h:168
OpenMS::OptimizationFunctions::PenaltyFactorsIntensity::PenaltyFactorsIntensity
PenaltyFactorsIntensity(const PenaltyFactorsIntensity &p)
Definition: OptimizePeakDeconvolution.h:62
OpenMS::OptimizePeakDeconvolution::Data::positions
std::vector< double > positions
Definition: OptimizePeakDeconvolution.h:113
DefaultParamHandler.h
OpenMS::DefaultParamHandler::operator=
virtual DefaultParamHandler & operator=(const DefaultParamHandler &rhs)
Assignment operator.
OpenMS::OptimizePeakDeconvolution::PeakIterator
RawDataVector::iterator PeakIterator
Definition: OptimizePeakDeconvolution.h:104
OpenMS::OptimizePeakDeconvolution
This class provides the deconvolution of peak regions using non-linear optimization.
Definition: OptimizePeakDeconvolution.h:96
OpenMS::OptimizationFunctions::PenaltyFactors::rWidth
double rWidth
Penalty factor for the peak shape&#39;s right width parameter.
Definition: OptimizePick.h:84
OpenMS::OptimizationFunctions::PenaltyFactors::pos
double pos
Penalty factor for the peak shape&#39;s position.
Definition: OptimizePick.h:80
int
OpenMS::OptimizePeakDeconvolution::Data::peaks
std::vector< PeakShape > peaks
Definition: OptimizePeakDeconvolution.h:112
PeakShape.h
OpenMS::OptimizePeakDeconvolution::charge_
Int charge_
Charge state of the current isotope pattern.
Definition: OptimizePeakDeconvolution.h:183
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::OptimizePeakDeconvolution::Data::charge
Int charge
Definition: OptimizePeakDeconvolution.h:116