| OpenMS 2.5.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-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 $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/KERNEL/MassTrace.h>
38 #include <OpenMS/KERNEL/Feature.h>
39 #include <OpenMS/KERNEL/FeatureMap.h>
40 #include <OpenMS/FORMAT/MzTab.h>
41 #include <OpenMS/KERNEL/MSExperiment.h>
42 #include <OpenMS/KERNEL/MSSpectrum.h>
43 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
44 #include <OpenMS/DATASTRUCTURES/String.h>
45 #include <OpenMS/CONCEPT/ProgressLogger.h>
46
47
48 #include <vector>
49 #include <algorithm>
50
51 namespace OpenMS
52 {
53
54 struct OPENMS_DLLAPI PrecursorMassComparator
55 {
56 bool operator() (const MSSpectrum& a, const MSSpectrum& b)
57 {
58 return a.getPrecursors()[0].getMZ() < b.getPrecursors()[0].getMZ();
59 }
60
61 } PrecursorMZLess;
62
63 class OPENMS_DLLAPI SpectralMatch
64 {
65 public:
67 SpectralMatch();
68
70 ~SpectralMatch();
71
73 SpectralMatch(const SpectralMatch&);
74
76 SpectralMatch& operator=(const SpectralMatch&);
77
78 double getObservedPrecursorMass() const;
79 void setObservedPrecursorMass(const double&);
80
81 double getObservedPrecursorRT() const;
82 void setObservedPrecursorRT(const double&);
83
84 double getFoundPrecursorMass() const;
85 void setFoundPrecursorMass(const double&);
86
87 Int getFoundPrecursorCharge() const;
88 void setFoundPrecursorCharge(const Int&);
89
90 double getMatchingScore() const;
91 void setMatchingScore(const double&);
92
93 Size getObservedSpectrumIndex() const;
94 void setObservedSpectrumIndex(const Size&);
95
96 Size getMatchingSpectrumIndex() const;
97 void setMatchingSpectrumIndex(const Size&);
98
99 String getPrimaryIdentifier() const;
100 void setPrimaryIdentifier(const String&);
101
102 String getSecondaryIdentifier() const;
103 void setSecondaryIdentifier(const String&);
104
105 String getCommonName() const;
106 void setCommonName(const String&);
107
108 String getSumFormula() const;
109 void setSumFormula(const String&);
110
111 String getInchiString() const;
112 void setInchiString(const String&);
113
114 String getSMILESString() const;
115 void setSMILESString(const String&);
116
117 String getPrecursorAdduct() const;
118 void setPrecursorAdduct(const String&);
119
120
121 private:
122 double observed_precursor_mass_;
123 double observed_precursor_rt_;
124 double found_precursor_mass_;
125 Int found_precursor_charge_;
126 double matching_score_;
127 Size observed_spectrum_idx_;
128 Size matching_spectrum_idx_;
129
130 // further meta information
131 String primary_id_;
132 String secondary_id_;
133 String common_name_;
134 String sum_formula_;
135 String inchi_string_;
136 String smiles_string_;
137 String precursor_adduct_;
138
139 };
140
141 struct OPENMS_DLLAPI SpectralMatchScoreComparator
142 {
143 bool operator() (const SpectralMatch& a, const SpectralMatch& b)
144 {
145 return a.getMatchingScore() > b.getMatchingScore();
146 }
147
148 } SpectralMatchScoreGreater;
149
150 class OPENMS_DLLAPI MetaboliteSpectralMatching :
151 public DefaultParamHandler,
152 public ProgressLogger
153 {
154 public:
156 MetaboliteSpectralMatching();
157
159 ~MetaboliteSpectralMatching() override;
160
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 double mz_lower_bound = 0.0);
168
170 static double computeHyperScore(
171 double fragment_mass_error,
172 bool fragment_mass_tolerance_unit_ppm,
173 const MSSpectrum& exp_spectrum,
174 const MSSpectrum& db_spectrum,
175 std::vector<PeptideHit::PeakAnnotation>& annotations,
176 double mz_lower_bound = 0.0);
177
179 void run(PeakMap &, PeakMap &, MzTab &);
180
181 protected:
182 void updateMembers_() override;
183
184 // we have to use a pointer for "annotations" because mutable
185 // references can't have temporary default values:
186 static double computeHyperScore_(
187 double fragment_mass_error,
188 bool fragment_mass_tolerance_unit_ppm,
189 const MSSpectrum& exp_spectrum,
190 const MSSpectrum& db_spectrum,
191 std::vector<PeptideHit::PeakAnnotation>* annotations = 0,
192 double mz_lower_bound = 0.0);
193
194 private:
196 void exportMzTab_(const std::vector<SpectralMatch>&, MzTab&);
197
198 double precursor_mz_error_;
199 double fragment_mz_error_;
200 String mz_error_unit_;
201 String ion_mode_;
202
203 String report_mode_;
204 };
205
206 }
207
OpenMS::SpectralMatch::common_name_
String common_name_
Definition: MetaboliteSpectralMatching.h:133
OpenMS::SpectralMatch::matching_score_
double matching_score_
Definition: MetaboliteSpectralMatching.h:126
MassTrace.h
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::MetaboliteSpectralMatching::precursor_mz_error_
double precursor_mz_error_
Definition: MetaboliteSpectralMatching.h:198
OpenMS::SpectralMatchScoreComparator
Definition: MetaboliteSpectralMatching.h:141
OpenMS::SpectralMatch::observed_precursor_rt_
double observed_precursor_rt_
Definition: MetaboliteSpectralMatching.h:123
OpenMS::SpectralMatch::primary_id_
String primary_id_
Definition: MetaboliteSpectralMatching.h:131
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:91
OpenMS::MetaboliteSpectralMatching::ion_mode_
String ion_mode_
Definition: MetaboliteSpectralMatching.h:201
Feature.h
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:77
OpenMS::SpectralMatchScoreGreater
struct OpenMS::SpectralMatchScoreComparator SpectralMatchScoreGreater
OpenMS::SpectralMatch::observed_precursor_mass_
double observed_precursor_mass_
Definition: MetaboliteSpectralMatching.h:122
OpenMS::SpectrumSettings::getPrecursors
const std::vector< Precursor > & getPrecursors() const
returns a const reference to the precursors
OpenMS::SpectralMatch::smiles_string_
String smiles_string_
Definition: MetaboliteSpectralMatching.h:136
OpenMS::SpectralMatch
Definition: MetaboliteSpectralMatching.h:63
OpenMS::SpectralMatch::getMatchingScore
double getMatchingScore() const
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:67
OpenMS::SpectralMatch::precursor_adduct_
String precursor_adduct_
Definition: MetaboliteSpectralMatching.h:137
FeatureMap.h
String.h
OpenMS::MetaboliteSpectralMatching
Definition: MetaboliteSpectralMatching.h:150
ProgressLogger.h
OpenMS::PrecursorMassComparator
Definition: MetaboliteSpectralMatching.h:54
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
MSExperiment.h
OpenMS::ProgressLogger
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
OpenMS::SpectralMatch::sum_formula_
String sum_formula_
Definition: MetaboliteSpectralMatching.h:134
OpenMS::SpectralMatch::found_precursor_charge_
Int found_precursor_charge_
Definition: MetaboliteSpectralMatching.h:125
DefaultParamHandler.h
OpenMS::MetaboliteSpectralMatching::mz_error_unit_
String mz_error_unit_
Definition: MetaboliteSpectralMatching.h:200
OpenMS::SpectralMatch::inchi_string_
String inchi_string_
Definition: MetaboliteSpectralMatching.h:135
MSSpectrum.h
MzTab.h
OpenMS::MzTab
Data model of MzTab files. Please see the official MzTab specification at https://code.google.com/p/mztab/.
Definition: MzTab.h:855
int
OpenMS::SpectralMatch::found_precursor_mass_
double found_precursor_mass_
Definition: MetaboliteSpectralMatching.h:124
OpenMS::SpectralMatch::secondary_id_
String secondary_id_
Definition: MetaboliteSpectralMatching.h:132
OpenMS::MetaboliteSpectralMatching::fragment_mz_error_
double fragment_mz_error_
Definition: MetaboliteSpectralMatching.h:199
OpenMS::SpectralMatch::observed_spectrum_idx_
Size observed_spectrum_idx_
Definition: MetaboliteSpectralMatching.h:127
OpenMS::MetaboliteSpectralMatching::report_mode_
String report_mode_
Definition: MetaboliteSpectralMatching.h:203
OpenMS::SpectralMatch::matching_spectrum_idx_
Size matching_spectrum_idx_
Definition: MetaboliteSpectralMatching.h:128
OpenMS::PrecursorMZLess
struct OpenMS::PrecursorMassComparator PrecursorMZLess
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127