OpenMS
FeatureFinderAlgorithmMetaboIdent.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- 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 
19 
20 #include <map>
21 #include <vector>
22 
23 namespace OpenMS
24 {
25 class IsotopeDistribution;
26 
27 class OPENMS_DLLAPI FeatureFinderAlgorithmMetaboIdent :
28  public DefaultParamHandler
29 {
30 public:
32  struct OPENMS_DLLAPI FeatureFinderMetaboIdentCompound
33  {
35  const String& _formula,
36  double _mass,
37  const std::vector<int>& _charges,
38  const std::vector<double>& _rts,
39  const std::vector<double>& _rt_ranges,
40  const std::vector<double>& _iso_distrib):
41  name_(_name),
42  formula_(_formula),
43  mass_(_mass),
44  charges_(_charges),
45  rts_(_rts),
46  rt_ranges_(_rt_ranges),
47  iso_distrib_(_iso_distrib)
48  {
49  }
50 
51  private:
54  double mass_;
55  std::vector<int> charges_;
56  std::vector<double> rts_;
57  std::vector<double> rt_ranges_;
58  std::vector<double> iso_distrib_;
59 
60  public:
61  const String& getName() const {
62  return name_;
63  }
64 
65  const String& getFormula() const {
66  return formula_;
67  }
68 
69  double getMass() const {
70  return mass_;
71  }
72 
73  const std::vector<int>& getCharges() const {
74  return charges_;
75  }
76 
77  const std::vector<double>& getRTs() const {
78  return rts_;
79  }
80 
81  const std::vector<double> getRTRanges() const {
82  return rt_ranges_;
83  }
84 
85  const std::vector<double>& getIsotopeDistribution() const {
86  return iso_distrib_;
87  }
88  };
89 
92 
97  void run(const std::vector<FeatureFinderMetaboIdentCompound>& metaboIdentTable, FeatureMap& features, const String& spectra_file = "");
98 
100  PeakMap& getMSData() { return ms_data_; }
101  const PeakMap& getMSData() const { return ms_data_; }
102 
104  void setMSData(const PeakMap& m); // needed because pyOpenMS can't wrap the non-const reference version
105 
106  void setMSData(PeakMap&& m); // moves peak data and saves the copy. Note that getMSData() will give back a processed/modified version.
107 
109  const PeakMap& getChromatograms() const { return chrom_data_; }
110  PeakMap& getChromatograms() { return chrom_data_; }
111 
113  const TargetedExperiment& getLibrary() const { return library_; }
114 
116  const TransformationDescription& getTransformations() const { return trafo_; }
117 
119  size_t getNShared() const { return n_shared_; }
120 
122 protected:
123 
126  {
128  double rt_min, rt_max, mz_min, mz_max;
129  };
130 
132  typedef std::map<UInt64, std::vector<MassTraceBounds> > FeatureBoundsMap;
133 
136 
137  typedef std::vector<Feature*> FeatureGroup;
138 
141  {
142  bool operator()(const Feature& feature)
143  {
144  return feature.metaValueExists("FFMetId_remove");
145  }
146  } feature_filter_;
147 
150  {
151  bool operator()(const Feature& f1, const Feature& f2)
152  {
153  const String& ref1 = f1.getMetaValue("PeptideRef");
154  const String& ref2 = f2.getMetaValue("PeptideRef");
155  if (ref1 == ref2)
156  {
157  return f1.getRT() < f2.getRT();
158  }
159  return ref1 < ref2;
160  }
161  } feature_compare_;
162 
163 
164  void extractTransformations_(const FeatureMap& features);
165 
167  void addTargetToLibrary_(const String& name, const String& formula,
168  double mass, const std::vector<Int>& charges,
169  const std::vector<double>& rts,
170  std::vector<double> rt_ranges,
171  const std::vector<double>& iso_distrib);
172 
175 
176  void addTargetRT_(TargetedExperiment::Compound& target, double rt);
177 
179  double calculateMZ_(double mass, Int charge) const;
180 
181  void generateTransitions_(const String& target_id, double mz, Int charge,
182  const IsotopeDistribution& iso_dist);
183 
184  void annotateFeatures_(FeatureMap& features);
185 
186  void ensureConvexHulls_(Feature& feature) const;
187 
189 
190  double rt_window_;
191  double mz_window_;
193 
194  double isotope_pmin_;
196 
197  double peak_width_;
200 
202 
203  // output file (before filtering)
205 
207 
208  void updateMembers_() override;
209 
212 
214 
216 
218 
220  std::map<String, double> isotope_probs_;
221  std::map<String, double> target_rts_;
222 
223  size_t n_shared_ = 0;
224 };
225 
226 } // namespace OpenMS
Isotope pattern generator for coarse isotope distributions.
Definition: CoarseIsotopePatternGenerator.h:79
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
Definition: FeatureFinderAlgorithmMetaboIdent.h:29
PeakMap & getMSData()
Retrieve chromatograms (empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:100
FeatureFinderAlgorithmPickedHelperStructs::MassTraces MassTraces
Definition: FeatureFinderAlgorithmMetaboIdent.h:135
const PeakMap & getMSData() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:101
TransformationDescription trafo_
Definition: FeatureFinderAlgorithmMetaboIdent.h:217
const PeakMap & getChromatograms() const
Retrieve chromatograms (empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:109
double rt_window_
RT window width.
Definition: FeatureFinderAlgorithmMetaboIdent.h:190
const TargetedExperiment & getLibrary() const
Retrieve the assay library (e.g., to store as TraML, empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:113
void run(const std::vector< FeatureFinderMetaboIdentCompound > &metaboIdentTable, FeatureMap &features, const String &spectra_file="")
perform targeted feature extraction of compounds from
String elution_model_
Definition: FeatureFinderAlgorithmMetaboIdent.h:201
double calculateMZ_(double mass, Int charge) const
Calculate mass-to-charge ratio from mass and charge.
PeakMap & getChromatograms()
Definition: FeatureFinderAlgorithmMetaboIdent.h:110
MRMFeatureFinderScoring feat_finder_
OpenSWATH feature finder.
Definition: FeatureFinderAlgorithmMetaboIdent.h:213
const TransformationDescription & getTransformations() const
Retrieve deviations between provided coordinates and extracted ones (e.g., to store as TrafoXML or fo...
Definition: FeatureFinderAlgorithmMetaboIdent.h:116
void annotateFeatures_(FeatureMap &features)
double signal_to_noise_
Definition: FeatureFinderAlgorithmMetaboIdent.h:199
TargetedExperiment library_
accumulated assays for targets
Definition: FeatureFinderAlgorithmMetaboIdent.h:215
void addTargetRT_(TargetedExperiment::Compound &target, double rt)
double min_peak_width_
Definition: FeatureFinderAlgorithmMetaboIdent.h:198
double mz_max
Definition: FeatureFinderAlgorithmMetaboIdent.h:128
Size addTargetAnnotations_(FeatureMap &features)
Add "peptide" identifications with information about targets to features.
CoarseIsotopePatternGenerator iso_gen_
isotope pattern generator
Definition: FeatureFinderAlgorithmMetaboIdent.h:219
void selectFeaturesFromCandidates_(FeatureMap &features)
PeakMap ms_data_
input LC-MS data
Definition: FeatureFinderAlgorithmMetaboIdent.h:210
double mz_window_
m/z window width
Definition: FeatureFinderAlgorithmMetaboIdent.h:191
std::map< String, double > isotope_probs_
isotope probabilities of transitions
Definition: FeatureFinderAlgorithmMetaboIdent.h:220
double peak_width_
Definition: FeatureFinderAlgorithmMetaboIdent.h:197
FeatureFinderAlgorithmPickedHelperStructs::MassTrace MassTrace
Definition: FeatureFinderAlgorithmMetaboIdent.h:134
Size n_isotopes_
number of isotopes for peptide assay
Definition: FeatureFinderAlgorithmMetaboIdent.h:195
void generateTransitions_(const String &target_id, double mz, Int charge, const IsotopeDistribution &iso_dist)
size_t getNShared() const
Retrieve number of features with shared identifications.
Definition: FeatureFinderAlgorithmMetaboIdent.h:119
Size debug_level_
Definition: FeatureFinderAlgorithmMetaboIdent.h:206
std::map< UInt64, std::vector< MassTraceBounds > > FeatureBoundsMap
Boundaries for all mass traces per feature.
Definition: FeatureFinderAlgorithmMetaboIdent.h:132
bool mz_window_ppm_
m/z window width is given in PPM (not Da)?
Definition: FeatureFinderAlgorithmMetaboIdent.h:192
std::vector< Feature * > FeatureGroup
group of (overlapping) features
Definition: FeatureFinderAlgorithmMetaboIdent.h:137
void updateMembers_() override
This method is used to update extra member variables at the end of the setParameters() method.
void extractTransformations_(const FeatureMap &features)
String prettyPrintCompound(const TargetedExperiment::Compound &compound)
void setMSData(const PeakMap &m)
Set spectra.
PeakMap chrom_data_
accumulated chromatograms (XICs)
Definition: FeatureFinderAlgorithmMetaboIdent.h:211
FeatureFinderAlgorithmMetaboIdent()
default constructor
void ensureConvexHulls_(Feature &feature) const
Size sub_index
Definition: FeatureFinderAlgorithmMetaboIdent.h:127
void addTargetToLibrary_(const String &name, const 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)
Add a target (from the input file) to the assay library.
String candidates_out_
Definition: FeatureFinderAlgorithmMetaboIdent.h:204
std::map< String, double > target_rts_
RTs of targets (assays)
Definition: FeatureFinderAlgorithmMetaboIdent.h:221
double isotope_pmin_
min. isotope probability for peptide assay
Definition: FeatureFinderAlgorithmMetaboIdent.h:194
Boundaries for a mass trace in a feature.
Definition: FeatureFinderAlgorithmMetaboIdent.h:126
A container for features.
Definition: FeatureMap.h:80
An LC-MS feature.
Definition: Feature.h:46
Definition: IsotopeDistribution.h:39
The MRMFeatureFinder finds and scores peaks of transitions that co-elute.
Definition: MRMFeatureFinderScoring.h:66
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
bool metaValueExists(const String &name) const
Returns whether an entry with the given name exists.
const DataValue & getMetaValue(const String &name) const
Returns the value corresponding to a string, or DataValue::EMPTY if not found.
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:184
A more convenient string class.
Definition: String.h:34
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:297
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:39
Generic description of a coordinate transformation.
Definition: TransformationDescription.h:37
int Int
Signed integer type.
Definition: Types.h:76
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22
Comparison functor for features.
Definition: FeatureFinderAlgorithmMetaboIdent.h:150
bool operator()(const Feature &f1, const Feature &f2)
Definition: FeatureFinderAlgorithmMetaboIdent.h:151
Predicate for filtering features by overall quality.
Definition: FeatureFinderAlgorithmMetaboIdent.h:141
bool operator()(const Feature &feature)
Definition: FeatureFinderAlgorithmMetaboIdent.h:142
represents a compound in the assay library
Definition: FeatureFinderAlgorithmMetaboIdent.h:33
std::vector< double > rts_
Definition: FeatureFinderAlgorithmMetaboIdent.h:56
const std::vector< double > getRTRanges() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:81
double mass_
Definition: FeatureFinderAlgorithmMetaboIdent.h:54
std::vector< int > charges_
Definition: FeatureFinderAlgorithmMetaboIdent.h:55
const std::vector< double > & getIsotopeDistribution() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:85
String name_
Definition: FeatureFinderAlgorithmMetaboIdent.h:52
String formula_
Definition: FeatureFinderAlgorithmMetaboIdent.h:53
const std::vector< double > & getRTs() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:77
std::vector< double > iso_distrib_
Definition: FeatureFinderAlgorithmMetaboIdent.h:58
std::vector< double > rt_ranges_
Definition: FeatureFinderAlgorithmMetaboIdent.h:57
const String & getName() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:61
const std::vector< int > & getCharges() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:73
const String & getFormula() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:65
FeatureFinderMetaboIdentCompound(const String &_name, const 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)
Definition: FeatureFinderAlgorithmMetaboIdent.h:34
double getMass() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:69
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