OpenMS  3.0.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-2022.
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 
101  virtual ~TransformationModel();
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:
179  const TransformationModel& operator=(const TransformationModel&);
180 
181  };
182 
183 } // end of namespace OpenMS
184 
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:147
OpenMS::TransformationModel::DataPoint::DataPoint
DataPoint(const std::pair< double, double > &pair)
Definition: TransformationModel.h:71
OpenMS::TransformationModel::DataPoint::first
double first
Definition: TransformationModel.h:60
OpenMS::TransformationModel::weighting_
bool weighting_
Definition: TransformationModel.h:173
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::TransformationModel::x_datum_min_
double x_datum_min_
Definition: TransformationModel.h:167
OpenMS::TransformationModel::y_datum_max_
double y_datum_max_
Definition: TransformationModel.h:172
OpenMS::TransformationModel::DataPoint::second
double second
Definition: TransformationModel.h:60
OpenMS::Exception::InvalidParameter
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:339
OpenMS::TransformationModel::params_
Param params_
Parameters.
Definition: TransformationModel.h:164
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::TransformationModel::DataPoint::DataPoint
DataPoint(double first_=0.0, double second_=0.0, const String &note_="")
Definition: TransformationModel.h:63
OpenMS::TransformationModel::x_datum_max_
double x_datum_max_
Definition: TransformationModel.h:168
OpenMS::TransformationModel::DataPoint::note
String note
Definition: TransformationModel.h:61
TransformationXMLFile.h
OpenMS::TransformationDescription::getDataPoints
const DataPoints & getDataPoints() const
Returns the data points.
OpenMS::TransformationModel::DataPoint::operator==
bool operator==(const DataPoint &other) const
Definition: TransformationModel.h:83
OpenMS::TransformationModel
Base class for transformation models.
Definition: TransformationModel.h:54
Param.h
MathFunctions.h
OpenMS::TransformationModel::x_weight_
String x_weight_
x weighting
Definition: TransformationModel.h:166
OpenMS::TransformationDescription::apply
double apply(double value) const
Applies the transformation to value.
OpenMS::Math::ceilDecimal
static double ceilDecimal(double x, int decPow)
rounds x up to the next decimal power 10 ^ decPow
Definition: MathFunctions.h:93
OpenMS::TransformationModel::y_datum_min_
double y_datum_min_
Definition: TransformationModel.h:171
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:71
OpenMS::TransformationXMLFile::load
void load(const String &filename, TransformationDescription &transformation, bool fit_model=true)
Loads the transformation from an TransformationXML file.
OpenMS::TransformationXMLFile
Used to load and store TransformationXML files.
Definition: TransformationXMLFile.h:56
OpenMS::TransformationModel::DataPoint::operator<
bool operator<(const DataPoint &other) const
Definition: TransformationModel.h:77
String.h
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:69
OpenMS::TransformationModel::DataPoints
std::vector< DataPoint > DataPoints
Vector of coordinate pairs.
Definition: TransformationModel.h:91
OpenMS::TransformationXMLFile::store
void store(String filename, const TransformationDescription &transformation)
Stores the data in an TransformationXML file.
OpenMS::TransformationModel::DataPoint
Coordinate pair (with optional annotation)
Definition: TransformationModel.h:58
OpenMS::TransformationDescription::DataPoints
TransformationModel::DataPoints DataPoints
Vector of coordinate pairs.
Definition: TransformationDescription.h:97
OpenMS::TransformationModel::TransformationModel
TransformationModel()
Constructor.
Definition: TransformationModel.h:94
OpenMS::TransformationModel::y_weight_
String y_weight_
y weighting
Definition: TransformationModel.h:170
OpenMS::TransformationDescription
Generic description of a coordinate transformation.
Definition: TransformationDescription.h:62
StandardTypes.h
TOPPBase.h