OpenMS  3.0.0
FeatureFinderAlgorithmPicked.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: Marc Sturm $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
40 
41 #include <fstream>
42 
43 namespace OpenMS
44 {
58  class OPENMS_DLLAPI FeatureFinderAlgorithmPicked :
60  public FeatureFinderDefs
61  {
62 public:
64 
69 
74 
75 protected:
76  typedef Peak1D PeakType;
82 
83 public:
86 
87  // docu in base class
88  void setSeeds(const FeatureMap& seeds) override;
89 
91  void run() override;
92 
93  static FeatureFinderAlgorithm* create();
94 
95  static const String getProductName();
96 
97 protected:
101  mutable std::ofstream log_;
103  bool debug_;
105  std::map<String, UInt> aborts_;
107  std::map<Seed, String> abort_reasons_;
110 
112 
117  double slope_bound_;
125  double min_rt_span_;
126  double max_rt_span_;
129 
130 
132 
133  double intensity_rt_step_;
138  std::vector<std::vector<std::vector<double> > > intensity_thresholds_;
140 
142  std::vector<TheoreticalIsotopePattern> isotope_distributions_;
143 
144  // Docu in base class
145  void updateMembers_() override;
146 
148  void abort_(const Seed& seed, const String& reason);
149 
154  double intersection_(const Feature& f1, const Feature& f2) const;
155 
157  const TheoreticalIsotopePattern& getIsotopeDistribution_(double mass) const;
158 
166  double findBestIsotopeFit_(const Seed& center, UInt charge, IsotopePattern& best_pattern) const;
167 
175  void extendMassTraces_(const IsotopePattern& pattern, MassTraces& traces, Size meta_index_overall) const;
176 
195  void extendMassTrace_(MassTrace& trace, SignedSize spectrum_index, double mz, bool increase_rt, Size meta_index_overall, double min_rt = 0.0, double max_rt = 0.0) const;
196 
198  Size nearest_(double pos, const MSSpectrum& spec, Size start) const;
199 
209  void findIsotope_(double pos, Size spectrum_index, IsotopePattern& pattern, Size pattern_index, Size& peak_index) const;
210 
212  double positionScore_(double pos1, double pos2, double allowed_deviation) const;
213 
215  double isotopeScore_(const TheoreticalIsotopePattern& isotopes, IsotopePattern& pattern, bool consider_mz_distances) const;
216 
227  double intensityScore_(Size spectrum, Size peak) const;
228 
235  std::unique_ptr<TraceFitter> chooseTraceFitter_(double& tau);
236 
237  double intensityScore_(Size rt_bin, Size mz_bin, double intensity) const;
238 
245 
254  void cropFeature_(std::shared_ptr<TraceFitter> fitter,
255  const MassTraces& traces,
256  MassTraces& new_traces);
257 
281  bool checkFeatureQuality_(std::shared_ptr<TraceFitter> fitter,
282  MassTraces& feature_traces,
283  const double& seed_mz, const double& min_feature_score,
284  String& error_msg, double& fit_score, double& correlation, double& final_score);
285 
299  void writeFeatureDebugInfo_(std::shared_ptr<TraceFitter> fitter,
300  const MassTraces& traces,
301  const MassTraces& new_traces,
302  bool feature_ok, const String error_msg, const double final_score, const Int plot_nr, const PeakType& peak,
303  const String path = "debug/features/");
304 
306 private:
307 
312  };
313 
314 } // namespace OpenMS
315 
OpenMS::FeatureFinderAlgorithmPickedHelperStructs::IsotopePattern
Helper structure for a found isotope pattern used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:193
OpenMS::FeatureFinderAlgorithmPickedHelperStructs::TheoreticalIsotopePattern
Helper structure for a theoretical isotope pattern used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:173
OpenMS::FeatureFinderDefs
The purpose of this struct is to provide definitions of classes and typedefs which are used throughou...
Definition: FeatureFinderDefs.h:50
OpenMS::FeatureFinderAlgorithmPicked::MapType
FeatureFinderAlgorithm::MapType MapType
Definition: FeatureFinderAlgorithmPicked.h:65
TraceFitter.h
OpenMS::FeatureFinderAlgorithmPicked::isotope_distributions_
std::vector< TheoreticalIsotopePattern > isotope_distributions_
Vector of precalculated isotope distributions for several mass windows.
Definition: FeatureFinderAlgorithmPicked.h:142
OpenMS::FeatureFinderAlgorithmPicked::intensity_thresholds_
std::vector< std::vector< std::vector< double > > > intensity_thresholds_
Precalculated intensity 20-quantiles (binned)
Definition: FeatureFinderAlgorithmPicked.h:138
OpenMS::FeatureFinderAlgorithmPicked::min_trace_score_
double min_trace_score_
Minimum quality of a traces.
Definition: FeatureFinderAlgorithmPicked.h:124
OpenMS::FeatureFinderAlgorithm::ff_
FeatureFinder * ff_
Pointer to the calling FeatureFinder that is used to access the feature flags.
Definition: FeatureFinderAlgorithm.h:145
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::FeatureFinderAlgorithmPicked::aborts_
std::map< String, UInt > aborts_
Array of abort reasons.
Definition: FeatureFinderAlgorithmPicked.h:105
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::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::FeatureFinderAlgorithmPicked::intensity_bins_
UInt intensity_bins_
Number of bins (in RT and MZ) for intensity significance estimation.
Definition: FeatureFinderAlgorithmPicked.h:122
FeatureFinderAlgorithmPickedHelperStructs.h
OpenMS::FeatureFinderAlgorithmPicked::Seed
FeatureFinderAlgorithmPickedHelperStructs::Seed Seed
Definition: FeatureFinderAlgorithmPicked.h:77
OpenMS::FeatureFinderAlgorithmPicked::pattern_tolerance_
double pattern_tolerance_
Stores mass_trace:mz_tolerance.
Definition: FeatureFinderAlgorithmPicked.h:113
OpenMS::FeatureFinderAlgorithmPicked::FloatDataArrays
SpectrumType::FloatDataArrays FloatDataArrays
Definition: FeatureFinderAlgorithmPicked.h:67
OpenMS::FeatureFinderAlgorithmPicked::optional_fit_improvement_
double optional_fit_improvement_
Minimal improvement for leaving out optional isotope.
Definition: FeatureFinderAlgorithmPicked.h:120
OpenMS::FeatureFinderAlgorithmPicked::min_spectra_
UInt min_spectra_
Number of spectra that have to show the same mass (for finding a mass trace)
Definition: FeatureFinderAlgorithmPicked.h:115
OpenMS::FeatureFinderAlgorithmPicked::mass_window_width_
double mass_window_width_
Width of the isotope pattern mass bins.
Definition: FeatureFinderAlgorithmPicked.h:121
OpenMS::FeatureFinderAlgorithmPicked::debug_
bool debug_
debug flag
Definition: FeatureFinderAlgorithmPicked.h:103
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::FeatureFinderAlgorithmPicked::slope_bound_
double slope_bound_
Max slope of mass trace intensities.
Definition: FeatureFinderAlgorithmPicked.h:117
OpenMS::FeatureFinderAlgorithmPicked::intensity_percentage_
double intensity_percentage_
Isotope pattern intensity contribution of required peaks.
Definition: FeatureFinderAlgorithmPicked.h:118
OpenMS::FeatureFinderAlgorithmPicked::trace_tolerance_
double trace_tolerance_
Stores isotopic_pattern:mz_tolerance.
Definition: FeatureFinderAlgorithmPicked.h:114
OpenMS::FeatureFinderAlgorithmPicked::min_rt_span_
double min_rt_span_
Minimum RT range that has to be left after the fit.
Definition: FeatureFinderAlgorithmPicked.h:125
OpenMS::FeatureFinderAlgorithmPicked::SpectrumType
MapType::SpectrumType SpectrumType
Definition: FeatureFinderAlgorithmPicked.h:66
OpenMS::FeatureFinderAlgorithmPicked::PeakType
Peak1D PeakType
Definition: FeatureFinderAlgorithmPicked.h:76
OpenMS::FeatureFinderAlgorithmPicked::abort_reasons_
std::map< Seed, String > abort_reasons_
Array of abort reasons.
Definition: FeatureFinderAlgorithmPicked.h:107
OpenMS::FeatureFinderAlgorithmPicked::log_
std::ofstream log_
Output stream for log/debug info.
Definition: FeatureFinderAlgorithmPicked.h:101
OpenMS::FeatureFinderAlgorithmPicked::MassTraces
FeatureFinderAlgorithmPickedHelperStructs::MassTraces MassTraces
Definition: FeatureFinderAlgorithmPicked.h:79
OpenMS::FeatureFinderAlgorithmPicked::max_feature_intersection_
double max_feature_intersection_
Maximum allowed feature intersection (if larger, that one of the feature is removed)
Definition: FeatureFinderAlgorithmPicked.h:127
OpenMS::FeatureFinderAlgorithmPicked::TheoreticalIsotopePattern
FeatureFinderAlgorithmPickedHelperStructs::TheoreticalIsotopePattern TheoreticalIsotopePattern
Definition: FeatureFinderAlgorithmPicked.h:80
OpenMS::Peak1D
A 1-dimensional raw data point or peak.
Definition: Peak1D.h:53
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::FeatureFinderAlgorithmPicked
FeatureFinderAlgorithm for picked peaks.
Definition: FeatureFinderAlgorithmPicked.h:58
OpenMS::FeatureFinderAlgorithm
Abstract base class for FeatureFinder algorithms.
Definition: FeatureFinderAlgorithm.h:74
OpenMS::MSSpectrum::FloatDataArrays
std::vector< FloatDataArray > FloatDataArrays
Definition: MSSpectrum.h:116
OpenMS::FeatureFinderAlgorithmPicked::min_isotope_fit_
double min_isotope_fit_
Minimum isotope pattern fit for a feature.
Definition: FeatureFinderAlgorithmPicked.h:123
OpenMS::SignedSize
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition: Types.h:134
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:98
OpenMS::Feature
An LC-MS feature.
Definition: Feature.h:70
OpenMS::FeatureFinderAlgorithmPicked::max_rt_span_
double max_rt_span_
Maximum RT range the model is allowed to span.
Definition: FeatureFinderAlgorithmPicked.h:126
OpenMS::FeatureFinderAlgorithmPicked::seeds_
FeatureMap seeds_
User-specified seed list.
Definition: FeatureFinderAlgorithmPicked.h:109
OpenMS::FeatureFinderAlgorithmPicked::MassTrace
FeatureFinderAlgorithmPickedHelperStructs::MassTrace MassTrace
Definition: FeatureFinderAlgorithmPicked.h:78
OpenMS::FeatureFinderAlgorithmPickedHelperStructs::Seed
Helper structure for seeds used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:62
OpenMS::DefaultParamHandler::defaults_
Param defaults_
Container for default parameters. This member should be filled in the constructor of derived classes!
Definition: DefaultParamHandler.h:173
OpenMS::FeatureFinderAlgorithmPicked::intensity_mz_step_
double intensity_mz_step_
m/z bin width
Definition: FeatureFinderAlgorithmPicked.h:136
OpenMS::FeatureFinderAlgorithmPicked::intensity_percentage_optional_
double intensity_percentage_optional_
Isotope pattern intensity contribution of optional peaks.
Definition: FeatureFinderAlgorithmPicked.h:119
OpenMS::FeatureFinderAlgorithmPicked::IsotopePattern
FeatureFinderAlgorithmPickedHelperStructs::IsotopePattern IsotopePattern
Definition: FeatureFinderAlgorithmPicked.h:81
OpenMS::FeatureFinderAlgorithm::features_
FeatureMap * features_
Output data pointer.
Definition: FeatureFinderAlgorithm.h:142
OpenMS::FeatureFinderAlgorithmPickedHelperStructs::MassTraces
Helper struct for a collection of mass traces used in FeatureFinderAlgorithmPicked.
Definition: FeatureFinderAlgorithmPickedHelperStructs.h:109
OpenMS::FeatureFinderAlgorithmPicked::map_
MapType map_
editable copy of the map
Definition: FeatureFinderAlgorithmPicked.h:99
OpenMS::MSSpectrum
The representation of a 1D spectrum.
Definition: MSSpectrum.h:66
OpenMS::FeatureFinderAlgorithmPicked::reported_mz_
String reported_mz_
The mass type that is reported for features. 'maximum' returns the m/z value of the highest mass trac...
Definition: FeatureFinderAlgorithmPicked.h:128
OpenMS::FeatureFinderAlgorithmPicked::max_missing_trace_peaks_
UInt max_missing_trace_peaks_
Stores mass_trace:max_missing.
Definition: FeatureFinderAlgorithmPicked.h:116
FeatureFinderAlgorithm.h
OpenMS::DefaultParamHandler::param_
Param param_
Container for current parameters.
Definition: DefaultParamHandler.h:166