| OpenMS 2.5.0

TransformationDescription.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: Clemens Groepl, Hendrik Weisser $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/DATASTRUCTURES/Param.h>
38 #include <OpenMS/ANALYSIS/MAPMATCHING/TransformationModel.h>
39 #include <iostream>
40 #include <map>
41
42 namespace OpenMS
43 {
61 class OPENMS_DLLAPI TransformationDescription
62 {
63 // friend class MapAlignmentAlgorithm;
64
65 public:
66
71 struct TransformationStatistics
72 {
73 TransformationStatistics& operator=(const TransformationStatistics& rhs)
74 {
75 if (this == &rhs)
76 return *this;
77
78 // percents = rhs.percents; // const, cannot be assigned
79 xmin = rhs.xmin;
80 xmax = rhs.xmax;
81 ymin = rhs.ymin;
82 ymax = rhs.ymax;
83 percentiles_before = rhs.percentiles_before;
84 percentiles_after = rhs.percentiles_after;
85
86 return *this;
87 }
88
89 const std::vector<Size> percents = {100, 99, 95, 90, 75, 50, 25};
90 double xmin = 0;
91 double xmax = 0;
92 double ymin = 0;
93 double ymax = 0;
94
95 std::map<Size, double> percentiles_before;
96 std::map<Size, double> percentiles_after;
97 };
98
99
101 typedef TransformationModel::DataPoint DataPoint;
103 typedef TransformationModel::DataPoints DataPoints;
104
106 TransformationDescription();
108 explicit TransformationDescription(const DataPoints& data);
110 ~TransformationDescription();
111
113 TransformationDescription(const TransformationDescription& rhs);
115 TransformationDescription& operator=(const TransformationDescription& rhs);
116
118 void fitModel(const String& model_type, const Param& params = Param());
119
126 double apply(double value) const;
127
129 const String& getModelType() const;
130
132 static void getModelTypes(StringList& result);
133
139 void setDataPoints(const DataPoints& data);
140
146 void setDataPoints(const std::vector<std::pair<double, double> >& data);
147
149 const DataPoints& getDataPoints() const;
150
152 const Param& getModelParameters() const;
153
155 void invert();
156
164 void getDeviations(std::vector<double>& diffs, bool do_apply = false,
165 bool do_sort = true) const;
166
168 TransformationStatistics getStatistics() const;
169
171 void printSummary(std::ostream& os = std::cout) const;
172
173 protected:
175 DataPoints data_;
177 String model_type_;
179 TransformationModel* model_;
180 };
181
182 } // end of namespace OpenMS
183
OpenMS::TransformationDescription::DataPoint
TransformationModel::DataPoint DataPoint
Coordinate pair.
Definition: TransformationDescription.h:101
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::TransformationDescription::TransformationStatistics::xmin
double xmin
smallest x value before transformation
Definition: TransformationDescription.h:90
OpenMS::TransformationDescription::TransformationStatistics::percentiles_after
std::map< Size, double > percentiles_after
percentiles of x/y deviations after transformation
Definition: TransformationDescription.h:96
OpenMS::TransformationDescription::TransformationStatistics::operator=
TransformationStatistics & operator=(const TransformationStatistics &rhs)
Definition: TransformationDescription.h:73
OpenMS::TransformationDescription::TransformationStatistics
Summary statistics before/after applying the transformation. For deviations before/after transformati...
Definition: TransformationDescription.h:71
OpenMS::TransformationDescription::TransformationStatistics::percentiles_before
std::map< Size, double > percentiles_before
percentiles of x/y deviations before transformation
Definition: TransformationDescription.h:95
OpenMS::TransformationModel::DataPoint
Coordinate pair (with optional annotation)
Definition: TransformationModel.h:57
OpenMS::TransformationDescription::model_
TransformationModel * model_
Pointer to model.
Definition: TransformationDescription.h:179
OpenMS::TransformationDescription
Generic description of a coordinate transformation.
Definition: TransformationDescription.h:61
OpenMS::TransformationModel::DataPoints
std::vector< DataPoint > DataPoints
Vector of coordinate pairs.
Definition: TransformationModel.h:90
OpenMS::TransformationDescription::model_type_
String model_type_
Type of model.
Definition: TransformationDescription.h:177
OpenMS::TransformationModel
Base class for transformation models.
Definition: TransformationModel.h:53
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::TransformationDescription::TransformationStatistics::ymin
double ymin
smallest y value before transformation
Definition: TransformationDescription.h:92
Param.h
TransformationModel.h
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:73
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::TransformationDescription::TransformationStatistics::ymax
double ymax
largest y value before transformation
Definition: TransformationDescription.h:93
OpenMS::TransformationDescription::data_
DataPoints data_
Data points.
Definition: TransformationDescription.h:175
OpenMS::TransformationDescription::DataPoints
TransformationModel::DataPoints DataPoints
Vector of coordinate pairs.
Definition: TransformationDescription.h:103
OpenMS::TransformationDescription::TransformationStatistics::xmax
double xmax
largest x value before transformation
Definition: TransformationDescription.h:91