Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
OpenSwathWorkflow.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-2017.
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: Hannes Roest $
32 // $Authors: Hannes Roest $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // Interfaces
42 
43 #include <OpenMS/FORMAT/MzMLFile.h> // debug file store only
44 
45 // Kernel and implementations
51 
52 // Helpers
54 // #include <OpenMS/ANALYSIS/OPENSWATH/DATAACCESS/DataAccessHelper.h>
58 
59 // Algorithms
66 
67 #include <cassert>
68 #include <limits>
69 
70 // #define OPENSWATH_WORKFLOW_DEBUG
71 
72 // The workflow class
73 namespace OpenMS
74 {
75 
83  {
91  bool ppm;
98  };
99 
104  public ProgressLogger
105  {
106  public:
107 
128  TransformationDescription performRTNormalization(const OpenMS::TargetedExperiment & irt_transitions,
129  std::vector< OpenSwath::SwathMap > & swath_maps,
130  double min_rsq,
131  double min_coverage,
132  const Param & feature_finder_param,
133  const ChromExtractParams & cp_irt,
134  const Param & irt_detection_param,
135  const String & mz_correction_function,
136  const String& irt_mzml_out,
137  Size debug_level,
138  bool sonar = false,
139  bool load_into_memory = false);
140 
141  private:
142 
158  TransformationDescription RTNormalization(const TargetedExperiment& transition_exp_,
159  const std::vector< OpenMS::MSChromatogram >& chromatograms,
160  double min_rsq,
161  double min_coverage,
162  const Param& default_ffparam,
163  const Param& irt_detection_param,
164  std::vector< OpenSwath::SwathMap > & swath_maps,
165  const String & mz_correction_function,
166  double mz_extraction_window,
167  bool ppm);
168 
170  void simpleExtractChromatograms(const std::vector< OpenSwath::SwathMap > & swath_maps,
171  const OpenMS::TargetedExperiment & irt_transitions,
172  std::vector< OpenMS::MSChromatogram > & chromatograms,
173  const ChromExtractParams & cp, bool sonar, bool load_into_memory);
174 
175  static void addChromatograms(MSChromatogram& base_chrom, const MSChromatogram& newchrom);
176  };
177 
186  class OPENMS_DLLAPI OpenSwathWorkflow :
187  public ProgressLogger
188  {
191 
192  public:
193 
194  explicit OpenSwathWorkflow(bool use_ms1_traces) :
195  use_ms1_traces_(use_ms1_traces)
196  {
197  }
198 
222  void performExtraction(const std::vector< OpenSwath::SwathMap > & swath_maps,
223  const TransformationDescription trafo,
224  const ChromExtractParams & cp,
225  const Param & feature_finder_param,
226  const OpenSwath::LightTargetedExperiment& transition_exp,
227  FeatureMap& out_featureFile,
228  bool store_features,
229  OpenSwathTSVWriter & tsv_writer,
230  OpenSwathOSWWriter & osw_writer,
231  Interfaces::IMSDataConsumer * chromConsumer,
232  int batchSize,
233  bool load_into_memory);
234 
235  protected:
236 
237 
241  void writeOutFeaturesAndChroms_(std::vector< OpenMS::MSChromatogram > & chromatograms,
242  const FeatureMap & featureFile,
243  FeatureMap& out_featureFile,
244  bool store_features,
245  Interfaces::IMSDataConsumer * chromConsumer);
246 
250  void MS1Extraction_(const std::vector< OpenSwath::SwathMap > & swath_maps,
251  std::map< std::string, OpenSwath::ChromatogramPtr >& ms1_chromatograms,
252  Interfaces::IMSDataConsumer * chromConsumer,
253  const ChromExtractParams & cp,
254  const OpenSwath::LightTargetedExperiment& transition_exp,
255  const TransformationDescription& trafo_inverse,
256  bool load_into_memory,
257  bool ms1only = false);
258 
276  void scoreAllChromatograms(
277  const OpenSwath::SpectrumAccessPtr input,
278  const std::map< std::string, OpenSwath::ChromatogramPtr > & ms1_chromatograms,
279  const std::vector< OpenSwath::SwathMap >& swath_maps,
280  OpenSwath::LightTargetedExperiment& transition_exp,
281  const Param& feature_finder_param,
283  const double rt_extraction_window,
284  FeatureMap& output,
285  OpenSwathTSVWriter & tsv_writer,
286  OpenSwathOSWWriter & osw_writer,
287  bool ms1only = false);
288 
303  void selectCompoundsForBatch_(const OpenSwath::LightTargetedExperiment& transition_exp_used_all,
304  OpenSwath::LightTargetedExperiment& transition_exp_used, int batch_size, size_t j);
305 
316  void copyBatchTransitions_(const std::vector<OpenSwath::LightCompound>& used_compounds,
317  const std::vector<OpenSwath::LightTransition>& all_transitions,
318  std::vector<OpenSwath::LightTransition>& output);
319 
337  void prepareExtractionCoordinates_(std::vector< OpenSwath::ChromatogramPtr > & chrom_list,
338  std::vector< ChromatogramExtractorAlgorithm::ExtractionCoordinates > & coordinates,
339  const OpenSwath::LightTargetedExperiment & transition_exp_used,
340  const bool ms1, const TransformationDescription trafo_inverse,
341  const ChromExtractParams & cp) const;
342 
356  void prepare_coordinates_sub(std::vector< OpenSwath::ChromatogramPtr > & output_chromatograms,
357  std::vector< ChromatogramExtractorAlgorithm::ExtractionCoordinates > & coordinates,
358  const OpenSwath::LightTargetedExperiment & transition_exp_used,
359  const double rt_extraction_window, const bool ms1) const;
360 
369 
372 
373  };
374 
384  class OPENMS_DLLAPI OpenSwathWorkflowSonar :
385  public OpenSwathWorkflow
386  {
387 
388  public:
389  explicit OpenSwathWorkflowSonar(bool use_ms1_traces) :
390  OpenSwathWorkflow(use_ms1_traces)
391  {}
392 
419  void performExtractionSonar(const std::vector< OpenSwath::SwathMap > & swath_maps,
420  const TransformationDescription trafo,
421  const ChromExtractParams & cp,
422  const Param & feature_finder_param,
423  const OpenSwath::LightTargetedExperiment& transition_exp,
424  FeatureMap& out_featureFile,
425  bool store_features,
426  OpenSwathTSVWriter & tsv_writer,
427  OpenSwathOSWWriter & osw_writer,
428  Interfaces::IMSDataConsumer * chromConsumer,
429  int batchSize,
430  bool load_into_memory);
431 
435  void computeSonarWindows_(const std::vector< OpenSwath::SwathMap > & swath_maps,
436  double & sonar_winsize,
437  double & sonar_start,
438  double & sonar_end,
439  int & sonar_total_win);
440 
444  void performSonarExtraction_(const std::vector< OpenSwath::SwathMap > & used_maps,
445  const std::vector< ChromatogramExtractor::ExtractionCoordinates > & coordinates,
446  std::vector< OpenSwath::ChromatogramPtr > & chrom_list,
447  const ChromExtractParams & cp);
448 
456  };
457 
458 }
459 
460 
A more convenient string class.
Definition: String.h:57
OpenSwathWorkflow(bool use_ms1_traces)
Definition: OpenSwathWorkflow.h:194
double mz_extraction_window
Extraction window in Da or ppm (e.g. 50ppm means extraction +/- 25ppm)
Definition: OpenSwathWorkflow.h:87
ChromatogramExtractor parameters.
Definition: OpenSwathWorkflow.h:82
OpenSwathWorkflowSonar(bool use_ms1_traces)
Definition: OpenSwathWorkflow.h:389
boost::shared_ptr< ISpectrumAccess > SpectrumAccessPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:89
The representation of a chromatogram.
Definition: MSChromatogram.h:54
A container for features.
Definition: FeatureMap.h:93
bool use_ms1_traces_
Whether to use the MS1 traces.
Definition: OpenSwathWorkflow.h:371
bool ppm
Whether the extraction window is given in ppm or Da.
Definition: OpenSwathWorkflow.h:91
Class to write out an OpenSwath TSV output (mProphet input)
Definition: OpenSwathTSVWriter.h:56
MRMTransitionGroup< MSChromatogram, TransitionType > MRMTransitionGroupType
Definition: OpenSwathWorkflow.h:190
Class to execute an OpenSwath Workflow.
Definition: OpenSwathWorkflow.h:186
Class to execute an OpenSwath Workflow for SONAR data.
Definition: OpenSwathWorkflow.h:384
OpenSwath::LightTransition TransitionType
Definition: OpenSwathWorkflow.h:189
double im_extraction_window
Extraction window in ion mobility.
Definition: OpenSwathWorkflow.h:89
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
Class to write out an OpenSwath OSW SQLite output (PyProphet input)
Definition: OpenSwathOSWWriter.h:58
The representation of a group of transitions in a targeted proteomics experiment. ...
Definition: MRMTransitionGroup.h:67
double rt_extraction_window
The retention time extraction window.
Definition: OpenSwathWorkflow.h:95
double min_upper_edge_dist
Whether to not extract anything closer than this (in Da) from the upper edge.
Definition: OpenSwathWorkflow.h:85
boost::shared_ptr< Chromatogram > ChromatogramPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/DataStructures.h:170
String extraction_function
The extraction function in mass space.
Definition: OpenSwathWorkflow.h:93
Management and storage of parameters / INI files.
Definition: Param.h:74
Definition: TransitionExperiment.h:46
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Simple OpenSwathWorkflow to perform RT and m/z correction based on a set of known peptides...
Definition: OpenSwathWorkflow.h:103
The interface of a consumer of spectra and chromatograms.
Definition: IMSDataConsumer.h:67
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:54
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:61
Generic description of a coordinate transformation.
Definition: TransformationDescription.h:60
double extra_rt_extract
Whether to extract some extra in the retention time (can be useful if one wants to look at the chroma...
Definition: OpenSwathWorkflow.h:97
OpenSwath::SpectrumAccessPtr ms1_map_
Spectrum Access to the MS1 map (note that this is *not* threadsafe!)
Definition: OpenSwathWorkflow.h:368
Definition: TransitionExperiment.h:206

OpenMS / TOPP release 2.3.0 Documentation generated on Wed Apr 18 2018 19:29:07 using doxygen 1.8.14