OpenMS
Loading...
Searching...
No Matches
FeatureFinderAlgorithmMetaboIdent.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: Timo Sachsenberg, Hendrik Weisser $
7// --------------------------------------------------------------------------
8
9#pragma once
10
20
21#include <map>
22#include <vector>
23
24namespace OpenMS
25{
26class IsotopeDistribution;
27
30{
31public:
53 {
67 FeatureFinderMetaboIdentCompound(const std::string& _name,
68 const std::string& _formula,
69 double _mass,
70 const std::vector<int>& _charges,
71 const std::vector<double>& _rts,
72 const std::vector<double>& _rt_ranges,
73 const std::vector<double>& _iso_distrib,
74 const std::vector<double>& _ion_mobilities = {},
75 const std::string& _adduct = ""):
76 name_(_name),
77 formula_(_formula),
78 mass_(_mass),
79 charges_(_charges),
80 rts_(_rts),
81 rt_ranges_(_rt_ranges),
82 iso_distrib_(_iso_distrib),
83 ion_mobilities_(_ion_mobilities),
84 adduct_(_adduct)
85 {
86 }
87
88 private:
89 std::string name_;
90 std::string formula_;
91 double mass_;
92 std::vector<int> charges_;
93 std::vector<double> rts_;
94 std::vector<double> rt_ranges_;
95 std::vector<double> iso_distrib_;
96 std::vector<double> ion_mobilities_;
97 std::string adduct_;
98
99 public:
101 const std::string& getName() const {
102 return name_;
103 }
104
106 const std::string& getFormula() const {
107 return formula_;
108 }
109
111 double getMass() const {
112 return mass_;
113 }
114
116 const std::vector<int>& getCharges() const {
117 return charges_;
118 }
119
121 const std::vector<double>& getRTs() const {
122 return rts_;
123 }
124
126 const std::vector<double>& getRTRanges() const {
127 return rt_ranges_;
128 }
129
131 const std::vector<double>& getIsotopeDistribution() const {
132 return iso_distrib_;
133 }
134
136 const std::vector<double>& getIonMobilities() const {
137 return ion_mobilities_;
138 }
139
140 const std::string& getAdduct() const {
141 return adduct_;
142 }
143 };
144
147
157 void run(const std::vector<FeatureFinderMetaboIdentCompound>& metaboIdentTable, FeatureMap& features, const std::string& spectra_file = "");
158
160 PeakMap& getMSData() { return ms_data_; }
161 const PeakMap& getMSData() const { return ms_data_; }
162
164 void setMSData(const PeakMap& m); // needed because pyOpenMS can't wrap the non-const reference version
165
166 void setMSData(PeakMap&& m); // moves peak data and saves the copy. Note that getMSData() will give back a processed/modified version.
167
169 const PeakMap& getChromatograms() const { return chrom_data_; }
170 PeakMap& getChromatograms() { return chrom_data_; }
171
173 const TargetedExperiment& getLibrary() const { return library_; }
174
176 const TransformationDescription& getTransformations() const { return trafo_; }
177
179 size_t getNShared() const { return n_shared_; }
180
181 static std::string prettyPrintCompound(const TargetedExperiment::Compound& compound);
182protected:
183
186 {
188 double rt_min, rt_max, mz_min, mz_max;
189 };
190
192 typedef std::map<UInt64, std::vector<MassTraceBounds> > FeatureBoundsMap;
193
196
197 typedef std::vector<Feature*> FeatureGroup;
198
201 {
202 bool operator()(const Feature& feature)
203 {
204 return feature.metaValueExists("FFMetId_remove");
205 }
206 } feature_filter_;
207
210 {
211 bool operator()(const Feature& f1, const Feature& f2)
212 {
213 const std::string ref1 = StringUtils::toStr(f1.getMetaValue("PeptideRef"));
214 const std::string ref2 = StringUtils::toStr(f2.getMetaValue("PeptideRef"));
215 if (ref1 == ref2)
216 {
217 return f1.getRT() < f2.getRT();
218 }
219 return ref1 < ref2;
220 }
221 } feature_compare_;
222
223
224 void extractTransformations_(const FeatureMap& features);
225
227 void addTargetToLibrary_(const std::string& name, const std::string& formula,
228 double mass, const std::vector<Int>& charges,
229 const std::vector<double>& rts,
230 std::vector<double> rt_ranges,
231 const std::vector<double>& iso_distrib,
232 const std::vector<double>& ion_mobilities = {},
233 const std::string& adduct = "");
234
237
239
241 double calculateMZ_(double mass, Int charge) const;
242
243 void generateTransitions_(const std::string& target_id, double mz, Int charge,
244 const IsotopeDistribution& iso_dist);
245
247
248 void ensureConvexHulls_(Feature& feature) const;
249
251
254 void runSingleGroup_(const std::vector<FeatureFinderMetaboIdentCompound>& metaboIdentTable,
255 FeatureMap& features,
256 const std::string& spectra_file);
257
258 double rt_window_;
259 double mz_window_;
261 double im_window_;
262
265
269
270 std::string elution_model_;
271
272 // output file (before filtering)
273 std::string candidates_out_;
274
276
277 void updateMembers_() override;
278
281
283
285
287
289 std::map<std::string, double> isotope_probs_;
290 std::map<std::string, double> target_rts_;
291
292 size_t n_shared_ = 0;
293};
294
295} // namespace OpenMS
Isotope pattern generator for coarse isotope distributions.
Definition CoarseIsotopePatternGenerator.h:81
A base class for all classes handling default parameters.
Definition DefaultParamHandler.h:66
Definition FeatureFinderAlgorithmMetaboIdent.h:30
const TargetedExperiment & getLibrary() const
Retrieve the assay library (e.g., to store as TraML, empty if run was not executed)
Definition FeatureFinderAlgorithmMetaboIdent.h:173
FeatureFinderAlgorithmPickedHelperStructs::MassTraces MassTraces
Definition FeatureFinderAlgorithmMetaboIdent.h:195
TransformationDescription trafo_
Definition FeatureFinderAlgorithmMetaboIdent.h:286
double rt_window_
RT window width.
Definition FeatureFinderAlgorithmMetaboIdent.h:258
std::map< std::string, double > isotope_probs_
isotope probabilities of transitions
Definition FeatureFinderAlgorithmMetaboIdent.h:289
const TransformationDescription & getTransformations() const
Retrieve deviations between provided coordinates and extracted ones (e.g., to store as TrafoXML or fo...
Definition FeatureFinderAlgorithmMetaboIdent.h:176
std::string candidates_out_
Definition FeatureFinderAlgorithmMetaboIdent.h:273
double calculateMZ_(double mass, Int charge) const
Calculate mass-to-charge ratio from mass and charge.
MRMFeatureFinderScoring feat_finder_
OpenSWATH feature finder.
Definition FeatureFinderAlgorithmMetaboIdent.h:282
void annotateFeatures_(FeatureMap &features)
double signal_to_noise_
Definition FeatureFinderAlgorithmMetaboIdent.h:268
TargetedExperiment library_
accumulated assays for targets
Definition FeatureFinderAlgorithmMetaboIdent.h:284
void addTargetRT_(TargetedExperiment::Compound &target, double rt)
double min_peak_width_
Definition FeatureFinderAlgorithmMetaboIdent.h:267
const PeakMap & getMSData() const
Definition FeatureFinderAlgorithmMetaboIdent.h:161
void runSingleGroup_(const std::vector< FeatureFinderMetaboIdentCompound > &metaboIdentTable, FeatureMap &features, const std::string &spectra_file)
double mz_max
Definition FeatureFinderAlgorithmMetaboIdent.h:188
Size addTargetAnnotations_(FeatureMap &features)
Add "peptide" identifications with information about targets to features.
CoarseIsotopePatternGenerator iso_gen_
isotope pattern generator
Definition FeatureFinderAlgorithmMetaboIdent.h:288
void selectFeaturesFromCandidates_(FeatureMap &features)
PeakMap ms_data_
input LC-MS data
Definition FeatureFinderAlgorithmMetaboIdent.h:279
const PeakMap & getChromatograms() const
Retrieve chromatograms (empty if run was not executed)
Definition FeatureFinderAlgorithmMetaboIdent.h:169
double mz_window_
m/z window width
Definition FeatureFinderAlgorithmMetaboIdent.h:259
double peak_width_
Definition FeatureFinderAlgorithmMetaboIdent.h:266
void addTargetToLibrary_(const std::string &name, const std::string &formula, double mass, const std::vector< Int > &charges, const std::vector< double > &rts, std::vector< double > rt_ranges, const std::vector< double > &iso_distrib, const std::vector< double > &ion_mobilities={}, const std::string &adduct="")
Add a target (from the input file) to the assay library.
FeatureFinderAlgorithmPickedHelperStructs::MassTrace MassTrace
Definition FeatureFinderAlgorithmMetaboIdent.h:194
PeakMap & getMSData()
Retrieve chromatograms (empty if run was not executed)
Definition FeatureFinderAlgorithmMetaboIdent.h:160
Size n_isotopes_
number of isotopes for peptide assay
Definition FeatureFinderAlgorithmMetaboIdent.h:264
double im_window_
Ion mobility window width (0 = disabled)
Definition FeatureFinderAlgorithmMetaboIdent.h:261
std::string elution_model_
Definition FeatureFinderAlgorithmMetaboIdent.h:270
size_t getNShared() const
Retrieve number of features with shared identifications.
Definition FeatureFinderAlgorithmMetaboIdent.h:179
Size debug_level_
Definition FeatureFinderAlgorithmMetaboIdent.h:275
std::map< UInt64, std::vector< MassTraceBounds > > FeatureBoundsMap
Boundaries for all mass traces per feature.
Definition FeatureFinderAlgorithmMetaboIdent.h:192
bool mz_window_ppm_
m/z window width is given in PPM (not Da)?
Definition FeatureFinderAlgorithmMetaboIdent.h:260
std::vector< Feature * > FeatureGroup
group of (overlapping) features
Definition FeatureFinderAlgorithmMetaboIdent.h:197
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
void extractTransformations_(const FeatureMap &features)
void run(const std::vector< FeatureFinderMetaboIdentCompound > &metaboIdentTable, FeatureMap &features, const std::string &spectra_file="")
perform targeted feature extraction of compounds from metaboIdentTable and stores them in features....
void setMSData(const PeakMap &m)
Set spectra.
void generateTransitions_(const std::string &target_id, double mz, Int charge, const IsotopeDistribution &iso_dist)
PeakMap chrom_data_
accumulated chromatograms (XICs)
Definition FeatureFinderAlgorithmMetaboIdent.h:280
FeatureFinderAlgorithmMetaboIdent()
default constructor
void ensureConvexHulls_(Feature &feature) const
Size sub_index
Definition FeatureFinderAlgorithmMetaboIdent.h:187
static std::string prettyPrintCompound(const TargetedExperiment::Compound &compound)
PeakMap & getChromatograms()
Definition FeatureFinderAlgorithmMetaboIdent.h:170
std::map< std::string, double > target_rts_
RTs of targets (assays)
Definition FeatureFinderAlgorithmMetaboIdent.h:290
double isotope_pmin_
min. isotope probability for peptide assay
Definition FeatureFinderAlgorithmMetaboIdent.h:263
Boundaries for a mass trace in a feature.
Definition FeatureFinderAlgorithmMetaboIdent.h:186
A container for features.
Definition FeatureMap.h:78
An LC-MS feature.
Definition Feature.h:46
Definition IsotopeDistribution.h:40
The MRMFeatureFinder finds and scores peaks of transitions that co-elute.
Definition MRMFeatureFinderScoring.h:69
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
const DataValue & getMetaValue(const std::string &name) const
Returns the value corresponding to a string, or DataValue::EMPTY if not found.
bool metaValueExists(const std::string &name) const
Returns whether an entry with the given name exists.
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition Peak2D.h:185
Represents a compound (small molecule)
Definition TargetedExperimentHelper.h:298
A description of a targeted experiment containing precursor and production ions.
Definition TargetedExperiment.h:40
Generic description of a coordinate transformation.
Definition TransformationDescription.h:38
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
Comparison functor for features.
Definition FeatureFinderAlgorithmMetaboIdent.h:210
bool operator()(const Feature &f1, const Feature &f2)
Definition FeatureFinderAlgorithmMetaboIdent.h:211
Predicate for filtering features by overall quality.
Definition FeatureFinderAlgorithmMetaboIdent.h:201
bool operator()(const Feature &feature)
Definition FeatureFinderAlgorithmMetaboIdent.h:202
One target compound for the FeatureFinderAlgorithmMetaboIdent assay library.
Definition FeatureFinderAlgorithmMetaboIdent.h:53
std::vector< double > rts_
Expected retention times; one library transition per entry.
Definition FeatureFinderAlgorithmMetaboIdent.h:93
const std::vector< double > & getIsotopeDistribution() const
Return the pre-computed isotope-intensity distribution (or empty / [0] for runtime computation from f...
Definition FeatureFinderAlgorithmMetaboIdent.h:131
std::string adduct_
Adduct string (e.g. "M+H;1+", "M+Na;1+", "M-H;1-"). Empty lets downstream logic infer defaults from c...
Definition FeatureFinderAlgorithmMetaboIdent.h:97
double mass_
Monoisotopic mass; <= 0 means "compute from @c formula_".
Definition FeatureFinderAlgorithmMetaboIdent.h:91
std::vector< int > charges_
Charge states to register; entries == 0 are dropped at library-build time.
Definition FeatureFinderAlgorithmMetaboIdent.h:92
const std::string & getName() const
Return the target name.
Definition FeatureFinderAlgorithmMetaboIdent.h:101
std::string name_
Target name; used as the name meta value and in the auto-generated library ID.
Definition FeatureFinderAlgorithmMetaboIdent.h:89
const std::vector< double > & getRTs() const
Return the expected retention times (one library transition per entry).
Definition FeatureFinderAlgorithmMetaboIdent.h:121
const std::vector< double > & getIonMobilities() const
Return the optional ion-mobility values per rts_ entry (or a single broadcast value,...
Definition FeatureFinderAlgorithmMetaboIdent.h:136
std::vector< double > ion_mobilities_
Optional ion-mobility values per rts_ entry; one-element broadcasts, empty disables IM filtering.
Definition FeatureFinderAlgorithmMetaboIdent.h:96
FeatureFinderMetaboIdentCompound(const std::string &_name, const std::string &_formula, double _mass, const std::vector< int > &_charges, const std::vector< double > &_rts, const std::vector< double > &_rt_ranges, const std::vector< double > &_iso_distrib, const std::vector< double > &_ion_mobilities={}, const std::string &_adduct="")
Construct a target compound by aggregating its identification data.
Definition FeatureFinderAlgorithmMetaboIdent.h:67
std::vector< double > iso_distrib_
Optional pre-computed isotope-intensity distribution; empty (or [0]) triggers computation from formul...
Definition FeatureFinderAlgorithmMetaboIdent.h:95
const std::vector< double > & getRTRanges() const
Return the RT tolerance per rts_ entry (or a single broadcast value, or empty for the algorithm defau...
Definition FeatureFinderAlgorithmMetaboIdent.h:126
std::vector< double > rt_ranges_
RT tolerance per rts_ entry; one-element broadcasts, empty falls back to the algorithm default.
Definition FeatureFinderAlgorithmMetaboIdent.h:94
const std::string & getAdduct() const
Definition FeatureFinderAlgorithmMetaboIdent.h:140
std::string formula_
Molecular formula; empty if the caller only provides mass_.
Definition FeatureFinderAlgorithmMetaboIdent.h:90
const std::vector< int > & getCharges() const
Return the list of charge states to register for this target.
Definition FeatureFinderAlgorithmMetaboIdent.h:116
const std::string & getFormula() const
Return the molecular formula (may be empty if only mass was provided).
Definition FeatureFinderAlgorithmMetaboIdent.h:106
double getMass() const
Return the monoisotopic mass; <= 0 means "compute from @c formula at library-build time".
Definition FeatureFinderAlgorithmMetaboIdent.h:111
Helper struct for mass traces used in FeatureFinderAlgorithmPicked.
Definition FeatureFinderAlgorithmPickedHelperStructs.h:54
Helper struct for a collection of mass traces used in FeatureFinderAlgorithmPicked.
Definition FeatureFinderAlgorithmPickedHelperStructs.h:85