OpenMS  2.7.0
TransformationModel.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-2021.
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: Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
40 
41 #include <tuple>
42 
43 namespace OpenMS
44 {
54  class OPENMS_DLLAPI TransformationModel
55  {
56  public:
58  struct DataPoint
59  {
60  double first, second;
62 
63  DataPoint(double first_ = 0.0,
64  double second_ = 0.0,
65  const String& note_ = "") :
66  first(first_),
67  second(second_),
68  note(note_)
69  {}
70 
71  DataPoint(const std::pair<double, double>& pair) :
72  first(pair.first),
73  second(pair.second),
74  note("")
75  {}
76 
77  bool operator<(const DataPoint& other) const
78  {
79  return (std::tie(first, second, note) <
80  std::tie(other.first, other.second, other.note));
81  }
82 
83  bool operator==(const DataPoint& other) const
84  {
85  return (std::tie(first, second, note) ==
86  std::tie(other.first, other.second, other.note));
87  }
88  };
89 
91  typedef std::vector<DataPoint> DataPoints;
92 
95 
99 
102 
104  virtual double evaluate(double value) const;
105 
119  virtual void weightData(DataPoints& data);
120 
124  virtual void unWeightData(DataPoints& data);
125 
129  bool checkValidWeight(const String& weight, const std::vector<String>& valid_weights) const;
130 
138  double checkDatumRange(const double& datum, const double& datum_min, const double& datum_max);
139 
143  double weightDatum(const double& datum, const String& weight) const;
144 
148  double unWeightDatum(const double& datum, const String& weight) const;
149 
151  const Param& getParameters() const;
152 
154  std::vector<String> getValidXWeights() const;
155 
157  std::vector<String> getValidYWeights() const;
158 
160  static void getDefaultParameters(Param& params);
161 
162  protected:
167  double x_datum_min_;
168  double x_datum_max_;
171  double y_datum_min_;
172  double y_datum_max_;
174 
175  private:
180 
181  };
182 
183 } // end of namespace OpenMS
184 
Management and storage of parameters / INI files.
Definition: Param.h:70
A more convenient string class.
Definition: String.h:61
Base class for transformation models.
Definition: TransformationModel.h:55
bool checkValidWeight(const String &weight, const std::vector< String > &valid_weights) const
Check for a valid weighting function string.
std::vector< String > getValidXWeights() const
Returns a list of valid x weight function strings.
const Param & getParameters() const
Gets the (actual) parameters.
Param params_
Parameters.
Definition: TransformationModel.h:164
TransformationModel()
Constructor.
Definition: TransformationModel.h:94
TransformationModel(const TransformationModel::DataPoints &, const Param &)
static void getDefaultParameters(Param &params)
Gets the default parameters.
bool weighting_
Definition: TransformationModel.h:173
std::vector< DataPoint > DataPoints
Vector of coordinate pairs.
Definition: TransformationModel.h:91
double x_datum_max_
Definition: TransformationModel.h:168
String y_weight_
y weighting
Definition: TransformationModel.h:170
virtual double evaluate(double value) const
Evaluates the model at the given value.
double checkDatumRange(const double &datum, const double &datum_min, const double &datum_max)
Check that the datum is within the valid min and max bounds.
TransformationModel(const TransformationModel &)
do not allow copy
virtual ~TransformationModel()
Destructor.
double weightDatum(const double &datum, const String &weight) const
Weight the data according to the weighting function.
std::vector< String > getValidYWeights() const
Returns a list of valid y weight function strings.
double unWeightDatum(const double &datum, const String &weight) const
Apply the reverse of the weighting function to the data.
virtual void unWeightData(DataPoints &data)
Unweight the data by the given weight function.
virtual void weightData(DataPoints &data)
Weight the data by the given weight function.
double y_datum_min_
Definition: TransformationModel.h:171
double x_datum_min_
Definition: TransformationModel.h:167
const TransformationModel & operator=(const TransformationModel &)
do not allow assignment
String x_weight_
x weighting
Definition: TransformationModel.h:166
double y_datum_max_
Definition: TransformationModel.h:172
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
Coordinate pair (with optional annotation)
Definition: TransformationModel.h:59
double second
Definition: TransformationModel.h:60
String note
Definition: TransformationModel.h:61
bool operator<(const DataPoint &other) const
Definition: TransformationModel.h:77
DataPoint(double first_=0.0, double second_=0.0, const String &note_="")
Definition: TransformationModel.h:63
DataPoint(const std::pair< double, double > &pair)
Definition: TransformationModel.h:71
double first
Definition: TransformationModel.h:60
bool operator==(const DataPoint &other) const
Definition: TransformationModel.h:83