OpenMS  2.5.0
FeatureDistance.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: Hendrik Weisser $
32 // $Authors: Clemens Groepl, Hendrik Weisser, Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 
40 #include <limits>
41 
42 namespace OpenMS
43 {
89  class OPENMS_DLLAPI FeatureDistance :
90  public DefaultParamHandler
91  {
92 public:
94  static const double infinity;
95 
102  FeatureDistance(double max_intensity = 1.0,
103  bool force_constraints = false);
104 
106  ~FeatureDistance() override;
107 
109  FeatureDistance & operator=(const FeatureDistance & other);
110 
118  std::pair<bool, double> operator()(const BaseFeature & left,
119  const BaseFeature & right);
120 
121 protected:
122 
125  {
127 
128  DistanceParams_(const String & what, const Param & global)
129  {
130  Param param = global.copy("distance_" + what + ":", true);
131  if (what == "MZ")
132  {
133  max_diff_ppm = (param.getValue("unit") == "ppm");
134  }
135  else
136  {
137  max_diff_ppm = false;
138  }
139 
140  max_difference = param.getValue("max_difference");
141  exponent = param.getValue("exponent");
142  weight = param.getValue("weight");
143  norm_factor = 1 / max_difference;
144 
145  relevant = (weight != 0.0) && (exponent != 0.0);
146  if (!relevant)
147  {
148  weight = 0.0;
149  }
150  }
151 
152  double max_difference, exponent, weight, norm_factor;
153  bool max_diff_ppm, relevant;
154  };
155 
157  void updateMembers_() override;
158 
160  inline double distance_(double diff, const DistanceParams_ & params) const;
161 
163  DistanceParams_ params_rt_, params_mz_, params_intensity_;
164 
167 
170 
173 
176 
179 
182  };
183 
184 } // namespace OpenMS
185 
DefaultParamHandler.h
OpenMS::Param::copy
Param copy(const String &prefix, bool remove_prefix=false) const
Returns a new Param object containing all entries that start with prefix.
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::FeatureDistance::DistanceParams_::weight
double weight
Definition: FeatureDistance.h:152
OpenMS::BaseFeature
A basic LC-MS feature.
Definition: BaseFeature.h:56
OpenMS::FeatureDistance::DistanceParams_::relevant
bool relevant
Definition: FeatureDistance.h:153
OpenMS::FeatureDistance::log_transform_
bool log_transform_
Log-transform intensities when computing intensity distance?
Definition: FeatureDistance.h:181
OpenMS::Param::getValue
const DataValue & getValue(const String &key) const
Returns a value of a parameter.
OpenMS::FeatureDistance::force_constraints_
bool force_constraints_
Always return infinity if "max. difference" constraints are not met?
Definition: FeatureDistance.h:178
OpenMS::FeatureDistance::DistanceParams_
Structure for storing distance parameters.
Definition: FeatureDistance.h:124
OpenMS::FeatureDistance::ignore_charge_
bool ignore_charge_
Compute a distance even if charge states don't match?
Definition: FeatureDistance.h:172
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
OpenMS::FeatureDistance::DistanceParams_::DistanceParams_
DistanceParams_(const String &what, const Param &global)
Definition: FeatureDistance.h:128
OpenMS::FeatureDistance::DistanceParams_::DistanceParams_
DistanceParams_()
Definition: FeatureDistance.h:126
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
BaseFeature.h
OpenMS::FeatureDistance::ignore_adduct_
bool ignore_adduct_
Compute a distance even if adducts don't match?
Definition: FeatureDistance.h:175
OpenMS::FeatureDistance
A functor class for the calculation of distances between features or consensus features.
Definition: FeatureDistance.h:89
OpenMS::FeatureDistance::max_intensity_
double max_intensity_
Maximum intensity of features (for normalization)
Definition: FeatureDistance.h:169
OpenMS::FeatureDistance::params_rt_
DistanceParams_ params_rt_
Storage of parameters for the individual distance components.
Definition: FeatureDistance.h:163
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:73
OpenMS::FeatureDistance::infinity
static const double infinity
Value to return if max. difference is exceeded or if charge states don't match.
Definition: FeatureDistance.h:94
OpenMS::FeatureDistance::total_weight_reciprocal_
double total_weight_reciprocal_
Reciprocal value of the total weight in the distance function.
Definition: FeatureDistance.h:166