OpenMS  2.5.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-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: Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 
40 #include <tuple>
41 
42 namespace OpenMS
43 {
53  class OPENMS_DLLAPI TransformationModel
54  {
55  public:
57  struct DataPoint
58  {
59  double first, second;
61 
62  DataPoint(double first_ = 0.0,
63  double second_ = 0.0,
64  const String& note_ = "") :
65  first(first_),
66  second(second_),
67  note(note_)
68  {}
69 
70  DataPoint(const std::pair<double, double>& pair) :
71  first(pair.first),
72  second(pair.second),
73  note("")
74  {}
75 
76  bool operator<(const DataPoint& other) const
77  {
78  return (std::tie(first, second, note) <
79  std::tie(other.first, other.second, other.note));
80  }
81 
82  bool operator==(const DataPoint& other) const
83  {
84  return (std::tie(first, second, note) ==
85  std::tie(other.first, other.second, other.note));
86  }
87  };
88 
90  typedef std::vector<DataPoint> DataPoints;
91 
94 
98 
100  virtual ~TransformationModel();
101 
103  virtual double evaluate(double value) const;
104 
118  virtual void weightData(DataPoints& data);
119 
123  virtual void unWeightData(DataPoints& data);
124 
128  bool checkValidWeight(const String& weight, const std::vector<String>& valid_weights) const;
129 
137  double checkDatumRange(const double& datum, const double& datum_min, const double& datum_max);
138 
142  double weightDatum(const double& datum, const String& weight) const;
143 
147  double unWeightDatum(const double& datum, const String& weight) const;
148 
150  const Param& getParameters() const;
151 
153  std::vector<String> getValidXWeights() const;
154 
156  std::vector<String> getValidYWeights() const;
157 
159  static void getDefaultParameters(Param& params);
160 
161  protected:
166  double x_datum_min_;
167  double x_datum_max_;
170  double y_datum_min_;
171  double y_datum_max_;
173 
174  private:
178  const TransformationModel& operator=(const TransformationModel&);
179 
180  };
181 
182 } // end of namespace OpenMS
183 
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:144
OpenMS::TransformationModel::DataPoint::DataPoint
DataPoint(const std::pair< double, double > &pair)
Definition: TransformationModel.h:70
OpenMS::TransformationModel::DataPoint::first
double first
Definition: TransformationModel.h:59
OpenMS::TransformationModel::weighting_
bool weighting_
Definition: TransformationModel.h:172
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::TransformationModel::x_datum_min_
double x_datum_min_
Definition: TransformationModel.h:166
OpenMS::TransformationModel::y_datum_max_
double y_datum_max_
Definition: TransformationModel.h:171
OpenMS::TransformationModel::DataPoint::second
double second
Definition: TransformationModel.h:59
OpenMS::Exception::InvalidParameter
Exception indicating that an invalid parameter was handed over to an algorithm.
Definition: Exception.h:347
OpenMS::TransformationModel::params_
Param params_
Parameters.
Definition: TransformationModel.h:163
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::TransformationModel::DataPoint::DataPoint
DataPoint(double first_=0.0, double second_=0.0, const String &note_="")
Definition: TransformationModel.h:62
OpenMS::TransformationModel::x_datum_max_
double x_datum_max_
Definition: TransformationModel.h:167
OpenMS::TransformationModel::DataPoint::note
String note
Definition: TransformationModel.h:60
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:82
OpenMS::TransformationModel
Base class for transformation models.
Definition: TransformationModel.h:53
Param.h
MathFunctions.h
OpenMS::TransformationModel::x_weight_
String x_weight_
x weighting
Definition: TransformationModel.h:165
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:65
OpenMS::TransformationModel::y_datum_min_
double y_datum_min_
Definition: TransformationModel.h:170
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:73
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:76
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:73
OpenMS::TransformationModel::DataPoints
std::vector< DataPoint > DataPoints
Vector of coordinate pairs.
Definition: TransformationModel.h:90
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:57
OpenMS::TransformationDescription::DataPoints
TransformationModel::DataPoints DataPoints
Vector of coordinate pairs.
Definition: TransformationDescription.h:103
OpenMS::TransformationModel::TransformationModel
TransformationModel()
Constructor.
Definition: TransformationModel.h:93
OpenMS::TransformationModel::y_weight_
String y_weight_
y weighting
Definition: TransformationModel.h:169
OpenMS::TransformationDescription
Generic description of a coordinate transformation.
Definition: TransformationDescription.h:61
StandardTypes.h
TOPPBase.h