OpenMS  3.0.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-2022.
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 
117  String prettyPrintCompound(const TargetedExperiment::Compound& compound);
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 
170  Size addTargetAnnotations_(FeatureMap& features);
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 
191  void findOverlappingFeatures_(FeatureMap& features,
192  const FeatureBoundsMap& feature_bounds,
193  std::vector<FeatureGroup>& overlap_groups);
194 
195  void resolveOverlappingFeatures_(FeatureGroup& group,
196  const FeatureBoundsMap& feature_bounds);
197 
198  void annotateFeatures_(FeatureMap& features);
199 
200  void ensureConvexHulls_(Feature& feature) const;
201 
202  void selectFeaturesFromCandidates_(FeatureMap& features);
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
OpenMS::FeatureFinderAlgorithmMetaboIdent::getNShared
size_t getNShared() const
Retrieve number of features with shared identifications.
Definition: FeatureFinderAlgorithmMetaboIdent.h:115
DefaultParamHandler.h
TargetedExperiment.h
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFilterQuality::operator()
bool operator()(const Feature &feature)
Definition: FeatureFinderAlgorithmMetaboIdent.h:138
OpenMS::FeatureFinderAlgorithmMetaboIdent::signal_to_noise_
double signal_to_noise_
Definition: FeatureFinderAlgorithmMetaboIdent.h:213
OpenMS::FeatureFinderAlgorithmMetaboIdent::MassTraceBounds::rt_min
double rt_min
Definition: FeatureFinderAlgorithmMetaboIdent.h:124
OpenMS::FeatureFinderAlgorithmMetaboIdent::target_rts_
std::map< String, double > target_rts_
RTs of targets (assays)
Definition: FeatureFinderAlgorithmMetaboIdent.h:235
OpenMS::MRMFeatureFinderScoring
The MRMFeatureFinder finds and scores peaks of transitions that co-elute.
Definition: MRMFeatureFinderScoring.h:89
OpenMS::MetaInfoInterface::getMetaValue
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...
OpenMS::FeatureFinderAlgorithmMetaboIdent::candidates_out_
String candidates_out_
Definition: FeatureFinderAlgorithmMetaboIdent.h:218
OpenMS::FeatureFinderAlgorithmMetaboIdent::mz_window_
double mz_window_
m/z window width
Definition: FeatureFinderAlgorithmMetaboIdent.h:205
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFinderMetaboIdentCompound::mass
double mass
Definition: FeatureFinderAlgorithmMetaboIdent.h:80
OpenMS::MSExperiment
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:70
OpenMS::FeatureFinderAlgorithmPickedHelperStructs::MassTrace
Helper struct for mass traces used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:79
OpenMS::CoarseIsotopePatternGenerator
Isotope pattern generator for coarse isotope distributions.
Definition: CoarseIsotopePatternGenerator.h:103
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFinderMetaboIdentCompound::charges
std::vector< int > charges
Definition: FeatureFinderAlgorithmMetaboIdent.h:81
OpenMS::FeatureFinderAlgorithmMetaboIdent
Definition: FeatureFinderAlgorithmMetaboIdent.h:53
OpenMS::FeatureFinderAlgorithmMetaboIdent::debug_level_
Size debug_level_
Definition: FeatureFinderAlgorithmMetaboIdent.h:220
OpenMS::FeatureFinderAlgorithmMetaboIdent::MassTraceBounds::sub_index
Size sub_index
Definition: FeatureFinderAlgorithmMetaboIdent.h:123
FeatureFinderAlgorithmPickedHelperStructs.h
TransformationDescription.h
OpenMS::FeatureFinderAlgorithmMetaboIdent::chrom_data_
PeakMap chrom_data_
accumulated chromatograms (XICs)
Definition: FeatureFinderAlgorithmMetaboIdent.h:225
OpenMS::FeatureFinderAlgorithmMetaboIdent::iso_gen_
CoarseIsotopePatternGenerator iso_gen_
isotope pattern generator
Definition: FeatureFinderAlgorithmMetaboIdent.h:233
OpenMS::FeatureFinderAlgorithmMetaboIdent::isotope_probs_
std::map< String, double > isotope_probs_
isotope probabilities of transitions
Definition: FeatureFinderAlgorithmMetaboIdent.h:234
OpenMS::FeatureFinderAlgorithmMetaboIdent::mz_window_ppm_
bool mz_window_ppm_
m/z window width is given in PPM (not Da)?
Definition: FeatureFinderAlgorithmMetaboIdent.h:206
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureGroup
std::vector< Feature * > FeatureGroup
group of (overlapping) features
Definition: FeatureFinderAlgorithmMetaboIdent.h:133
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
OpenMS::FeatureFinderAlgorithmMetaboIdent::rt_window_
double rt_window_
RT window width.
Definition: FeatureFinderAlgorithmMetaboIdent.h:204
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFinderMetaboIdentCompound
represents a compound in the assay library
Definition: FeatureFinderAlgorithmMetaboIdent.h:58
OpenMS::FeatureFinderAlgorithmMetaboIdent::elution_model_
String elution_model_
Definition: FeatureFinderAlgorithmMetaboIdent.h:215
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
ProgressLogger.h
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureBoundsMap
std::map< UInt64, std::vector< MassTraceBounds > > FeatureBoundsMap
Boundaries for all mass traces per feature.
Definition: FeatureFinderAlgorithmMetaboIdent.h:128
MRMFeatureFinderScoring.h
CoarseIsotopePatternGenerator.h
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFilterQuality
Predicate for filtering features by overall quality.
Definition: FeatureFinderAlgorithmMetaboIdent.h:136
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFinderMetaboIdentCompound::rt_ranges
std::vector< double > rt_ranges
Definition: FeatureFinderAlgorithmMetaboIdent.h:83
OpenMS::TargetedExperimentHelper::Compound
Represents a compound (small molecule)
Definition: TargetedExperimentHelper.h:321
OpenMS::FeatureFinderAlgorithmMetaboIdent::MassTrace
FeatureFinderAlgorithmPickedHelperStructs::MassTrace MassTrace
Definition: FeatureFinderAlgorithmMetaboIdent.h:130
OpenMS::Peak2D::getRT
CoordinateType getRT() const
Returns the RT coordinate (index 0)
Definition: Peak2D.h:208
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFinderMetaboIdentCompound::FeatureFinderMetaboIdentCompound
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
OpenMS::FeatureFinderAlgorithmMetaboIdent::ms_data_
PeakMap ms_data_
input LC-MS data
Definition: FeatureFinderAlgorithmMetaboIdent.h:224
OpenMS::FeatureFinderAlgorithmMetaboIdent::getMSData
PeakMap & getMSData()
Retrieve chromatograms (empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:96
OpenMS::FeatureFinderAlgorithmMetaboIdent::getChromatograms
const PeakMap & getChromatograms() const
Retrieve chromatograms (empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:105
OpenMS::FeatureFinderAlgorithmMetaboIdent::n_isotopes_
Size n_isotopes_
number of isotopes for peptide assay
Definition: FeatureFinderAlgorithmMetaboIdent.h:209
OpenMS::FeatureFinderAlgorithmMetaboIdent::getChromatograms
PeakMap & getChromatograms()
Definition: FeatureFinderAlgorithmMetaboIdent.h:106
OpenMS::FeatureFinderAlgorithmMetaboIdent::MassTraceBounds
Boundaries for a mass trace in a feature.
Definition: FeatureFinderAlgorithmMetaboIdent.h:121
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFinderMetaboIdentCompound::formula
String formula
Definition: FeatureFinderAlgorithmMetaboIdent.h:79
MSExperiment.h
OpenMS::FeatureFinderAlgorithmMetaboIdent::getLibrary
const TargetedExperiment & getLibrary() const
Retrieve the assay library (e.g., to store as TraML, empty if run was not executed)
Definition: FeatureFinderAlgorithmMetaboIdent.h:109
OpenMS::FeatureFinderAlgorithmMetaboIdent::min_peak_width_
double min_peak_width_
Definition: FeatureFinderAlgorithmMetaboIdent.h:212
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureCompare::operator()
bool operator()(const Feature &f1, const Feature &f2)
Definition: FeatureFinderAlgorithmMetaboIdent.h:147
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:98
OpenMS::IsotopeDistribution
Definition: IsotopeDistribution.h:64
OpenMS::Feature
An LC-MS feature.
Definition: Feature.h:70
OpenMS::MetaInfoInterface::metaValueExists
bool metaValueExists(const String &name) const
Returns whether an entry with the given name exists.
OpenMS::FeatureFinderAlgorithmMetaboIdent::isotope_pmin_
double isotope_pmin_
min. isotope probability for peptide assay
Definition: FeatureFinderAlgorithmMetaboIdent.h:208
OpenMS::FeatureFinderAlgorithmMetaboIdent::library_
TargetedExperiment library_
accumulated assays for targets
Definition: FeatureFinderAlgorithmMetaboIdent.h:229
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFinderMetaboIdentCompound::rts
std::vector< double > rts
Definition: FeatureFinderAlgorithmMetaboIdent.h:82
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureCompare
Comparison functor for features.
Definition: FeatureFinderAlgorithmMetaboIdent.h:145
OpenMS::FeatureFinderAlgorithmPickedHelperStructs::MassTraces
Helper struct for a collection of mass traces used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:109
OpenMS::TargetedExperiment
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:64
OpenMS::FeatureFinderAlgorithmMetaboIdent::peak_width_
double peak_width_
Definition: FeatureFinderAlgorithmMetaboIdent.h:211
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFinderMetaboIdentCompound::iso_distrib
std::vector< double > iso_distrib
Definition: FeatureFinderAlgorithmMetaboIdent.h:84
OpenMS::FeatureFinderAlgorithmMetaboIdent::trafo_
TransformationDescription trafo_
Definition: FeatureFinderAlgorithmMetaboIdent.h:231
OpenMS::FeatureFinderAlgorithmMetaboIdent::feat_finder_
MRMFeatureFinderScoring feat_finder_
OpenSWATH feature finder.
Definition: FeatureFinderAlgorithmMetaboIdent.h:227
OpenMS::TransformationDescription
Generic description of a coordinate transformation.
Definition: TransformationDescription.h:62
OpenMS::FeatureFinderAlgorithmMetaboIdent::MassTraces
FeatureFinderAlgorithmPickedHelperStructs::MassTraces MassTraces
Definition: FeatureFinderAlgorithmMetaboIdent.h:131
OpenMS::FeatureFinderAlgorithmMetaboIdent::getTransformations
const TransformationDescription & getTransformations() const
Retrieve deviations between provided coordinates and extracted ones (e.g., to store as TrafoXML or fo...
Definition: FeatureFinderAlgorithmMetaboIdent.h:112
OpenMS::FeatureFinderAlgorithmMetaboIdent::FeatureFinderMetaboIdentCompound::name
String name
Definition: FeatureFinderAlgorithmMetaboIdent.h:78
OpenMS::FeatureFinderAlgorithmMetaboIdent::getMSData
const PeakMap & getMSData() const
Definition: FeatureFinderAlgorithmMetaboIdent.h:97