OpenMS  2.4.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-2018.
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 namespace OpenMS
41 {
51  class OPENMS_DLLAPI TransformationModel
52  {
53  public:
55  struct DataPoint
56  {
57  double first, second;
59 
60  DataPoint(double first_ = 0.0,
61  double second_ = 0.0,
62  const String& note_ = "") :
63  first(first_),
64  second(second_),
65  note(note_)
66  {}
67 
68  DataPoint(const std::pair<double, double>& pair) :
69  first(pair.first),
70  second(pair.second),
71  note("")
72  {}
73 
74  bool operator<(const DataPoint& other) const
75  {
76  return (std::tie(first, second, note) <
77  std::tie(other.first, other.second, other.note));
78  }
79 
80  bool operator==(const DataPoint& other) const
81  {
82  return (std::tie(first, second, note) ==
83  std::tie(other.first, other.second, other.note));
84  }
85  };
86 
88  typedef std::vector<DataPoint> DataPoints;
89 
92 
96 
98  virtual ~TransformationModel();
99 
101  virtual double evaluate(double value) const;
102 
116  virtual void weightData(DataPoints& data);
117 
121  virtual void unWeightData(DataPoints& data);
122 
126  bool checkValidWeight(const String& weight, const std::vector<String>& valid_weights) const;
127 
135  double checkDatumRange(const double& datum, const double& datum_min, const double& datum_max);
136 
140  double weightDatum(const double& datum, const String& weight) const;
141 
145  double unWeightDatum(const double& datum, const String& weight) const;
146 
148  const Param& getParameters() const;
149 
151  std::vector<String> getValidXWeights() const;
152 
154  std::vector<String> getValidYWeights() const;
155 
157  static void getDefaultParameters(Param& params);
158 
159  protected:
164  double x_datum_min_;
165  double x_datum_max_;
168  double y_datum_min_;
169  double y_datum_max_;
171 
172  private:
176  const TransformationModel& operator=(const TransformationModel&);
177 
178  };
179 
180 } // end of namespace OpenMS
181 
Param params_
Parameters.
Definition: TransformationModel.h:161
TransformationModel()
Constructor.
Definition: TransformationModel.h:91
A more convenient string class.
Definition: String.h:57
DataPoint(double first_=0.0, double second_=0.0, const String &note_="")
Definition: TransformationModel.h:60
String note
Definition: TransformationModel.h:58
double y_datum_max_
Definition: TransformationModel.h:169
String x_weight_
x weighting
Definition: TransformationModel.h:163
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
bool operator<(const DataPoint &other) const
Definition: TransformationModel.h:74
double y_datum_min_
Definition: TransformationModel.h:168
DataPoint(const std::pair< double, double > &pair)
Definition: TransformationModel.h:68
Management and storage of parameters / INI files.
Definition: Param.h:74
double second
Definition: TransformationModel.h:57
double first
Definition: TransformationModel.h:57
std::vector< DataPoint > DataPoints
Vector of coordinate pairs.
Definition: TransformationModel.h:88
double x_datum_max_
Definition: TransformationModel.h:165
Base class for transformation models.
Definition: TransformationModel.h:51
double x_datum_min_
Definition: TransformationModel.h:164
String y_weight_
y weighting
Definition: TransformationModel.h:167
bool operator==(const DataPoint &other) const
Definition: TransformationModel.h:80
bool weighting_
Definition: TransformationModel.h:170
Coordinate pair (with optional annotation)
Definition: TransformationModel.h:55