OpenMS
FeatureFindingMetabo.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Timo Sachsenberg $
6 // $Authors: Erhan Kenar, Holger Franken $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
17 
18 #include <vector>
19 
20 struct svm_model;
21 
22 namespace OpenMS
23 {
24 
33  class OPENMS_DLLAPI FeatureHypothesis
34  {
35 public:
37  FeatureHypothesis() = default;
38 
40  ~FeatureHypothesis() = default;
41 
44 
47 
48  // getter & setter
49  Size getSize() const;
50 
51  String getLabel() const;
52 
53  std::vector<String> getLabels() const;
54 
55  double getScore() const;
56 
57  void setScore(const double& score);
58 
60 
61  void setCharge(const SignedSize& ch);
62 
63  std::vector<double> getAllIntensities(bool smoothed = false) const;
64 
65  std::vector<double> getAllCentroidMZ() const;
66 
67  std::vector<double> getAllCentroidRT() const;
68 
69  std::vector<double> getIsotopeDistances() const;
70 
71  double getCentroidMZ() const;
72 
73  double getCentroidRT() const;
74 
75  double getFWHM() const;
76 
78  void addMassTrace(const MassTrace&);
79  double getMonoisotopicFeatureIntensity(bool) const;
80  double getSummedFeatureIntensity(bool) const;
81 
83  double getMaxIntensity(bool smoothed = false) const;
84 
86  std::vector<ConvexHull2D> getConvexHulls() const;
87  std::vector< OpenMS::MSChromatogram > getChromatograms(UInt64 feature_id) const;
88 
89 private:
90 
91  // pointers of MassTraces contained in isotopic pattern
92  std::vector<const MassTrace*> iso_pattern_;
93 
94  double feat_score_{};
95 
96  SignedSize charge_{};
97  };
98 
99  class OPENMS_DLLAPI CmpMassTraceByMZ
100  {
101 public:
102 
103  bool operator()(const MassTrace& x, const MassTrace& y) const
104  {
105  return x.getCentroidMZ() < y.getCentroidMZ();
106  }
107 
108  };
109 
110  class OPENMS_DLLAPI CmpHypothesesByScore
111  {
112 public:
113 
114  bool operator()(const FeatureHypothesis& x, const FeatureHypothesis& y) const
115  {
116  return x.getScore() > y.getScore();
117  }
118 
119  };
120 
124  struct OPENMS_DLLAPI Range
125 {
128 };
129 
155  class OPENMS_DLLAPI FeatureFindingMetabo :
156  public DefaultParamHandler,
157  public ProgressLogger
158  {
159 public:
162 
165 
167  void run(std::vector<MassTrace>& input_mtraces, FeatureMap& output_featmap, std::vector<std::vector< OpenMS::MSChromatogram > >& output_chromatograms);
168 
169 protected:
170  void updateMembers_() override;
171 
172 private:
178  std::vector<const Element*> elementsFromString_(const std::string& elements_string) const;
186  Range getTheoreticIsotopicMassWindow_(const std::vector<Element const *>& alphabet, int peakOffset) const;
187 
196  double computeCosineSim_(const std::vector<double>&, const std::vector<double>&) const;
197 
210  int isLegalIsotopePattern_(const FeatureHypothesis& feat_hypo) const;
211 
212  void loadIsotopeModel_(const String&);
213 
237  double scoreMZ_(const MassTrace &, const MassTrace &, Size isotopic_position, Size charge, Range isotope_window) const;
238 
247  double scoreMZByExpectedMean_(Size iso_pos, Size charge, const double diff_mz, double mt_variances) const;
248 
257  double scoreMZByExpectedRange_(Size charge, const double diff_mz, double mt_variances, Range isotope_window) const;
258 
270  double scoreRT_(const MassTrace&, const MassTrace&) const;
271 
278  double computeAveragineSimScore_(const std::vector<double>& intensities, const double& molecular_weight) const;
279 
288  void findLocalFeatures_(const std::vector<const MassTrace*>& candidates, double total_intensity, std::vector<FeatureHypothesis>& output_hypotheses) const;
289 
291  svm_model* isotope_filt_svm_ = nullptr;
292  std::vector<double> svm_feat_centers_;
293  std::vector<double> svm_feat_scales_;
294 
295  //unused
296  //double total_intensity_;
297 
303  double chrom_fwhm_;
304 
309 
314 
316  std::vector<const Element*> elements_;
317  };
318 
319 }
320 
Definition: FeatureFindingMetabo.h:111
bool operator()(const FeatureHypothesis &x, const FeatureHypothesis &y) const
Definition: FeatureFindingMetabo.h:114
Definition: FeatureFindingMetabo.h:100
bool operator()(const MassTrace &x, const MassTrace &y) const
Definition: FeatureFindingMetabo.h:103
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
Method for the assembly of mass traces belonging to the same isotope pattern, i.e....
Definition: FeatureFindingMetabo.h:158
void findLocalFeatures_(const std::vector< const MassTrace * > &candidates, double total_intensity, std::vector< FeatureHypothesis > &output_hypotheses) const
Identify groupings of mass traces based on a set of reasonable candidates.
FeatureFindingMetabo()
Default constructor.
String isotope_filtering_model_
Definition: FeatureFindingMetabo.h:307
std::vector< const Element * > elementsFromString_(const std::string &elements_string) const
parses a string of element symbols into a vector of Elements
Size charge_upper_bound_
Definition: FeatureFindingMetabo.h:302
~FeatureFindingMetabo() override
Default destructor.
bool use_mz_scoring_C13_
Definition: FeatureFindingMetabo.h:310
bool report_chromatograms_
Definition: FeatureFindingMetabo.h:313
std::vector< double > svm_feat_centers_
Definition: FeatureFindingMetabo.h:292
double scoreMZ_(const MassTrace &, const MassTrace &, Size isotopic_position, Size charge, Range isotope_window) const
Perform mass to charge scoring of two multiple mass traces.
bool report_summed_ints_
Definition: FeatureFindingMetabo.h:305
bool report_convex_hulls_
Definition: FeatureFindingMetabo.h:312
Size charge_lower_bound_
Definition: FeatureFindingMetabo.h:301
double computeCosineSim_(const std::vector< double > &, const std::vector< double > &) const
Computes the cosine similarity between two vectors.
std::vector< double > svm_feat_scales_
Definition: FeatureFindingMetabo.h:293
double scoreMZByExpectedRange_(Size charge, const double diff_mz, double mt_variances, Range isotope_window) const
score isotope m/z distance based on an expected isotope window which was calculated from a set of exp...
void run(std::vector< MassTrace > &input_mtraces, FeatureMap &output_featmap, std::vector< std::vector< OpenMS::MSChromatogram > > &output_chromatograms)
main method of FeatureFindingMetabo
double local_rt_range_
parameter stuff
Definition: FeatureFindingMetabo.h:299
bool use_mz_scoring_by_element_range_
Definition: FeatureFindingMetabo.h:311
double local_mz_range_
Definition: FeatureFindingMetabo.h:300
double scoreMZByExpectedMean_(Size iso_pos, Size charge, const double diff_mz, double mt_variances) const
score isotope m/z distance based on the expected m/z distances using C13-C12 or Kenar method
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
double scoreRT_(const MassTrace &, const MassTrace &) const
Perform retention time scoring of two multiple mass traces.
std::vector< const Element * > elements_
Definition: FeatureFindingMetabo.h:316
int isLegalIsotopePattern_(const FeatureHypothesis &feat_hypo) const
Compare intensities of feature hypothesis with model.
Range getTheoreticIsotopicMassWindow_(const std::vector< Element const * > &alphabet, int peakOffset) const
bool remove_single_traces_
Definition: FeatureFindingMetabo.h:315
double chrom_fwhm_
Definition: FeatureFindingMetabo.h:303
void loadIsotopeModel_(const String &)
bool enable_RT_filtering_
Definition: FeatureFindingMetabo.h:306
double computeAveragineSimScore_(const std::vector< double > &intensities, const double &molecular_weight) const
Perform intensity scoring using the averagine model (for peptides only)
bool use_smoothed_intensities_
Definition: FeatureFindingMetabo.h:308
Internal structure used in FeatureFindingMetabo that keeps track of a feature hypothesis (isotope gro...
Definition: FeatureFindingMetabo.h:34
std::vector< String > getLabels() const
double getCentroidMZ() const
FeatureHypothesis()=default
default constructor
void addMassTrace(const MassTrace &)
addMassTrace
void setCharge(const SignedSize &ch)
FeatureHypothesis(const FeatureHypothesis &)=default
copy constructor
std::vector< double > getAllCentroidRT() const
FeatureHypothesis & operator=(const FeatureHypothesis &rhs)=default
assignment operator
std::vector< OpenMS::MSChromatogram > getChromatograms(UInt64 feature_id) const
std::vector< double > getAllIntensities(bool smoothed=false) const
void setScore(const double &score)
std::vector< double > getAllCentroidMZ() const
std::vector< ConvexHull2D > getConvexHulls() const
double getMonoisotopicFeatureIntensity(bool) const
std::vector< const MassTrace * > iso_pattern_
Definition: FeatureFindingMetabo.h:92
double getSummedFeatureIntensity(bool) const
std::vector< double > getIsotopeDistances() const
double getCentroidRT() const
~FeatureHypothesis()=default
default destructor
Size getNumFeatPoints() const
SignedSize getCharge() const
double getMaxIntensity(bool smoothed=false) const
return highest apex of all isotope traces
A container for features.
Definition: FeatureMap.h:80
A container type that gathers peaks similar in m/z and moving along retention time.
Definition: MassTrace.h:36
double getCentroidMZ() const
Returns the centroid m/z.
Definition: MassTrace.h:153
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
A more convenient string class.
Definition: String.h:34
uint64_t UInt64
Unsigned integer type (64bit)
Definition: Types.h:47
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:104
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:97
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
double left_boundary
Definition: FeatureFindingMetabo.h:126
double right_boundary
Definition: FeatureFindingMetabo.h:127
Internal structure to store a lower and upper bound of an m/z range.
Definition: FeatureFindingMetabo.h:125