OpenMS
FeatureDistance.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Hendrik Weisser $
6 // $Authors: Clemens Groepl, Hendrik Weisser, Chris Bielow $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
13 
14 #include <limits>
15 
16 namespace OpenMS
17 {
63  class OPENMS_DLLAPI FeatureDistance :
64  public DefaultParamHandler
65  {
66 public:
68  static const double infinity;
69 
76  FeatureDistance(double max_intensity = 1.0,
77  bool force_constraints = false);
78 
80  ~FeatureDistance() override;
81 
84 
92  std::pair<bool, double> operator()(const BaseFeature & left,
93  const BaseFeature & right);
94 
95 protected:
96 
99  {
101 
102  DistanceParams_(const String & what, const Param & global)
103  {
104  Param param = global.copy("distance_" + what + ":", true);
105  if (what == "MZ")
106  {
107  max_diff_ppm = (param.getValue("unit") == "ppm");
108  }
109  else
110  {
111  max_diff_ppm = false;
112  }
113 
114  max_difference = param.getValue("max_difference");
115  exponent = param.getValue("exponent");
116  weight = param.getValue("weight");
117  norm_factor = 1 / max_difference;
118 
119  relevant = (weight != 0.0) && (exponent != 0.0);
120  if (!relevant)
121  {
122  weight = 0.0;
123  }
124  }
125 
126  double max_difference, exponent, weight, norm_factor;
127  bool max_diff_ppm, relevant;
128  };
129 
131  void updateMembers_() override;
132 
134  inline double distance_(double diff, const DistanceParams_ & params) const;
135 
137  DistanceParams_ params_rt_, params_mz_, params_intensity_;
138 
141 
144 
147 
150 
153 
156  };
157 
158 } // namespace OpenMS
159 
A basic LC-MS feature.
Definition: BaseFeature.h:33
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
A functor class for the calculation of distances between features or consensus features.
Definition: FeatureDistance.h:65
~FeatureDistance() override
Destructor.
static const double infinity
Value to return if max. difference is exceeded or if charge states don't match.
Definition: FeatureDistance.h:68
bool ignore_adduct_
Compute a distance even if adducts don't match?
Definition: FeatureDistance.h:149
std::pair< bool, double > operator()(const BaseFeature &left, const BaseFeature &right)
Evaluation operator - checks constraints and computes the distance between two features.
FeatureDistance & operator=(const FeatureDistance &other)
Assignment operator.
bool force_constraints_
Always return infinity if "max. difference" constraints are not met?
Definition: FeatureDistance.h:152
DistanceParams_ params_intensity_
Definition: FeatureDistance.h:137
double max_intensity_
Maximum intensity of features (for normalization)
Definition: FeatureDistance.h:143
bool log_transform_
Log-transform intensities when computing intensity distance?
Definition: FeatureDistance.h:155
double distance_(double diff, const DistanceParams_ &params) const
Computes a distance component given absolute difference and parameters.
void updateMembers_() override
Docu in base class.
FeatureDistance(double max_intensity=1.0, bool force_constraints=false)
Constructor.
bool ignore_charge_
Compute a distance even if charge states don't match?
Definition: FeatureDistance.h:146
double total_weight_reciprocal_
Reciprocal value of the total weight in the distance function.
Definition: FeatureDistance.h:140
Management and storage of parameters / INI files.
Definition: Param.h:44
Param copy(const std::string &prefix, bool remove_prefix=false) const
Returns a new Param object containing all entries that start with prefix.
const ParamValue & getValue(const std::string &key) const
Returns a value of a parameter.
A more convenient string class.
Definition: String.h:34
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Structure for storing distance parameters.
Definition: FeatureDistance.h:99
DistanceParams_()
Definition: FeatureDistance.h:100
bool max_diff_ppm
Definition: FeatureDistance.h:127
DistanceParams_(const String &what, const Param &global)
Definition: FeatureDistance.h:102
double exponent
Definition: FeatureDistance.h:126