OpenMS  2.4.0
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-2018.
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 
100  class OPENMS_DLLAPI OpenSwathWorkflowBase :
101  public ProgressLogger
102  {
103 
104 protected:
105 
106  explicit OpenSwathWorkflowBase(bool use_ms1_traces) :
107  use_ms1_traces_(use_ms1_traces)
108  {
109  }
110 
114  void MS1Extraction_(const std::vector< OpenSwath::SwathMap > & swath_maps,
115  std::map< std::string, OpenSwath::ChromatogramPtr >& ms1_chromatograms,
116  Interfaces::IMSDataConsumer * chromConsumer,
117  const ChromExtractParams & cp,
118  const OpenSwath::LightTargetedExperiment& transition_exp,
119  const TransformationDescription& trafo_inverse,
120  bool load_into_memory,
121  bool ms1only = false);
122 
140  void prepareExtractionCoordinates_(std::vector< OpenSwath::ChromatogramPtr > & chrom_list,
141  std::vector< ChromatogramExtractorAlgorithm::ExtractionCoordinates > & coordinates,
142  const OpenSwath::LightTargetedExperiment & transition_exp_used,
143  const bool ms1, const TransformationDescription trafo_inverse,
144  const ChromExtractParams & cp) const;
145 
146 
155 
158 
159 
160  };
161 
166  public OpenSwathWorkflowBase
167  {
168  public:
169 
171  OpenSwathWorkflowBase(false)
172  {
173  }
174 
175  explicit OpenSwathRetentionTimeNormalization(bool use_ms1_traces) :
176  OpenSwathWorkflowBase(use_ms1_traces)
177  {
178  }
179 
200  TransformationDescription performRTNormalization(const OpenSwath::LightTargetedExperiment & irt_transitions,
201  std::vector< OpenSwath::SwathMap > & swath_maps,
202  double min_rsq,
203  double min_coverage,
204  const Param & feature_finder_param,
205  const ChromExtractParams & cp_irt,
206  const Param & irt_detection_param,
207  const String & mz_correction_function,
208  const String& irt_mzml_out,
209  Size debug_level,
210  bool sonar = false,
211  bool load_into_memory = false);
212 
213  public:
214 
230  TransformationDescription RTNormalization(const OpenSwath::LightTargetedExperiment& transition_exp_,
231  const std::vector< OpenMS::MSChromatogram >& chromatograms,
232  double min_rsq,
233  double min_coverage,
234  const Param& default_ffparam,
235  const Param& irt_detection_param,
236  std::vector< OpenSwath::SwathMap > & swath_maps,
237  const String & mz_correction_function,
238  double mz_extraction_window,
239  bool ppm);
240 
242  void simpleExtractChromatograms(const std::vector< OpenSwath::SwathMap > & swath_maps,
243  const OpenSwath::LightTargetedExperiment & irt_transitions,
244  std::vector< OpenMS::MSChromatogram > & chromatograms,
245  const TransformationDescription& trafo,
246  const ChromExtractParams & cp,
247  bool sonar,
248  bool load_into_memory);
249 
250  static void addChromatograms(MSChromatogram& base_chrom, const MSChromatogram& newchrom);
251  };
252 
261  class OPENMS_DLLAPI OpenSwathWorkflow :
262  public OpenSwathWorkflowBase
263  {
266 
267  public:
268 
269  explicit OpenSwathWorkflow(bool use_ms1_traces) :
270  OpenSwathWorkflowBase(use_ms1_traces)
271  {
272  }
273 
297  void performExtraction(const std::vector< OpenSwath::SwathMap > & swath_maps,
298  const TransformationDescription trafo,
299  const ChromExtractParams & cp,
300  const Param & feature_finder_param,
301  const OpenSwath::LightTargetedExperiment& transition_exp,
302  FeatureMap& out_featureFile,
303  bool store_features,
304  OpenSwathTSVWriter & tsv_writer,
305  OpenSwathOSWWriter & osw_writer,
306  Interfaces::IMSDataConsumer * chromConsumer,
307  int batchSize,
308  bool load_into_memory);
309 
310  protected:
311 
312 
316  void writeOutFeaturesAndChroms_(std::vector< OpenMS::MSChromatogram > & chromatograms,
317  const FeatureMap & featureFile,
318  FeatureMap& out_featureFile,
319  bool store_features,
320  Interfaces::IMSDataConsumer * chromConsumer);
321 
339  void scoreAllChromatograms(
340  const OpenSwath::SpectrumAccessPtr input,
341  const std::map< std::string, OpenSwath::ChromatogramPtr > & ms1_chromatograms,
342  const std::vector< OpenSwath::SwathMap >& swath_maps,
343  OpenSwath::LightTargetedExperiment& transition_exp,
344  const Param& feature_finder_param,
346  const double rt_extraction_window,
347  FeatureMap& output,
348  OpenSwathTSVWriter & tsv_writer,
349  OpenSwathOSWWriter & osw_writer,
350  bool ms1only = false);
351 
366  void selectCompoundsForBatch_(const OpenSwath::LightTargetedExperiment& transition_exp_used_all,
367  OpenSwath::LightTargetedExperiment& transition_exp_used, int batch_size, size_t j);
368 
379  void copyBatchTransitions_(const std::vector<OpenSwath::LightCompound>& used_compounds,
380  const std::vector<OpenSwath::LightTransition>& all_transitions,
381  std::vector<OpenSwath::LightTransition>& output);
382 
383  };
384 
394  class OPENMS_DLLAPI OpenSwathWorkflowSonar :
395  public OpenSwathWorkflow
396  {
397 
398  public:
399  explicit OpenSwathWorkflowSonar(bool use_ms1_traces) :
400  OpenSwathWorkflow(use_ms1_traces)
401  {}
402 
429  void performExtractionSonar(const std::vector< OpenSwath::SwathMap > & swath_maps,
430  const TransformationDescription trafo,
431  const ChromExtractParams & cp,
432  const Param & feature_finder_param,
433  const OpenSwath::LightTargetedExperiment& transition_exp,
434  FeatureMap& out_featureFile,
435  bool store_features,
436  OpenSwathTSVWriter & tsv_writer,
437  OpenSwathOSWWriter & osw_writer,
438  Interfaces::IMSDataConsumer * chromConsumer,
439  int batchSize,
440  bool load_into_memory);
441 
445  void computeSonarWindows_(const std::vector< OpenSwath::SwathMap > & swath_maps,
446  double & sonar_winsize,
447  double & sonar_start,
448  double & sonar_end,
449  int & sonar_total_win);
450 
454  void performSonarExtraction_(const std::vector< OpenSwath::SwathMap > & used_maps,
455  const std::vector< ChromatogramExtractor::ExtractionCoordinates > & coordinates,
456  std::vector< OpenSwath::ChromatogramPtr > & chrom_list,
457  const ChromExtractParams & cp);
458 
466  };
467 
468 }
469 
470 
OpenSwathRetentionTimeNormalization()
Definition: OpenSwathWorkflow.h:170
A more convenient string class.
Definition: String.h:57
OpenSwathWorkflow(bool use_ms1_traces)
Definition: OpenSwathWorkflow.h:269
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:399
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 ppm
Whether the extraction window is given in ppm or Da.
Definition: OpenSwathWorkflow.h:91
Definition: OpenSwathWorkflow.h:100
Class to write out an OpenSwath TSV output (mProphet input)
Definition: OpenSwathTSVWriter.h:56
MRMTransitionGroup< MSChromatogram, TransitionType > MRMTransitionGroupType
Definition: OpenSwathWorkflow.h:265
Class to execute an OpenSwath Workflow.
Definition: OpenSwathWorkflow.h:261
Class to execute an OpenSwath Workflow for SONAR data.
Definition: OpenSwathWorkflow.h:394
OpenSwath::LightTransition TransitionType
Definition: OpenSwathWorkflow.h:264
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
bool use_ms1_traces_
Whether to use the MS1 traces.
Definition: OpenSwathWorkflow.h:157
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
OpenSwathWorkflowBase(bool use_ms1_traces)
Definition: OpenSwathWorkflow.h:106
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
OpenSwathRetentionTimeNormalization(bool use_ms1_traces)
Definition: OpenSwathWorkflow.h:175
OpenSwath::SpectrumAccessPtr ms1_map_
Spectrum Access to the MS1 map (note that this is *not* threadsafe!)
Definition: OpenSwathWorkflow.h:154
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:165
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
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
Definition: TransitionExperiment.h:206