OpenMS
OptimizePeakDeconvolution.h
Go to the documentation of this file.
1// Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: $
7// --------------------------------------------------------------------------
8//
9
10#pragma once
11
15
16//#define DEBUG_DECONV
17#include <vector>
18
19namespace OpenMS
20{
21
22 namespace OptimizationFunctions
23 {
24
31 struct OPENMS_DLLAPI PenaltyFactorsIntensity :
32 public PenaltyFactors
33 {
35 PenaltyFactors(), height(0){}
37 PenaltyFactors(p), height(p.height) {}
39 {
40 height = p.height;
41 pos = p.pos;
42 lWidth = p.lWidth;
43 rWidth = p.rWidth;
44
45 return *this;
46 }
47
49
50 double height;
51
52
53 };
54
55
56
57 } //namespace OptimizationFunctions
58
70 class OPENMS_DLLAPI OptimizePeakDeconvolution :
72 {
73public:
77 typedef std::vector<Peak1D> RawDataVector;
78 typedef RawDataVector::iterator PeakIterator;
80
84 struct Data
85 {
86 std::vector<PeakShape> peaks;
87 std::vector<double> positions;
88 std::vector<double> signal;
91 };
92
93
94
100
104 penalties_(opt.penalties_),
105 charge_(opt.charge_){}
106
110
115 {
117 penalties_ = opt.penalties_;
118 charge_ = opt.charge_;
119
120 return *this;
121 }
122
124
125
130 inline const OptimizationFunctions::PenaltyFactorsIntensity & getPenalties() const { return penalties_; }
133 {
134 penalties_ = penalties;
135 param_.setValue("penalties:left_width", penalties_.lWidth);
136 param_.setValue("penalties:right_width", penalties_.rWidth);
137 param_.setValue("penalties:height", penalties_.height);
138 param_.setValue("penalties:position", penalties_.pos);
139 }
140
142 inline Int getCharge() const { return charge_; }
144 inline void setCharge(const Int charge) { charge_ = charge; }
146
147
149 bool optimize(std::vector<PeakShape> & peaks, Data & data);
150 Size getNumberOfPeaks_(Int charge, std::vector<PeakShape> & temp_shapes, Data & data);
151
152protected:
153 // Penalty factors for some parameter in the optimization
155
158
160 static const double dist_;
161
163 void setNumberOfPeaks_(Data & data, const std::vector<PeakShape> & temp_shapes, Int charge);
164
165 void updateMembers_() override;
166 }; // class
167
168} // namespace OpenMS
169
170
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
DefaultParamHandler & operator=(const DefaultParamHandler &rhs)
Assignment operator.
This class provides the deconvolution of peak regions using non-linear optimization.
Definition: OptimizePeakDeconvolution.h:72
OptimizationFunctions::PenaltyFactorsIntensity penalties_
Definition: OptimizePeakDeconvolution.h:154
std::vector< Peak1D > RawDataVector
Definition: OptimizePeakDeconvolution.h:77
OptimizePeakDeconvolution & operator=(const OptimizePeakDeconvolution &opt)
Definition: OptimizePeakDeconvolution.h:114
bool optimize(std::vector< PeakShape > &peaks, Data &data)
Performs a nonlinear optimization of the peaks that belong to the current isotope pattern.
RawDataVector::iterator PeakIterator
Definition: OptimizePeakDeconvolution.h:78
const OptimizationFunctions::PenaltyFactorsIntensity & getPenalties() const
Non-mutable access to the penalty parameter.
Definition: OptimizePeakDeconvolution.h:130
OptimizationFunctions::PenaltyFactorsIntensity penalties
Definition: OptimizePeakDeconvolution.h:89
std::vector< double > positions
Definition: OptimizePeakDeconvolution.h:87
Int getCharge() const
Non-mutable access to the charge.
Definition: OptimizePeakDeconvolution.h:142
Int charge
Definition: OptimizePeakDeconvolution.h:90
static const double dist_
distance between two isotopic peaks
Definition: OptimizePeakDeconvolution.h:160
Size getNumberOfPeaks_(Int charge, std::vector< PeakShape > &temp_shapes, Data &data)
void setNumberOfPeaks_(Data &data, const std::vector< PeakShape > &temp_shapes, Int charge)
A function to determine the number of peaks that lie in the current m/z interval given the distance b...
std::vector< PeakShape > peaks
Definition: OptimizePeakDeconvolution.h:86
~OptimizePeakDeconvolution() override
Destructor.
Definition: OptimizePeakDeconvolution.h:108
void setCharge(const Int charge)
Mutable access to the charge.
Definition: OptimizePeakDeconvolution.h:144
OptimizePeakDeconvolution(const OptimizePeakDeconvolution &opt)
Copy-Constructor.
Definition: OptimizePeakDeconvolution.h:102
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
void setPenalties(const OptimizationFunctions::PenaltyFactorsIntensity &penalties)
Mutable access to the penalty parameter.
Definition: OptimizePeakDeconvolution.h:132
Int charge_
Charge state of the current isotope pattern.
Definition: OptimizePeakDeconvolution.h:157
std::vector< double > signal
Definition: OptimizePeakDeconvolution.h:88
Class containing the data needed for optimization.
Definition: OptimizePeakDeconvolution.h:85
int Int
Signed integer type.
Definition: Types.h:76
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Class for the penalty factors used during the optimization.
Definition: OptimizePeakDeconvolution.h:33
PenaltyFactorsIntensity()
Definition: OptimizePeakDeconvolution.h:34
double height
Definition: OptimizePeakDeconvolution.h:50
~PenaltyFactorsIntensity()
Definition: OptimizePeakDeconvolution.h:48
PenaltyFactorsIntensity(const PenaltyFactorsIntensity &p)
Definition: OptimizePeakDeconvolution.h:36
PenaltyFactorsIntensity & operator=(const PenaltyFactorsIntensity &p)
Definition: OptimizePeakDeconvolution.h:38
Class for the penalty factors used during the optimization.
Definition: OptimizePick.h:43
double rWidth
Penalty factor for the peak shape's right width parameter.
Definition: OptimizePick.h:64
double pos
Penalty factor for the peak shape's position.
Definition: OptimizePick.h:60
double lWidth
Penalty factor for the peak shape's left width parameter.
Definition: OptimizePick.h:62