OpenMS  2.8.0
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-2021.
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 
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 
89 
93  void run(const std::vector<FeatureFinderMetaboIdentCompound>& metaboIdentTable, FeatureMap& features, String spectra_file = "");
94 
96  PeakMap& getMSData() { return ms_data_; }
97  const PeakMap& getMSData() const { return ms_data_; }
98 
100  void setMSData(const PeakMap& m); // needed because pyOpenMS can't wrap the non-const reference version
101 
102  void setMSData(PeakMap&& m); // moves peak data and saves the copy. Note that getMSData() will give back a processed/modified version.
103 
105  const PeakMap& getChromatograms() const { return chrom_data_; }
106  PeakMap& getChromatograms() { return chrom_data_; }
107 
109  const TargetedExperiment& getLibrary() const { return library_; }
110 
112  const TransformationDescription& getTransformations() const { return trafo_; }
113 
115  size_t getNShared() const { return n_shared_; }
116 
118 protected:
119 
122  {
124  double rt_min, rt_max, mz_min, mz_max;
125  };
126 
128  typedef std::map<UInt64, std::vector<MassTraceBounds> > FeatureBoundsMap;
129 
132 
133  typedef std::vector<Feature*> FeatureGroup;
134 
137  {
138  bool operator()(const Feature& feature)
139  {
140  return feature.metaValueExists("FFMetId_remove");
141  }
142  } feature_filter_;
143 
146  {
147  bool operator()(const Feature& f1, const Feature& f2)
148  {
149  const String& ref1 = f1.getMetaValue("PeptideRef");
150  const String& ref2 = f2.getMetaValue("PeptideRef");
151  if (ref1 == ref2)
152  {
153  return f1.getRT() < f2.getRT();
154  }
155  return ref1 < ref2;
156  }
157  } feature_compare_;
158 
159 
160  void extractTransformations_(const FeatureMap& features);
161 
163  void addTargetToLibrary_(const String& name, const String& formula,
164  double mass, const std::vector<Int>& charges,
165  const std::vector<double>& rts,
166  std::vector<double> rt_ranges,
167  const std::vector<double>& iso_distrib);
168 
171 
172  void addTargetRT_(TargetedExperiment::Compound& target, double rt);
173 
175  double calculateMZ_(double mass, Int charge) const;
176 
177  void generateTransitions_(const String& target_id, double mz, Int charge,
178  const IsotopeDistribution& iso_dist);
179 
181  bool hasOverlappingBounds_(const std::vector<MassTraceBounds>& mtb1,
182  const std::vector<MassTraceBounds>& mtb2) const;
183 
184  void getFeatureBounds_(const FeatureMap& features,
185  FeatureBoundsMap& feature_bounds);
186 
187 
188  bool hasOverlappingFeature_(const Feature& feature, const FeatureGroup& group,
189  const FeatureBoundsMap& feature_bounds) const;
190 
192  const FeatureBoundsMap& feature_bounds,
193  std::vector<FeatureGroup>& overlap_groups);
194 
196  const FeatureBoundsMap& feature_bounds);
197 
198  void annotateFeatures_(FeatureMap& features);
199 
200  void ensureConvexHulls_(Feature& feature) const;
201 
203 
204  double rt_window_;
205  double mz_window_;
207 
208  double isotope_pmin_;
210 
211  double peak_width_;
214 
216 
217  // output file (before filtering)
219 
221 
222  void updateMembers_() override;
223 
226 
228 
230 
232 
234  std::map<String, double> isotope_probs_;
235  std::map<String, double> target_rts_;
236 
237  size_t n_shared_ = 0;
238 };
239 
240 } // namespace OpenMS
Isotope pattern generator for coarse isotope distributions.
Definition: CoarseIsotopePatternGenerator.h:98
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
Definition: FeatureFinderAlgorithmMetaboIdent.h:55
PeakMap & getMSData()
Retrieve chromatograms (empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:96
FeatureFinderAlgorithmPickedHelperStructs::MassTraces MassTraces
Definition: FeatureFinderAlgorithmMetaboIdent.h:131
const PeakMap & getMSData() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:97
TransformationDescription trafo_
Definition: FeatureFinderAlgorithmMetaboIdent.h:231
const PeakMap & getChromatograms() const
Retrieve chromatograms (empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:105
double rt_window_
RT window width.
Definition: FeatureFinderAlgorithmMetaboIdent.h:204
const TargetedExperiment & getLibrary() const
Retrieve the assay library (e.g., to store as TraML, empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:109
bool hasOverlappingFeature_(const Feature &feature, const FeatureGroup &group, const FeatureBoundsMap &feature_bounds) const
String elution_model_
Definition: FeatureFinderAlgorithmMetaboIdent.h:215
double calculateMZ_(double mass, Int charge) const
Calculate mass-to-charge ratio from mass and charge.
PeakMap & getChromatograms()
Definition: FeatureFinderAlgorithmMetaboIdent.h:106
void getFeatureBounds_(const FeatureMap &features, FeatureBoundsMap &feature_bounds)
MRMFeatureFinderScoring feat_finder_
OpenSWATH feature finder.
Definition: FeatureFinderAlgorithmMetaboIdent.h:227
const TransformationDescription & getTransformations() const
Retrieve deviations between provided coordinates and extracted ones (e.g., to store as TrafoXML or fo...
Definition: FeatureFinderAlgorithmMetaboIdent.h:112
void annotateFeatures_(FeatureMap &features)
double signal_to_noise_
Definition: FeatureFinderAlgorithmMetaboIdent.h:213
TargetedExperiment library_
accumulated assays for targets
Definition: FeatureFinderAlgorithmMetaboIdent.h:229
void addTargetRT_(TargetedExperiment::Compound &target, double rt)
double min_peak_width_
Definition: FeatureFinderAlgorithmMetaboIdent.h:212
double mz_max
Definition: FeatureFinderAlgorithmMetaboIdent.h:124
Size addTargetAnnotations_(FeatureMap &features)
Add "peptide" identifications with information about targets to features.
CoarseIsotopePatternGenerator iso_gen_
isotope pattern generator
Definition: FeatureFinderAlgorithmMetaboIdent.h:233
bool hasOverlappingBounds_(const std::vector< MassTraceBounds > &mtb1, const std::vector< MassTraceBounds > &mtb2) const
Check if two sets of mass trace boundaries overlap.
void selectFeaturesFromCandidates_(FeatureMap &features)
PeakMap ms_data_
input LC-MS data
Definition: FeatureFinderAlgorithmMetaboIdent.h:224
double mz_window_
m/z window width
Definition: FeatureFinderAlgorithmMetaboIdent.h:205
std::map< String, double > isotope_probs_
isotope probabilities of transitions
Definition: FeatureFinderAlgorithmMetaboIdent.h:234
double peak_width_
Definition: FeatureFinderAlgorithmMetaboIdent.h:211
void findOverlappingFeatures_(FeatureMap &features, const FeatureBoundsMap &feature_bounds, std::vector< FeatureGroup > &overlap_groups)
FeatureFinderAlgorithmPickedHelperStructs::MassTrace MassTrace
Definition: FeatureFinderAlgorithmMetaboIdent.h:130
Size n_isotopes_
number of isotopes for peptide assay
Definition: FeatureFinderAlgorithmMetaboIdent.h:209
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:115
Size debug_level_
Definition: FeatureFinderAlgorithmMetaboIdent.h:220
std::map< UInt64, std::vector< MassTraceBounds > > FeatureBoundsMap
Boundaries for all mass traces per feature.
Definition: FeatureFinderAlgorithmMetaboIdent.h:128
bool mz_window_ppm_
m/z window width is given in PPM (not Da)?
Definition: FeatureFinderAlgorithmMetaboIdent.h:206
std::vector< Feature * > FeatureGroup
group of (overlapping) features
Definition: FeatureFinderAlgorithmMetaboIdent.h:133
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 resolveOverlappingFeatures_(FeatureGroup &group, const FeatureBoundsMap &feature_bounds)
String prettyPrintCompound(const TargetedExperiment::Compound &compound)
void run(const std::vector< FeatureFinderMetaboIdentCompound > &metaboIdentTable, FeatureMap &features, String spectra_file="")
perform targeted feature extraction of compounds from
void setMSData(const PeakMap &m)
Set spectra.
PeakMap chrom_data_
accumulated chromatograms (XICs)
Definition: FeatureFinderAlgorithmMetaboIdent.h:225
FeatureFinderAlgorithmMetaboIdent()
default constructor
void ensureConvexHulls_(Feature &feature) const
Size sub_index
Definition: FeatureFinderAlgorithmMetaboIdent.h:123
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:218
std::map< String, double > target_rts_
RTs of targets (assays)
Definition: FeatureFinderAlgorithmMetaboIdent.h:235
double isotope_pmin_
min. isotope probability for peptide assay
Definition: FeatureFinderAlgorithmMetaboIdent.h:208
Boundaries for a mass trace in a feature.
Definition: FeatureFinderAlgorithmMetaboIdent.h:122
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:73
bool metaValueExists(const String &name) const
Returns whether an entry with the given name exists.
const DataValue & getMetaValue(const String &name, const DataValue &default_value=DataValue::EMPTY) const
Returns the value corresponding to a string, or a default value (default: DataValue::EMPTY) if not fo...
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:208
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:47
Comparison functor for features.
Definition: FeatureFinderAlgorithmMetaboIdent.h:146
bool operator()(const Feature &f1, const Feature &f2)
Definition: FeatureFinderAlgorithmMetaboIdent.h:147
Predicate for filtering features by overall quality.
Definition: FeatureFinderAlgorithmMetaboIdent.h:137
bool operator()(const Feature &feature)
Definition: FeatureFinderAlgorithmMetaboIdent.h:138
represents a compound in the assay library
Definition: FeatureFinderAlgorithmMetaboIdent.h:59
std::vector< double > rt_ranges
Definition: FeatureFinderAlgorithmMetaboIdent.h:83
double mass
Definition: FeatureFinderAlgorithmMetaboIdent.h:80
std::vector< double > rts
Definition: FeatureFinderAlgorithmMetaboIdent.h:82
std::vector< int > charges
Definition: FeatureFinderAlgorithmMetaboIdent.h:81
String name
Definition: FeatureFinderAlgorithmMetaboIdent.h:78
String formula
Definition: FeatureFinderAlgorithmMetaboIdent.h:79
std::vector< double > iso_distrib
Definition: FeatureFinderAlgorithmMetaboIdent.h:84
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
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