OpenMS
FeatureFinderAlgorithmMetaboIdent.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: Timo Sachsenberg, Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
45 
46 #include <map>
47 #include <vector>
48 
49 namespace OpenMS
50 {
51 class IsotopeDistribution;
52 
53 class OPENMS_DLLAPI FeatureFinderAlgorithmMetaboIdent :
54  public DefaultParamHandler
55 {
56 public:
58  struct OPENMS_DLLAPI FeatureFinderMetaboIdentCompound
59  {
61  const String& _formula,
62  double _mass,
63  const std::vector<int>& _charges,
64  const std::vector<double>& _rts,
65  const std::vector<double>& _rt_ranges,
66  const std::vector<double>& _iso_distrib):
67  name_(_name),
68  formula_(_formula),
69  mass_(_mass),
70  charges_(_charges),
71  rts_(_rts),
72  rt_ranges_(_rt_ranges),
73  iso_distrib_(_iso_distrib)
74  {
75  }
76 
77  private:
80  double mass_;
81  std::vector<int> charges_;
82  std::vector<double> rts_;
83  std::vector<double> rt_ranges_;
84  std::vector<double> iso_distrib_;
85 
86  public:
87  const String& getName() const {
88  return name_;
89  }
90 
91  const String& getFormula() const {
92  return formula_;
93  }
94 
95  double getMass() const {
96  return mass_;
97  }
98 
99  const std::vector<int>& getCharges() const {
100  return charges_;
101  }
102 
103  const std::vector<double>& getRTs() const {
104  return rts_;
105  }
106 
107  const std::vector<double> getRTRanges() const {
108  return rt_ranges_;
109  }
110 
111  const std::vector<double>& getIsotopeDistribution() const {
112  return iso_distrib_;
113  }
114  };
115 
118 
123  void run(const std::vector<FeatureFinderMetaboIdentCompound>& metaboIdentTable, FeatureMap& features, const String& spectra_file = "");
124 
126  PeakMap& getMSData() { return ms_data_; }
127  const PeakMap& getMSData() const { return ms_data_; }
128 
130  void setMSData(const PeakMap& m); // needed because pyOpenMS can't wrap the non-const reference version
131 
132  void setMSData(PeakMap&& m); // moves peak data and saves the copy. Note that getMSData() will give back a processed/modified version.
133 
135  const PeakMap& getChromatograms() const { return chrom_data_; }
136  PeakMap& getChromatograms() { return chrom_data_; }
137 
139  const TargetedExperiment& getLibrary() const { return library_; }
140 
142  const TransformationDescription& getTransformations() const { return trafo_; }
143 
145  size_t getNShared() const { return n_shared_; }
146 
148 protected:
149 
152  {
154  double rt_min, rt_max, mz_min, mz_max;
155  };
156 
158  typedef std::map<UInt64, std::vector<MassTraceBounds> > FeatureBoundsMap;
159 
162 
163  typedef std::vector<Feature*> FeatureGroup;
164 
167  {
168  bool operator()(const Feature& feature)
169  {
170  return feature.metaValueExists("FFMetId_remove");
171  }
172  } feature_filter_;
173 
176  {
177  bool operator()(const Feature& f1, const Feature& f2)
178  {
179  const String& ref1 = f1.getMetaValue("PeptideRef");
180  const String& ref2 = f2.getMetaValue("PeptideRef");
181  if (ref1 == ref2)
182  {
183  return f1.getRT() < f2.getRT();
184  }
185  return ref1 < ref2;
186  }
187  } feature_compare_;
188 
189 
190  void extractTransformations_(const FeatureMap& features);
191 
193  void addTargetToLibrary_(const String& name, const String& formula,
194  double mass, const std::vector<Int>& charges,
195  const std::vector<double>& rts,
196  std::vector<double> rt_ranges,
197  const std::vector<double>& iso_distrib);
198 
201 
202  void addTargetRT_(TargetedExperiment::Compound& target, double rt);
203 
205  double calculateMZ_(double mass, Int charge) const;
206 
207  void generateTransitions_(const String& target_id, double mz, Int charge,
208  const IsotopeDistribution& iso_dist);
209 
210  void annotateFeatures_(FeatureMap& features);
211 
212  void ensureConvexHulls_(Feature& feature) const;
213 
215 
216  double rt_window_;
217  double mz_window_;
219 
220  double isotope_pmin_;
222 
223  double peak_width_;
226 
228 
229  // output file (before filtering)
231 
233 
234  void updateMembers_() override;
235 
238 
240 
242 
244 
246  std::map<String, double> isotope_probs_;
247  std::map<String, double> target_rts_;
248 
249  size_t n_shared_ = 0;
250 };
251 
252 } // namespace OpenMS
Isotope pattern generator for coarse isotope distributions.
Definition: CoarseIsotopePatternGenerator.h:105
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
Definition: FeatureFinderAlgorithmMetaboIdent.h:55
PeakMap & getMSData()
Retrieve chromatograms (empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:126
FeatureFinderAlgorithmPickedHelperStructs::MassTraces MassTraces
Definition: FeatureFinderAlgorithmMetaboIdent.h:161
const PeakMap & getMSData() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:127
TransformationDescription trafo_
Definition: FeatureFinderAlgorithmMetaboIdent.h:243
const PeakMap & getChromatograms() const
Retrieve chromatograms (empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:135
double rt_window_
RT window width.
Definition: FeatureFinderAlgorithmMetaboIdent.h:216
const TargetedExperiment & getLibrary() const
Retrieve the assay library (e.g., to store as TraML, empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:139
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:227
double calculateMZ_(double mass, Int charge) const
Calculate mass-to-charge ratio from mass and charge.
PeakMap & getChromatograms()
Definition: FeatureFinderAlgorithmMetaboIdent.h:136
MRMFeatureFinderScoring feat_finder_
OpenSWATH feature finder.
Definition: FeatureFinderAlgorithmMetaboIdent.h:239
const TransformationDescription & getTransformations() const
Retrieve deviations between provided coordinates and extracted ones (e.g., to store as TrafoXML or fo...
Definition: FeatureFinderAlgorithmMetaboIdent.h:142
void annotateFeatures_(FeatureMap &features)
double signal_to_noise_
Definition: FeatureFinderAlgorithmMetaboIdent.h:225
TargetedExperiment library_
accumulated assays for targets
Definition: FeatureFinderAlgorithmMetaboIdent.h:241
void addTargetRT_(TargetedExperiment::Compound &target, double rt)
double min_peak_width_
Definition: FeatureFinderAlgorithmMetaboIdent.h:224
double mz_max
Definition: FeatureFinderAlgorithmMetaboIdent.h:154
Size addTargetAnnotations_(FeatureMap &features)
Add "peptide" identifications with information about targets to features.
CoarseIsotopePatternGenerator iso_gen_
isotope pattern generator
Definition: FeatureFinderAlgorithmMetaboIdent.h:245
void selectFeaturesFromCandidates_(FeatureMap &features)
PeakMap ms_data_
input LC-MS data
Definition: FeatureFinderAlgorithmMetaboIdent.h:236
double mz_window_
m/z window width
Definition: FeatureFinderAlgorithmMetaboIdent.h:217
std::map< String, double > isotope_probs_
isotope probabilities of transitions
Definition: FeatureFinderAlgorithmMetaboIdent.h:246
double peak_width_
Definition: FeatureFinderAlgorithmMetaboIdent.h:223
FeatureFinderAlgorithmPickedHelperStructs::MassTrace MassTrace
Definition: FeatureFinderAlgorithmMetaboIdent.h:160
Size n_isotopes_
number of isotopes for peptide assay
Definition: FeatureFinderAlgorithmMetaboIdent.h:221
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:145
Size debug_level_
Definition: FeatureFinderAlgorithmMetaboIdent.h:232
std::map< UInt64, std::vector< MassTraceBounds > > FeatureBoundsMap
Boundaries for all mass traces per feature.
Definition: FeatureFinderAlgorithmMetaboIdent.h:158
bool mz_window_ppm_
m/z window width is given in PPM (not Da)?
Definition: FeatureFinderAlgorithmMetaboIdent.h:218
std::vector< Feature * > FeatureGroup
group of (overlapping) features
Definition: FeatureFinderAlgorithmMetaboIdent.h:163
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:237
FeatureFinderAlgorithmMetaboIdent()
default constructor
void ensureConvexHulls_(Feature &feature) const
Size sub_index
Definition: FeatureFinderAlgorithmMetaboIdent.h:153
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:230
std::map< String, double > target_rts_
RTs of targets (assays)
Definition: FeatureFinderAlgorithmMetaboIdent.h:247
double isotope_pmin_
min. isotope probability for peptide assay
Definition: FeatureFinderAlgorithmMetaboIdent.h:220
Boundaries for a mass trace in a feature.
Definition: FeatureFinderAlgorithmMetaboIdent.h:152
A container for features.
Definition: FeatureMap.h:106
An LC-MS feature.
Definition: Feature.h:72
Definition: IsotopeDistribution.h:65
The MRMFeatureFinder finds and scores peaks of transitions that co-elute.
Definition: MRMFeatureFinderScoring.h:92
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:72
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:210
A more convenient string class.
Definition: String.h:60
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:323
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:65
Generic description of a coordinate transformation.
Definition: TransformationDescription.h:63
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
Comparison functor for features.
Definition: FeatureFinderAlgorithmMetaboIdent.h:176
bool operator()(const Feature &f1, const Feature &f2)
Definition: FeatureFinderAlgorithmMetaboIdent.h:177
Predicate for filtering features by overall quality.
Definition: FeatureFinderAlgorithmMetaboIdent.h:167
bool operator()(const Feature &feature)
Definition: FeatureFinderAlgorithmMetaboIdent.h:168
represents a compound in the assay library
Definition: FeatureFinderAlgorithmMetaboIdent.h:59
std::vector< double > rts_
Definition: FeatureFinderAlgorithmMetaboIdent.h:82
const std::vector< double > getRTRanges() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:107
double mass_
Definition: FeatureFinderAlgorithmMetaboIdent.h:80
std::vector< int > charges_
Definition: FeatureFinderAlgorithmMetaboIdent.h:81
const std::vector< double > & getIsotopeDistribution() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:111
String name_
Definition: FeatureFinderAlgorithmMetaboIdent.h:78
String formula_
Definition: FeatureFinderAlgorithmMetaboIdent.h:79
const std::vector< double > & getRTs() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:103
std::vector< double > iso_distrib_
Definition: FeatureFinderAlgorithmMetaboIdent.h:84
std::vector< double > rt_ranges_
Definition: FeatureFinderAlgorithmMetaboIdent.h:83
const String & getName() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:87
const std::vector< int > & getCharges() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:99
const String & getFormula() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:91
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:60
double getMass() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:95
Helper struct for mass traces used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:80
Helper struct for a collection of mass traces used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:111