OpenMS
MetaboliteSpectralMatching.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 $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
12 #include <OpenMS/KERNEL/Feature.h>
14 #include <OpenMS/FORMAT/MzTab.h>
20 
21 #include <vector>
22 
23 namespace OpenMS
24 {
25 
26  struct OPENMS_DLLAPI PrecursorMassComparator
27  {
28  bool operator() (const MSSpectrum& a, const MSSpectrum& b)
29  {
30  return a.getPrecursors()[0].getMZ() < b.getPrecursors()[0].getMZ();
31  }
32 
34 
35  class OPENMS_DLLAPI SpectralMatch
36  {
37  public:
40 
43 
46 
49 
50  double getObservedPrecursorMass() const;
51  void setObservedPrecursorMass(const double&);
52 
53  double getObservedPrecursorRT() const;
54  void setObservedPrecursorRT(const double&);
55 
56  double getFoundPrecursorMass() const;
57  void setFoundPrecursorMass(const double&);
58 
61 
62  double getMatchingScore() const;
63  void setMatchingScore(const double&);
64 
67 
70 
73 
76 
79 
81  void setCommonName(const String&);
82 
84  void setSumFormula(const String&);
85 
87  void setInchiString(const String&);
88 
90  void setSMILESString(const String&);
91 
93  void setPrecursorAdduct(const String&);
94 
95 
96  private:
105 
106  // further meta information
114 
115  };
116 
117  struct OPENMS_DLLAPI SpectralMatchScoreComparator
118  {
119  bool operator() (const SpectralMatch& a, const SpectralMatch& b)
120  {
121  return a.getMatchingScore() > b.getMatchingScore();
122  }
123 
125 
126  class OPENMS_DLLAPI MetaboliteSpectralMatching :
127  public DefaultParamHandler,
128  public ProgressLogger
129  {
130  public:
133 
136 
138  static double computeHyperScore(
139  double fragment_mass_error,
140  bool fragment_mass_tolerance_unit_ppm,
141  const MSSpectrum& exp_spectrum,
142  const MSSpectrum& db_spectrum,
143  double mz_lower_bound = 0.0);
144 
146  static double computeHyperScore(
147  double fragment_mass_error,
148  bool fragment_mass_tolerance_unit_ppm,
149  const MSSpectrum& exp_spectrum,
150  const MSSpectrum& db_spectrum,
151  std::vector<PeptideHit::PeakAnnotation>& annotations,
152  double mz_lower_bound = 0.0);
153 
155  void run(PeakMap &, PeakMap &, MzTab &, String &);
156 
157  protected:
158  void updateMembers_() override;
159 
160  // we have to use a pointer for "annotations" because mutable
161  // references can't have temporary default values:
162  static double computeHyperScore_(
163  double fragment_mass_error,
164  bool fragment_mass_tolerance_unit_ppm,
165  const MSSpectrum& exp_spectrum,
166  const MSSpectrum& db_spectrum,
167  std::vector<PeptideHit::PeakAnnotation>* annotations = 0,
168  double mz_lower_bound = 0.0);
169 
170  private:
172  void exportMzTab_(const std::vector<SpectralMatch>&, MzTab&);
173 
178 
180 
182  };
183 
184 }
185 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
The representation of a 1D spectrum.
Definition: MSSpectrum.h:44
Definition: MetaboliteSpectralMatching.h:129
MetaboliteSpectralMatching()
Default constructor.
double precursor_mz_error_
Definition: MetaboliteSpectralMatching.h:174
void exportMzTab_(const std::vector< SpectralMatch > &, MzTab &)
private member functions
void run(PeakMap &, PeakMap &, MzTab &, String &)
main method of MetaboliteSpectralMatching
static double computeHyperScore(double fragment_mass_error, bool fragment_mass_tolerance_unit_ppm, const MSSpectrum &exp_spectrum, const MSSpectrum &db_spectrum, double mz_lower_bound=0.0)
hyperscore computation
String ion_mode_
Definition: MetaboliteSpectralMatching.h:177
~MetaboliteSpectralMatching() override
Default destructor.
String mz_error_unit_
Definition: MetaboliteSpectralMatching.h:176
bool merge_spectra_
Definition: MetaboliteSpectralMatching.h:181
static double computeHyperScore_(double fragment_mass_error, bool fragment_mass_tolerance_unit_ppm, const MSSpectrum &exp_spectrum, const MSSpectrum &db_spectrum, std::vector< PeptideHit::PeakAnnotation > *annotations=0, double mz_lower_bound=0.0)
String report_mode_
Definition: MetaboliteSpectralMatching.h:179
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
double fragment_mz_error_
Definition: MetaboliteSpectralMatching.h:175
static double computeHyperScore(double fragment_mass_error, bool fragment_mass_tolerance_unit_ppm, const MSSpectrum &exp_spectrum, const MSSpectrum &db_spectrum, std::vector< PeptideHit::PeakAnnotation > &annotations, double mz_lower_bound=0.0)
hyperscore computation (with output of peak annotations)
Data model of MzTab files. Please see the official MzTab specification at https://code....
Definition: MzTab.h:452
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
Definition: MetaboliteSpectralMatching.h:36
String getPrecursorAdduct() const
String secondary_id_
Definition: MetaboliteSpectralMatching.h:108
void setObservedSpectrumIndex(const Size &)
void setCommonName(const String &)
void setObservedPrecursorRT(const double &)
double getObservedPrecursorRT() const
void setInchiString(const String &)
Int getFoundPrecursorCharge() const
double getMatchingScore() const
void setPrimaryIdentifier(const String &)
String sum_formula_
Definition: MetaboliteSpectralMatching.h:110
void setMatchingScore(const double &)
String common_name_
Definition: MetaboliteSpectralMatching.h:109
Size getObservedSpectrumIndex() const
double getFoundPrecursorMass() const
void setMatchingSpectrumIndex(const Size &)
String getSMILESString() const
String getSumFormula() const
Size getMatchingSpectrumIndex() const
void setObservedPrecursorMass(const double &)
~SpectralMatch()
Default destructor.
double matching_score_
Definition: MetaboliteSpectralMatching.h:101
double observed_precursor_rt_
Definition: MetaboliteSpectralMatching.h:98
Size matching_spectrum_idx_
Definition: MetaboliteSpectralMatching.h:103
SpectralMatch & operator=(const SpectralMatch &)
Assignment operator.
double getObservedPrecursorMass() const
void setFoundPrecursorMass(const double &)
String primary_id_
Definition: MetaboliteSpectralMatching.h:107
double found_precursor_mass_
Definition: MetaboliteSpectralMatching.h:99
void setFoundPrecursorCharge(const Int &)
Int found_precursor_charge_
Definition: MetaboliteSpectralMatching.h:100
double observed_precursor_mass_
Definition: MetaboliteSpectralMatching.h:97
void setSecondaryIdentifier(const String &)
String getPrimaryIdentifier() const
String precursor_adduct_
Definition: MetaboliteSpectralMatching.h:113
void setObservedSpectrumNativeID(const String &)
void setSMILESString(const String &)
SpectralMatch(const SpectralMatch &)
Copy constructor.
Size observed_spectrum_idx_
Definition: MetaboliteSpectralMatching.h:102
SpectralMatch()
Default constructor.
void setSumFormula(const String &)
void setPrecursorAdduct(const String &)
String smiles_string_
Definition: MetaboliteSpectralMatching.h:112
String inchi_string_
Definition: MetaboliteSpectralMatching.h:111
String getCommonName() const
String getInchiString() const
String getSecondaryIdentifier() const
String observed_spectrum_native_id_
Definition: MetaboliteSpectralMatching.h:104
String getObservedSpectrumNativeID() const
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:72
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
struct OpenMS::SpectralMatchScoreComparator SpectralMatchScoreGreater
struct OpenMS::PrecursorMassComparator PrecursorMZLess
Definition: MetaboliteSpectralMatching.h:27
Definition: MetaboliteSpectralMatching.h:118