OpenMS
MetaboliteSpectralMatching.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-2023.
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 $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
38 #include <OpenMS/KERNEL/Feature.h>
40 #include <OpenMS/FORMAT/MzTab.h>
46 
47 #include <vector>
48 
49 namespace OpenMS
50 {
51 
52  struct OPENMS_DLLAPI PrecursorMassComparator
53  {
54  bool operator() (const MSSpectrum& a, const MSSpectrum& b)
55  {
56  return a.getPrecursors()[0].getMZ() < b.getPrecursors()[0].getMZ();
57  }
58 
60 
61  class OPENMS_DLLAPI SpectralMatch
62  {
63  public:
66 
69 
72 
75 
76  double getObservedPrecursorMass() const;
77  void setObservedPrecursorMass(const double&);
78 
79  double getObservedPrecursorRT() const;
80  void setObservedPrecursorRT(const double&);
81 
82  double getFoundPrecursorMass() const;
83  void setFoundPrecursorMass(const double&);
84 
87 
88  double getMatchingScore() const;
89  void setMatchingScore(const double&);
90 
93 
96 
99 
102 
105 
107  void setCommonName(const String&);
108 
110  void setSumFormula(const String&);
111 
113  void setInchiString(const String&);
114 
116  void setSMILESString(const String&);
117 
120 
121 
122  private:
131 
132  // further meta information
140 
141  };
142 
143  struct OPENMS_DLLAPI SpectralMatchScoreComparator
144  {
145  bool operator() (const SpectralMatch& a, const SpectralMatch& b)
146  {
147  return a.getMatchingScore() > b.getMatchingScore();
148  }
149 
151 
152  class OPENMS_DLLAPI MetaboliteSpectralMatching :
153  public DefaultParamHandler,
154  public ProgressLogger
155  {
156  public:
159 
162 
164  static double computeHyperScore(
165  double fragment_mass_error,
166  bool fragment_mass_tolerance_unit_ppm,
167  const MSSpectrum& exp_spectrum,
168  const MSSpectrum& db_spectrum,
169  double mz_lower_bound = 0.0);
170 
172  static double computeHyperScore(
173  double fragment_mass_error,
174  bool fragment_mass_tolerance_unit_ppm,
175  const MSSpectrum& exp_spectrum,
176  const MSSpectrum& db_spectrum,
177  std::vector<PeptideHit::PeakAnnotation>& annotations,
178  double mz_lower_bound = 0.0);
179 
181  void run(PeakMap &, PeakMap &, MzTab &, String &);
182 
183  protected:
184  void updateMembers_() override;
185 
186  // we have to use a pointer for "annotations" because mutable
187  // references can't have temporary default values:
188  static double computeHyperScore_(
189  double fragment_mass_error,
190  bool fragment_mass_tolerance_unit_ppm,
191  const MSSpectrum& exp_spectrum,
192  const MSSpectrum& db_spectrum,
193  std::vector<PeptideHit::PeakAnnotation>* annotations = 0,
194  double mz_lower_bound = 0.0);
195 
196  private:
198  void exportMzTab_(const std::vector<SpectralMatch>&, MzTab&);
199 
204 
206 
208  };
209 
210 }
211 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:72
The representation of a 1D spectrum.
Definition: MSSpectrum.h:70
Definition: MetaboliteSpectralMatching.h:155
MetaboliteSpectralMatching()
Default constructor.
double precursor_mz_error_
Definition: MetaboliteSpectralMatching.h:200
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:203
~MetaboliteSpectralMatching() override
Default destructor.
String mz_error_unit_
Definition: MetaboliteSpectralMatching.h:202
bool merge_spectra_
Definition: MetaboliteSpectralMatching.h:207
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:205
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:201
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:478
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:53
Definition: MetaboliteSpectralMatching.h:62
String getPrecursorAdduct() const
String secondary_id_
Definition: MetaboliteSpectralMatching.h:134
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:136
void setMatchingScore(const double &)
String common_name_
Definition: MetaboliteSpectralMatching.h:135
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:127
double observed_precursor_rt_
Definition: MetaboliteSpectralMatching.h:124
Size matching_spectrum_idx_
Definition: MetaboliteSpectralMatching.h:129
SpectralMatch & operator=(const SpectralMatch &)
Assignment operator.
double getObservedPrecursorMass() const
void setFoundPrecursorMass(const double &)
String primary_id_
Definition: MetaboliteSpectralMatching.h:133
double found_precursor_mass_
Definition: MetaboliteSpectralMatching.h:125
void setFoundPrecursorCharge(const Int &)
Int found_precursor_charge_
Definition: MetaboliteSpectralMatching.h:126
double observed_precursor_mass_
Definition: MetaboliteSpectralMatching.h:123
void setSecondaryIdentifier(const String &)
String getPrimaryIdentifier() const
String precursor_adduct_
Definition: MetaboliteSpectralMatching.h:139
void setObservedSpectrumNativeID(const String &)
void setSMILESString(const String &)
SpectralMatch(const SpectralMatch &)
Copy constructor.
Size observed_spectrum_idx_
Definition: MetaboliteSpectralMatching.h:128
SpectralMatch()
Default constructor.
void setSumFormula(const String &)
void setPrecursorAdduct(const String &)
String smiles_string_
Definition: MetaboliteSpectralMatching.h:138
String inchi_string_
Definition: MetaboliteSpectralMatching.h:137
String getCommonName() const
String getInchiString() const
String getSecondaryIdentifier() const
String observed_spectrum_native_id_
Definition: MetaboliteSpectralMatching.h:130
String getObservedSpectrumNativeID() const
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
A more convenient string class.
Definition: String.h:60
int Int
Signed integer type.
Definition: Types.h:102
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
struct OpenMS::SpectralMatchScoreComparator SpectralMatchScoreGreater
struct OpenMS::PrecursorMassComparator PrecursorMZLess
Definition: MetaboliteSpectralMatching.h:53
Definition: MetaboliteSpectralMatching.h:144