OpenMS  2.5.0
FeatureFindingMetabo.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: Timo Sachsenberg $
32 // $Authors: Erhan Kenar, Holger Franken $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
43 
44 #include <vector>
45 #include <svm.h>
46 
47 namespace OpenMS
48 {
49 
58  class OPENMS_DLLAPI FeatureHypothesis
59  {
60 public:
63 
66 
69 
71  FeatureHypothesis& operator=(const FeatureHypothesis& rhs);
72 
73  // getter & setter
74  Size getSize() const;
75 
76  String getLabel() const;
77 
78  std::vector<String> getLabels() const;
79 
80  double getScore() const;
81 
82  void setScore(const double& score);
83 
84  SignedSize getCharge() const;
85 
86  void setCharge(const SignedSize& ch);
87 
88  std::vector<double> getAllIntensities(bool smoothed = false) const;
89 
90  std::vector<double> getAllCentroidMZ() const;
91 
92  std::vector<double> getAllCentroidRT() const;
93 
94  std::vector<double> getIsotopeDistances() const;
95 
96  double getCentroidMZ() const;
97 
98  double getCentroidRT() const;
99 
100  double getFWHM() const;
101 
103  void addMassTrace(const MassTrace&);
104  double getMonoisotopicFeatureIntensity(bool) const;
105  double getSummedFeatureIntensity(bool) const;
106 
107  Size getNumFeatPoints() const;
108  std::vector<ConvexHull2D> getConvexHulls() const;
109  std::vector< OpenMS::MSChromatogram > getChromatograms(UInt64 feature_id) const;
110 
111 private:
112 
113  // pointers of MassTraces contained in isotopic pattern
114  std::vector<const MassTrace*> iso_pattern_;
115 
116  double feat_score_;
117 
119  };
120 
121  class OPENMS_DLLAPI CmpMassTraceByMZ
122  {
123 public:
124 
125  bool operator()(const MassTrace& x, const MassTrace& y) const
126  {
127  return x.getCentroidMZ() < y.getCentroidMZ();
128  }
129 
130  };
131 
132  class OPENMS_DLLAPI CmpHypothesesByScore
133  {
134 public:
135 
136  bool operator()(const FeatureHypothesis& x, const FeatureHypothesis& y) const
137  {
138  return x.getScore() > y.getScore();
139  }
140 
141  };
142 
146  struct OPENMS_DLLAPI Range
147 {
150 };
151 
177  class OPENMS_DLLAPI FeatureFindingMetabo :
178  public DefaultParamHandler,
179  public ProgressLogger
180  {
181 public:
184 
186  ~FeatureFindingMetabo() override;
187 
189  void run(std::vector<MassTrace>& input_mtraces, FeatureMap& output_featmap, std::vector<std::vector< OpenMS::MSChromatogram > >& output_chromatograms);
190 
191 protected:
192  void updateMembers_() override;
193 
194 private:
200  std::vector<const Element*> elementsFromString_(const std::string& elements_string) const;
208  Range getTheoreticIsotopicMassWindow_(const std::vector<Element const *> alphabet, int peakOffset) const;
209 
218  double computeCosineSim_(const std::vector<double>&, const std::vector<double>&) const;
219 
232  int isLegalIsotopePattern_(const FeatureHypothesis& feat_hypo) const;
233 
234  void loadIsotopeModel_(const String&);
235 
259  double scoreMZ_(const MassTrace &, const MassTrace &, Size isotopic_position, Size charge, Range isotope_window) const;
260 
269  double scoreMZByExpectedMean_(Size iso_pos, Size charge, const double diff_mz, double mt_variances) const;
270 
279  double scoreMZByExpectedRange_(Size charge, const double diff_mz, double mt_variances, Range isotope_window) const;
280 
293  double scoreRT_(const MassTrace&, const MassTrace&) const;
294 
301  double computeAveragineSimScore_(const std::vector<double>& intensities, const double& molecular_weight) const;
302 
311  void findLocalFeatures_(const std::vector<const MassTrace*>& candidates, double total_intensity, std::vector<FeatureHypothesis>& output_hypotheses) const;
312 
314  svm_model* isotope_filt_svm_;
315  std::vector<double> svm_feat_centers_;
316  std::vector<double> svm_feat_scales_;
317 
319 
325  double chrom_fwhm_;
326 
331 
336 
338  std::vector<const Element*> elements_;
339  };
340 
341 }
342 
DefaultParamHandler.h
OpenMS::UniqueIdInterface::ensureUniqueId
Size ensureUniqueId()
Assigns a valid unique id, but only if the present one is invalid. Returns 1 if the unique id was cha...
Definition: UniqueIdInterface.h:154
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:144
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::UInt64
OPENMS_UINT64_TYPE UInt64
Unsigned integer type (64bit)
Definition: Types.h:77
OpenMS::FeatureFindingMetabo::charge_lower_bound_
Size charge_lower_bound_
Definition: FeatureFindingMetabo.h:323
OpenMS::FeatureFindingMetabo::enable_RT_filtering_
bool enable_RT_filtering_
Definition: FeatureFindingMetabo.h:328
OpenMS::File::basename
static String basename(const String &file)
Returns the basename of the file (without the path).
OpenMS::FeatureFindingMetabo::report_chromatograms_
bool report_chromatograms_
Definition: FeatureFindingMetabo.h:335
OpenMS::FeatureFindingMetabo::chrom_fwhm_
double chrom_fwhm_
Definition: FeatureFindingMetabo.h:325
OpenMS::MzMLFile
File adapter for MzML files.
Definition: MzMLFile.h:55
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::FeatureFindingMetabo::local_rt_range_
double local_rt_range_
parameter stuff
Definition: FeatureFindingMetabo.h:321
MzMLFile.h
OpenMS::MassTrace
A container type that gathers peaks similar in m/z and moving along retention time.
Definition: MassTrace.h:61
Feature.h
OpenMS::FeatureFindingMetabo
Method for the assembly of mass traces belonging to the same isotope pattern, i.e....
Definition: FeatureFindingMetabo.h:177
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenMS::PeakFileOptions::addMSLevel
void addMSLevel(int level)
adds a desired MS level for peaks to load
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
FeatureXMLFile.h
OpenMS::FeatureFindingMetabo::use_mz_scoring_C13_
bool use_mz_scoring_C13_
Definition: FeatureFindingMetabo.h:332
OpenMS::FeatureHypothesis::charge_
SignedSize charge_
Definition: FeatureFindingMetabo.h:118
OpenMS::FeatureMap::setPrimaryMSRunPath
void setPrimaryMSRunPath(const StringList &s)
set the file path to the primary MS run (usually the mzML file obtained after data conversion from ra...
OpenMS::CmpHypothesesByScore::operator()
bool operator()(const FeatureHypothesis &x, const FeatureHypothesis &y) const
Definition: FeatureFindingMetabo.h:136
OPENMS_LOG_WARN
#define OPENMS_LOG_WARN
Macro if a warning, a piece of information which should be read by the user, should be logged.
Definition: LogStream.h:460
OpenMS::MSExperiment::size
Size size() const
Definition: MSExperiment.h:127
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
OpenMS::FeatureFindingMetabo::isotope_filtering_model_
String isotope_filtering_model_
Definition: FeatureFindingMetabo.h:329
Element.h
MassTrace.h
OpenMS::FeatureFindingMetabo::svm_feat_centers_
std::vector< double > svm_feat_centers_
Definition: FeatureFindingMetabo.h:315
OpenMS::Range
Internal structure to store a lower and upper bound of an m/z range.
Definition: FeatureFindingMetabo.h:146
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::FeatureFinderAlgorithmSH
The Superhirn FeatureFinderAlgorithm.
Definition: FeatureFinderAlgorithmSH.h:99
OpenMS::FeatureFindingMetabo::isotope_filt_svm_
svm_model * isotope_filt_svm_
SVM parameters.
Definition: FeatureFindingMetabo.h:314
OpenMS::Range::right_boundary
double right_boundary
Definition: FeatureFindingMetabo.h:149
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
ProgressLogger.h
OpenMS::MzMLFile::load
void load(const String &filename, PeakMap &map)
Loads a map from a MzML file. Spectra and chromatograms are sorted by default (this can be disabled u...
OpenMS::FeatureHypothesis::feat_score_
double feat_score_
Definition: FeatureFindingMetabo.h:116
OpenMS::FeatureFindingMetabo::use_mz_scoring_by_element_range_
bool use_mz_scoring_by_element_range_
Definition: FeatureFindingMetabo.h:333
OpenMS::Range::left_boundary
double left_boundary
Definition: FeatureFindingMetabo.h:148
FeatureMap.h
OpenMS::FeatureFindingMetabo::local_mz_range_
double local_mz_range_
Definition: FeatureFindingMetabo.h:322
OpenMS::DataProcessing::PEAK_PICKING
Peak picking (conversion from raw to peak data)
Definition: DataProcessing.h:67
OpenMS::FeatureFinder
The main feature finder class.
Definition: FeatureFinder.h:56
OpenMS::FeatureFindingMetabo::total_intensity_
double total_intensity_
Definition: FeatureFindingMetabo.h:318
OpenMS::CmpMassTraceByMZ
Definition: FeatureFindingMetabo.h:121
OpenMS::MSExperiment::empty
bool empty() const
Definition: MSExperiment.h:137
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::FeatureXMLFile::store
void store(const String &filename, const FeatureMap &feature_map)
stores the map feature_map in file with name filename.
OpenMS::CmpMassTraceByMZ::operator()
bool operator()(const MassTrace &x, const MassTrace &y) const
Definition: FeatureFindingMetabo.h:125
OpenMS::FeatureHypothesis::iso_pattern_
std::vector< const MassTrace * > iso_pattern_
Definition: FeatureFindingMetabo.h:114
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:73
MSExperiment.h
OpenMS::SignedSize
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:95
OpenMS::FeatureHypothesis
Internal structure used in FeatureFindingMetabo that keeps track of a feature hypothesis (isotope gro...
Definition: FeatureFindingMetabo.h:58
MSChromatogram.h
OpenMS::FeatureFindingMetabo::remove_single_traces_
bool remove_single_traces_
Definition: FeatureFindingMetabo.h:337
OpenMS::FeatureXMLFile
This class provides Input/Output functionality for feature maps.
Definition: FeatureXMLFile.h:68
OpenMS::DataProcessing::QUANTITATION
Quantitation.
Definition: DataProcessing.h:72
FeatureFinderAlgorithmSH.h
OpenMS::FeatureFindingMetabo::charge_upper_bound_
Size charge_upper_bound_
Definition: FeatureFindingMetabo.h:324
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:73
OpenMS::FeatureFindingMetabo::svm_feat_scales_
std::vector< double > svm_feat_scales_
Definition: FeatureFindingMetabo.h:316
OpenMS::CmpHypothesesByScore
Definition: FeatureFindingMetabo.h:132
OpenMS::FeatureFindingMetabo::use_smoothed_intensities_
bool use_smoothed_intensities_
Definition: FeatureFindingMetabo.h:330
OpenMS::MassTrace::getCentroidMZ
double getCentroidMZ() const
Returns the centroid m/z.
Definition: MassTrace.h:179
File.h
OpenMS::FeatureFindingMetabo::elements_
std::vector< const Element * > elements_
Definition: FeatureFindingMetabo.h:338
OpenMS::FeatureFindingMetabo::report_convex_hulls_
bool report_convex_hulls_
Definition: FeatureFindingMetabo.h:334
OpenMS::MzMLFile::getOptions
PeakFileOptions & getOptions()
Mutable access to the options for loading/storing.
OpenMS::ProgressLogger::setLogType
void setLogType(LogType type) const
Sets the progress log that should be used. The default type is NONE!
TOPPBase.h
OpenMS::FeatureHypothesis::getScore
double getScore() const
OpenMS::FeatureFindingMetabo::report_summed_ints_
bool report_summed_ints_
Definition: FeatureFindingMetabo.h:327