OpenMS  2.7.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 
91  void run(const std::vector<FeatureFinderMetaboIdentCompound>& metaboIdentTable, FeatureMap& features);
92 
94  PeakMap& getMSData() { return ms_data_; }
95  const PeakMap& getMSData() const { return ms_data_; }
96 
98  void setMSData(const PeakMap& m) { ms_data_ = m; } // needed because pyOpenMS can't wrap the non-const reference version
99 
101  const PeakMap& getChromatograms() const { return chrom_data_; }
102  PeakMap& getChromatograms() { return chrom_data_; }
103 
105  const TargetedExperiment& getLibrary() const { return library_; }
106 
108  const TransformationDescription& getTransformations() const { return trafo_; }
109 
111  size_t getNShared() const { return n_shared_; }
112 
114 protected:
115 
118  {
120  double rt_min, rt_max, mz_min, mz_max;
121  };
122 
124  typedef std::map<UInt64, std::vector<MassTraceBounds> > FeatureBoundsMap;
125 
128 
129  typedef std::vector<Feature*> FeatureGroup;
130 
133  {
134  bool operator()(const Feature& feature)
135  {
136  return feature.metaValueExists("FFMetId_remove");
137  }
138  } feature_filter_;
139 
142  {
143  bool operator()(const Feature& f1, const Feature& f2)
144  {
145  const String& ref1 = f1.getMetaValue("PeptideRef");
146  const String& ref2 = f2.getMetaValue("PeptideRef");
147  if (ref1 == ref2)
148  {
149  return f1.getRT() < f2.getRT();
150  }
151  return ref1 < ref2;
152  }
153  } feature_compare_;
154 
155 
156  void extractTransformations_(const FeatureMap& features);
157 
159  void addTargetToLibrary_(const String& name, const String& formula,
160  double mass, const std::vector<Int>& charges,
161  const std::vector<double>& rts,
162  std::vector<double> rt_ranges,
163  const std::vector<double>& iso_distrib);
164 
167 
168  void addTargetRT_(TargetedExperiment::Compound& target, double rt);
169 
171  double calculateMZ_(double mass, Int charge) const;
172 
173  void generateTransitions_(const String& target_id, double mz, Int charge,
174  const IsotopeDistribution& iso_dist);
175 
177  bool hasOverlappingBounds_(const std::vector<MassTraceBounds>& mtb1,
178  const std::vector<MassTraceBounds>& mtb2) const;
179 
180  void getFeatureBounds_(const FeatureMap& features,
181  FeatureBoundsMap& feature_bounds);
182 
183 
184  bool hasOverlappingFeature_(const Feature& feature, const FeatureGroup& group,
185  const FeatureBoundsMap& feature_bounds) const;
186 
188  const FeatureBoundsMap& feature_bounds,
189  std::vector<FeatureGroup>& overlap_groups);
190 
192  const FeatureBoundsMap& feature_bounds);
193 
194  void annotateFeatures_(FeatureMap& features);
195 
196  void ensureConvexHulls_(Feature& feature) const;
197 
199 
200  double rt_window_;
201  double mz_window_;
203 
204  double isotope_pmin_;
206 
207  double peak_width_;
210 
212 
213  // output file (before filtering)
215 
217 
218  void updateMembers_() override;
219 
222 
224 
226 
228 
230  std::map<String, double> isotope_probs_;
231  std::map<String, double> target_rts_;
232 
233  size_t n_shared_;
234 };
235 
236 } // 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:94
FeatureFinderAlgorithmPickedHelperStructs::MassTraces MassTraces
Definition: FeatureFinderAlgorithmMetaboIdent.h:127
const PeakMap & getMSData() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:95
TransformationDescription trafo_
Definition: FeatureFinderAlgorithmMetaboIdent.h:227
const PeakMap & getChromatograms() const
Retrieve chromatograms (empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:101
double rt_window_
RT window width.
Definition: FeatureFinderAlgorithmMetaboIdent.h:200
const TargetedExperiment & getLibrary() const
Retrieve the assay library (e.g., to store as TraML, empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:105
bool hasOverlappingFeature_(const Feature &feature, const FeatureGroup &group, const FeatureBoundsMap &feature_bounds) const
String elution_model_
Definition: FeatureFinderAlgorithmMetaboIdent.h:211
double calculateMZ_(double mass, Int charge) const
Calculate mass-to-charge ratio from mass and charge.
PeakMap & getChromatograms()
Definition: FeatureFinderAlgorithmMetaboIdent.h:102
void getFeatureBounds_(const FeatureMap &features, FeatureBoundsMap &feature_bounds)
MRMFeatureFinderScoring feat_finder_
OpenSWATH feature finder.
Definition: FeatureFinderAlgorithmMetaboIdent.h:223
const TransformationDescription & getTransformations() const
Retrieve deviations between provided coordinates and extracted ones (e.g., to store as TrafoXML or fo...
Definition: FeatureFinderAlgorithmMetaboIdent.h:108
void annotateFeatures_(FeatureMap &features)
double signal_to_noise_
Definition: FeatureFinderAlgorithmMetaboIdent.h:209
TargetedExperiment library_
accumulated assays for targets
Definition: FeatureFinderAlgorithmMetaboIdent.h:225
void addTargetRT_(TargetedExperiment::Compound &target, double rt)
double min_peak_width_
Definition: FeatureFinderAlgorithmMetaboIdent.h:208
double mz_max
Definition: FeatureFinderAlgorithmMetaboIdent.h:120
Size addTargetAnnotations_(FeatureMap &features)
Add "peptide" identifications with information about targets to features.
CoarseIsotopePatternGenerator iso_gen_
isotope pattern generator
Definition: FeatureFinderAlgorithmMetaboIdent.h:229
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:220
double mz_window_
m/z window width
Definition: FeatureFinderAlgorithmMetaboIdent.h:201
std::map< String, double > isotope_probs_
isotope probabilities of transitions
Definition: FeatureFinderAlgorithmMetaboIdent.h:230
double peak_width_
Definition: FeatureFinderAlgorithmMetaboIdent.h:207
void findOverlappingFeatures_(FeatureMap &features, const FeatureBoundsMap &feature_bounds, std::vector< FeatureGroup > &overlap_groups)
FeatureFinderAlgorithmPickedHelperStructs::MassTrace MassTrace
Definition: FeatureFinderAlgorithmMetaboIdent.h:126
Size n_isotopes_
number of isotopes for peptide assay
Definition: FeatureFinderAlgorithmMetaboIdent.h:205
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:111
Size debug_level_
Definition: FeatureFinderAlgorithmMetaboIdent.h:216
std::map< UInt64, std::vector< MassTraceBounds > > FeatureBoundsMap
Boundaries for all mass traces per feature.
Definition: FeatureFinderAlgorithmMetaboIdent.h:124
bool mz_window_ppm_
m/z window width is given in PPM (not Da)?
Definition: FeatureFinderAlgorithmMetaboIdent.h:202
std::vector< Feature * > FeatureGroup
group of (overlapping) features
Definition: FeatureFinderAlgorithmMetaboIdent.h:129
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)
perform targeted feature extraction of compounds from
void setMSData(const PeakMap &m)
Set spectra.
Definition: FeatureFinderAlgorithmMetaboIdent.h:98
PeakMap chrom_data_
accumulated chromatograms (XICs)
Definition: FeatureFinderAlgorithmMetaboIdent.h:221
FeatureFinderAlgorithmMetaboIdent()
default constructor
void ensureConvexHulls_(Feature &feature) const
Size sub_index
Definition: FeatureFinderAlgorithmMetaboIdent.h:119
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:214
std::map< String, double > target_rts_
RTs of targets (assays)
Definition: FeatureFinderAlgorithmMetaboIdent.h:231
double isotope_pmin_
min. isotope probability for peptide assay
Definition: FeatureFinderAlgorithmMetaboIdent.h:204
size_t n_shared_
Definition: FeatureFinderAlgorithmMetaboIdent.h:233
Boundaries for a mass trace in a feature.
Definition: FeatureFinderAlgorithmMetaboIdent.h:118
A container for features.
Definition: FeatureMap.h:105
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:96
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:80
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:61
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:142
bool operator()(const Feature &f1, const Feature &f2)
Definition: FeatureFinderAlgorithmMetaboIdent.h:143
Predicate for filtering features by overall quality.
Definition: FeatureFinderAlgorithmMetaboIdent.h:133
bool operator()(const Feature &feature)
Definition: FeatureFinderAlgorithmMetaboIdent.h:134
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