Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
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-2015.
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 #ifndef OPENMS_ANALYSIS_MAPMATCHING_FEATUREDISTANCE_H
36 #define OPENMS_ANALYSIS_MAPMATCHING_FEATUREDISTANCE_H
37 
40 
41 #include <limits>
42 
43 namespace OpenMS
44 {
76  class OPENMS_DLLAPI FeatureDistance :
77  public DefaultParamHandler
78  {
79 public:
81  static const double infinity;
82 
89  FeatureDistance(double max_intensity = 1.0,
90  bool force_constraints = false);
91 
93  virtual ~FeatureDistance();
94 
96  FeatureDistance & operator=(const FeatureDistance & other);
97 
103  std::pair<bool, double> operator()(const BaseFeature & left,
104  const BaseFeature & right);
105 
106 protected:
109  {
111 
112  DistanceParams_(const String & what, const Param & global)
113  {
114  Param param = global.copy("distance_" + what + ":", true);
115  if (what == "MZ") max_diff_ppm = param.getValue("unit") == "ppm";
116  else max_diff_ppm = false;
117  max_difference = param.getValue("max_difference");
118  exponent = param.getValue("exponent");
119  weight = param.getValue("weight");
120  norm_factor = 1 / max_difference;
121  relevant = (weight != 0.0) && (exponent != 0.0);
122  if (!relevant) weight = 0.0;
123  }
124 
125  double max_difference, exponent, weight, norm_factor;
126  bool max_diff_ppm, relevant;
127  };
128 
130  void updateMembers_();
131 
133  inline double distance_(double diff, const DistanceParams_ & params) const;
134 
136  DistanceParams_ params_rt_, params_mz_, params_intensity_;
137 
140 
143 
146 
149  };
150 
151 } // namespace OpenMS
152 
153 #endif // OPENMS_ANALYSIS_MAPMATCHING_FEATUREDISTANCE_H
A functor class for the calculation of distances between features or consensus features.
Definition: FeatureDistance.h:76
Structure for storing distance parameters.
Definition: FeatureDistance.h:108
A more convenient string class.
Definition: String.h:57
double weight
Definition: FeatureDistance.h:125
DistanceParams_()
Definition: FeatureDistance.h:110
double max_intensity_
Maximum intensity of features (for normalization)
Definition: FeatureDistance.h:142
A basic LC-MS feature.
Definition: BaseFeature.h:56
Param copy(const String &prefix, bool remove_prefix=false) const
Returns a new Param object containing all entries that start with prefix.
DistanceParams_(const String &what, const Param &global)
Definition: FeatureDistance.h:112
double total_weight_reciprocal_
Reciprocal value of the total weight in the distance function.
Definition: FeatureDistance.h:139
const DataValue & getValue(const String &key) const
Returns a value of a parameter.
DistanceParams_ params_rt_
Storage of parameters for the individual distance components.
Definition: FeatureDistance.h:136
static const double infinity
Value to return if max. difference is exceeded or if charge states don&#39;t match.
Definition: FeatureDistance.h:81
Management and storage of parameters / INI files.
Definition: Param.h:75
bool force_constraints_
Always return infinity if &quot;max. difference&quot; constraints are not met?
Definition: FeatureDistance.h:148
bool ignore_charge_
Compute a distance even if charge states don&#39;t match?
Definition: FeatureDistance.h:145
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
bool relevant
Definition: FeatureDistance.h:126

OpenMS / TOPP release 2.0.0 Documentation generated on Wed Mar 30 2016 16:18:38 using doxygen 1.8.5