OpenMS
Loading...
Searching...
No Matches
FeatureFindingMetabo.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- 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
20struct svm_model;
21
22namespace OpenMS
23{
24
33 class OPENMS_DLLAPI FeatureHypothesis
34 {
35public:
37 FeatureHypothesis() = default;
38
40 ~FeatureHypothesis() = default;
41
44
47
48 // getter & setter
49 Size getSize() const;
50
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&);
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
89private:
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 {
101public:
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 {
112public:
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 {
159public:
162
165
167 void run(std::vector<MassTrace>& input_mtraces, FeatureMap& output_featmap, std::vector<std::vector< OpenMS::MSChromatogram > >& output_chromatograms);
168
169protected:
170 void updateMembers_() override;
171
172private:
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
198 double computeCosineSim_(const std::vector<double>& vec1, const std::vector<double>& vec2) const;
199
212 int isLegalIsotopePattern_(const FeatureHypothesis& feat_hypo) const;
213
215
244 double scoreMZ_(const MassTrace& mt1, const MassTrace& mt2, Size isotopic_position, Size charge, Range isotope_window) const;
245
254 double scoreMZByExpectedMean_(Size iso_pos, Size charge, const double diff_mz, double mt_variances) const;
255
264 double scoreMZByExpectedRange_(Size charge, const double diff_mz, double mt_variances, Range isotope_window) const;
265
280 double scoreRT_(const MassTrace& mt1, const MassTrace& mt2) const;
281
291 double computeAveragineSimScore_(const std::vector<double>& intensities, const double& molecular_weight) const;
292
305 void findLocalFeatures_(const std::vector<const MassTrace*>& candidates, double total_intensity, std::vector<FeatureHypothesis>& output_hypotheses) const;
306
308 svm_model* isotope_filt_svm_ = nullptr;
309 std::vector<double> svm_feat_centers_;
310 std::vector<double> svm_feat_scales_;
311
312 //unused
313 //double total_intensity_;
314
321
327
332
334 std::vector<const Element*> elements_;
335 };
336
337}
338
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:324
double scoreRT_(const MassTrace &mt1, const MassTrace &mt2) const
Perform retention time scoring of two multiple mass traces.
Size charge_upper_bound_
Definition FeatureFindingMetabo.h:319
~FeatureFindingMetabo() override
Default destructor.
bool use_mz_scoring_C13_
Definition FeatureFindingMetabo.h:328
bool report_chromatograms_
Definition FeatureFindingMetabo.h:331
std::vector< double > svm_feat_centers_
Definition FeatureFindingMetabo.h:309
bool report_summed_ints_
Definition FeatureFindingMetabo.h:322
bool report_convex_hulls_
Definition FeatureFindingMetabo.h:330
Size charge_lower_bound_
Definition FeatureFindingMetabo.h:318
std::vector< const Element * > elementsFromString_(const std::string &elements_string) const
parses a string of element symbols into a vector of Elements
std::vector< double > svm_feat_scales_
Definition FeatureFindingMetabo.h:310
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...
double computeCosineSim_(const std::vector< double > &vec1, const std::vector< double > &vec2) const
Computes the cosine similarity between two vectors.
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:316
bool use_mz_scoring_by_element_range_
Definition FeatureFindingMetabo.h:329
double local_mz_range_
Definition FeatureFindingMetabo.h:317
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 scoreMZ_(const MassTrace &mt1, const MassTrace &mt2, Size isotopic_position, Size charge, Range isotope_window) const
Perform mass to charge scoring of two multiple mass traces.
std::vector< const Element * > elements_
Definition FeatureFindingMetabo.h:334
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:333
double chrom_fwhm_
Definition FeatureFindingMetabo.h:320
void loadIsotopeModel_(const String &)
bool report_smoothed_intensities_
Definition FeatureFindingMetabo.h:326
bool enable_RT_filtering_
Definition FeatureFindingMetabo.h:323
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:325
Internal structure used in FeatureFindingMetabo that keeps track of a feature hypothesis (isotope gro...
Definition FeatureFindingMetabo.h:34
double getCentroidMZ() const
FeatureHypothesis()=default
default constructor
void addMassTrace(const MassTrace &)
addMassTrace
void setCharge(const SignedSize &ch)
std::vector< double > getIsotopeDistances() const
FeatureHypothesis(const FeatureHypothesis &)=default
copy constructor
std::vector< OpenMS::MSChromatogram > getChromatograms(UInt64 feature_id) const
void setScore(const double &score)
std::vector< double > getAllCentroidRT() const
double getMonoisotopicFeatureIntensity(bool) const
std::vector< double > getAllIntensities(bool smoothed=false) const
std::vector< String > getLabels() const
std::vector< const MassTrace * > iso_pattern_
Definition FeatureFindingMetabo.h:92
std::vector< ConvexHull2D > getConvexHulls() const
double getSummedFeatureIntensity(bool) const
double getCentroidRT() const
~FeatureHypothesis()=default
default destructor
Size getNumFeatPoints() const
std::vector< double > getAllCentroidMZ() const
FeatureHypothesis & operator=(const FeatureHypothesis &rhs)=default
assignment operator
SignedSize getCharge() const
double getMaxIntensity(bool smoothed=false) const
return highest apex of all isotope traces
A container for features.
Definition FeatureMap.h:82
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