OpenMS  3.0.0
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-2022.
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:
65  SpectralMatch();
66 
68  ~SpectralMatch();
69 
72 
74  SpectralMatch& operator=(const SpectralMatch&);
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 
85  Int getFoundPrecursorCharge() const;
86  void setFoundPrecursorCharge(const Int&);
87 
88  double getMatchingScore() const;
89  void setMatchingScore(const double&);
90 
91  Size getObservedSpectrumIndex() const;
92  void setObservedSpectrumIndex(const Size&);
93 
94  Size getMatchingSpectrumIndex() const;
95  void setMatchingSpectrumIndex(const Size&);
96 
97  String getPrimaryIdentifier() const;
98  void setPrimaryIdentifier(const String&);
99 
100  String getSecondaryIdentifier() const;
101  void setSecondaryIdentifier(const String&);
102 
103  String getCommonName() const;
104  void setCommonName(const String&);
105 
106  String getSumFormula() const;
107  void setSumFormula(const String&);
108 
109  String getInchiString() const;
110  void setInchiString(const String&);
111 
112  String getSMILESString() const;
113  void setSMILESString(const String&);
114 
115  String getPrecursorAdduct() const;
116  void setPrecursorAdduct(const String&);
117 
118 
119  private:
127 
128  // further meta information
136 
137  };
138 
139  struct OPENMS_DLLAPI SpectralMatchScoreComparator
140  {
141  bool operator() (const SpectralMatch& a, const SpectralMatch& b)
142  {
143  return a.getMatchingScore() > b.getMatchingScore();
144  }
145 
147 
148  class OPENMS_DLLAPI MetaboliteSpectralMatching :
149  public DefaultParamHandler,
150  public ProgressLogger
151  {
152  public:
155 
157  ~MetaboliteSpectralMatching() override;
158 
160  static double computeHyperScore(
161  double fragment_mass_error,
162  bool fragment_mass_tolerance_unit_ppm,
163  const MSSpectrum& exp_spectrum,
164  const MSSpectrum& db_spectrum,
165  double mz_lower_bound = 0.0);
166 
168  static double computeHyperScore(
169  double fragment_mass_error,
170  bool fragment_mass_tolerance_unit_ppm,
171  const MSSpectrum& exp_spectrum,
172  const MSSpectrum& db_spectrum,
173  std::vector<PeptideHit::PeakAnnotation>& annotations,
174  double mz_lower_bound = 0.0);
175 
177  void run(PeakMap &, PeakMap &, MzTab &);
178 
179  protected:
180  void updateMembers_() override;
181 
182  // we have to use a pointer for "annotations" because mutable
183  // references can't have temporary default values:
184  static double computeHyperScore_(
185  double fragment_mass_error,
186  bool fragment_mass_tolerance_unit_ppm,
187  const MSSpectrum& exp_spectrum,
188  const MSSpectrum& db_spectrum,
189  std::vector<PeptideHit::PeakAnnotation>* annotations = 0,
190  double mz_lower_bound = 0.0);
191 
192  private:
194  void exportMzTab_(const std::vector<SpectralMatch>&, MzTab&);
195 
200 
202  };
203 
204 }
205 
DefaultParamHandler.h
MzTabFile.h
OpenMS::TOPPBase
Base class for TOPP applications.
Definition: TOPPBase.h:147
OpenMS::SpectralMatchScoreComparator
Definition: MetaboliteSpectralMatching.h:139
OpenMS::MzTabFile
File adapter for MzTab files.
Definition: MzTabFile.h:55
OpenMS::MetaboliteSpectralMatching::fragment_mz_error_
double fragment_mz_error_
Definition: MetaboliteSpectralMatching.h:197
OpenMS::SpectralMatch::found_precursor_charge_
Int found_precursor_charge_
Definition: MetaboliteSpectralMatching.h:123
OpenMS::MzMLFile
File adapter for MzML files.
Definition: MzMLFile.h:57
OpenMS::PrecursorMZLess
struct OpenMS::PrecursorMassComparator PrecursorMZLess
OpenMS::String
A more convenient string class.
Definition: String.h:58
MzMLFile.h
Feature.h
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
OpenMS::SpectrumSettings::getPrecursors
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
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::MzTab
Data model of MzTab files. Please see the official MzTab specification at https://code....
Definition: MzTab.h:477
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::SpectralMatch::found_precursor_mass_
double found_precursor_mass_
Definition: MetaboliteSpectralMatching.h:122
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
OpenMS::MetaboliteSpectralMatching::run
void run(PeakMap &, PeakMap &, MzTab &)
main method of MetaboliteSpectralMatching
OpenMS::File::find
static String find(const String &filename, StringList directories=StringList())
Looks up the location of the file filename.
OpenMS::SpectralMatch::primary_id_
String primary_id_
Definition: MetaboliteSpectralMatching.h:129
MassTrace.h
OpenMS::MetaboliteSpectralMatching::ion_mode_
String ion_mode_
Definition: MetaboliteSpectralMatching.h:199
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::SpectralMatch::inchi_string_
String inchi_string_
Definition: MetaboliteSpectralMatching.h:133
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:52
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::SpectralMatch::getMatchingScore
double getMatchingScore() const
OpenMS::SpectralMatch::observed_spectrum_idx_
Size observed_spectrum_idx_
Definition: MetaboliteSpectralMatching.h:125
OpenMS::SpectralMatch::observed_precursor_mass_
double observed_precursor_mass_
Definition: MetaboliteSpectralMatching.h:120
FeatureMap.h
OpenMS::MetaboliteSpectralMatching
Definition: MetaboliteSpectralMatching.h:148
OpenMS::SpectralMatch::precursor_adduct_
String precursor_adduct_
Definition: MetaboliteSpectralMatching.h:135
OpenMS::MzTabFile::store
void store(const String &filename, const MzTab &mz_tab) const
OpenMS::MetaboliteSpectralMatching::mz_error_unit_
String mz_error_unit_
Definition: MetaboliteSpectralMatching.h:198
OpenMS::SpectralMatchScoreGreater
struct OpenMS::SpectralMatchScoreComparator SpectralMatchScoreGreater
OpenMS::DefaultParamHandler::setParameters
void setParameters(const Param &param)
Sets the parameters.
OpenMS::DefaultParamHandler::getDefaults
const Param & getDefaults() const
Non-mutable access to the default parameters.
MzTab.h
OpenMS::MSExperiment::empty
bool empty() const
Definition: MSExperiment.h:130
OpenMS::PrecursorMassComparator
Definition: MetaboliteSpectralMatching.h:52
OpenMS::SpectralMatch::secondary_id_
String secondary_id_
Definition: MetaboliteSpectralMatching.h:130
main
int main(int argc, const char **argv)
Definition: INIFileEditor.cpp:71
OpenMS::SpectralMatch::matching_score_
double matching_score_
Definition: MetaboliteSpectralMatching.h:124
MSExperiment.h
OpenMS::Param::copy
Param copy(const std::string &prefix, bool remove_prefix=false) const
Returns a new Param object containing all entries that start with prefix.
OpenMS::SpectralMatch::matching_spectrum_idx_
Size matching_spectrum_idx_
Definition: MetaboliteSpectralMatching.h:126
OpenMS::SpectralMatch::smiles_string_
String smiles_string_
Definition: MetaboliteSpectralMatching.h:134
OpenMS::SpectralMatch
Definition: MetaboliteSpectralMatching.h:61
String.h
OpenMS::MetaboliteSpectralMatching::report_mode_
String report_mode_
Definition: MetaboliteSpectralMatching.h:201
OpenMS::Param
Management and storage of parameters / INI files.
Definition: Param.h:69
OpenMS::SpectralMatch::observed_precursor_rt_
double observed_precursor_rt_
Definition: MetaboliteSpectralMatching.h:121
OpenMS::SpectralMatch::common_name_
String common_name_
Definition: MetaboliteSpectralMatching.h:131
OpenMS::PeakFileOptions::setMSLevels
void setMSLevels(const std::vector< Int > &levels)
sets the desired MS levels for peaks to load
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
OpenMS::SpectralMatch::sum_formula_
String sum_formula_
Definition: MetaboliteSpectralMatching.h:132
MetaboliteSpectralMatching.h
File.h
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!
OpenMS::MetaboliteSpectralMatching::precursor_mz_error_
double precursor_mz_error_
Definition: MetaboliteSpectralMatching.h:196
TOPPBase.h
MSSpectrum.h