OpenMS
Loading...
Searching...
No Matches
OpenSwathWorkflow.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Hannes Roest $
6// $Authors: Hannes Roest $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11// Interfaces
16
17#include <OpenMS/FORMAT/FileHandler.h> // debug file store only
18
19// Kernel and implementations
25
26// Helpers
28// #include <OpenMS/ANALYSIS/OPENSWATH/DATAACCESS/DataAccessHelper.h>
31
32// Algorithms
39
40#include <cassert>
41#include <limits>
42
43// #define OPENSWATH_WORKFLOW_DEBUG
44
45// The workflow class
46namespace OpenMS
47{
48
72
73 class OPENMS_DLLAPI OpenSwathWorkflowBase :
74 public ProgressLogger
75 {
76
77protected:
78
85 use_ms1_traces_(false),
86 use_ms1_ion_mobility_(false),
87 prm_(false),
88 pasef_(false),
89 threads_outer_loop_(-1)
90 {
91 }
92
108 OpenSwathWorkflowBase(bool use_ms1_traces, bool use_ms1_ion_mobility, bool prm, bool pasef, int threads_outer_loop) :
109 use_ms1_traces_(use_ms1_traces),
110 use_ms1_ion_mobility_(use_ms1_ion_mobility),
111 prm_(prm),
112 pasef_(pasef),
113 threads_outer_loop_(threads_outer_loop)
114 {
115 }
116
130 const std::vector<OpenSwath::SwathMap>& swath_maps,
131 std::vector<MSChromatogram>& ms1_chromatograms,
132 const ChromExtractParams& cp,
133 const OpenSwath::LightTargetedExperiment& transition_exp,
134 const TransformationDescription& trafo_inverse,
135 bool ms1_only = false,
136 int ms1_isotopes = 0);
137
156 void prepareExtractionCoordinates_(std::vector< OpenSwath::ChromatogramPtr > & chrom_list,
157 std::vector< ChromatogramExtractorAlgorithm::ExtractionCoordinates > & coordinates,
158 const OpenSwath::LightTargetedExperiment & transition_exp_used,
159 const TransformationDescription& trafo_inverse,
160 const ChromExtractParams & cp,
161 const bool ms1 = false,
162 const int ms1_isotopes = -1) const;
163
164
173
176
179
188 bool prm_;
189
198 bool pasef_;
199
210
211};
212
229 class OPENMS_DLLAPI OpenSwathCalibrationWorkflow :
231 {
232 public:
233
238
239 explicit OpenSwathCalibrationWorkflow(bool use_ms1_traces) :
240 OpenSwathWorkflowBase(use_ms1_traces, false, false, false, -1)
241 {
242 }
243
270 std::vector< OpenSwath::SwathMap > & swath_maps,
272 double min_rsq,
273 double min_coverage,
274 const Param & feature_finder_param,
275 const ChromExtractParams & cp_irt,
276 const Param& irt_detection_param,
277 const Param& calibration_param,
278 const String& irt_mzml_out,
279 Size debug_level,
280 bool pasef = false,
281 bool load_into_memory = false);
282
283 public:
284
318 const std::vector< OpenMS::MSChromatogram >& chromatograms,
320 std::vector< OpenSwath::SwathMap > & swath_maps,
321 double min_rsq,
322 double min_coverage,
323 const Param& default_ffparam,
324 const Param& irt_detection_param,
325 const Param& calibration_param,
326 const bool pasef);
327
339 void simpleExtractChromatograms_(const std::vector< OpenSwath::SwathMap > & swath_maps,
340 const OpenSwath::LightTargetedExperiment & irt_transitions,
341 std::vector< OpenMS::MSChromatogram > & chromatograms,
342 const TransformationDescription& trafo,
343 const ChromExtractParams & cp,
344 bool pasef,
345 bool load_into_memory);
346
353 static void addChromatograms(MSChromatogram& base_chrom, const MSChromatogram& newchrom);
354
356 double getEstimatedMzWindow() const;
357
359 void setEstimatedMzWindow(double estimatedMzWindow);
360
362 double getEstimatedImWindow() const;
363
365 void setEstimatedImWindow(double estimatedImWindow);
366
369
371 void setEstimatedMs1MzWindow(double estimatedMs1MzWindow);
372
375
377 void setEstimatedMs1ImWindow(double estimatedMs1ImWindow);
378
379 protected:
381 double estimated_mz_window_ = -1;
382 double estimated_im_window_ = -1;
383 double estimated_ms1_mz_window_ = -1;
384 double estimated_ms1_im_window_ = -1;
385 };
386
415 class OPENMS_DLLAPI OpenSwathWorkflow :
417 {
420
421 public:
422
438 OpenSwathWorkflow(bool use_ms1_traces, bool use_ms1_ion_mobility, bool prm, bool pasef, int threads_outer_loop) :
439 OpenSwathWorkflowBase(use_ms1_traces, use_ms1_ion_mobility, prm, pasef, threads_outer_loop)
440 {
441 }
442
467 void performExtraction(const std::vector<OpenSwath::SwathMap>& swath_maps,
468 const TransformationDescription& rt_trafo,
469 const ChromExtractParams & chromatogram_extraction_params,
470 const ChromExtractParams & ms1_chromatogram_extraction_params,
471 const Param & feature_finder_param,
472 const OpenSwath::LightTargetedExperiment& assay_library,
473 FeatureMap& result_featureFile,
474 bool store_features_in_featureFile,
475 OpenSwathOSWWriter & result_osw,
476 Interfaces::IMSDataConsumer * result_chromatograms,
477 int batchSize,
478 int ms1_isotopes,
479 bool load_into_memory);
480
481 protected:
482
483
499 void writeOutFeaturesAndChroms_(std::vector< OpenMS::MSChromatogram > & chromatograms,
500 std::vector< MSChromatogram >& ms1_chromatograms,
501 const FeatureMap & featureFile,
502 FeatureMap& out_featureFile,
503 bool store_features,
504 Interfaces::IMSDataConsumer * chromConsumer);
505
543 const std::vector<OpenMS::MSChromatogram>& ms2_chromatograms,
544 const std::vector<OpenMS::MSChromatogram>& ms1_chromatograms,
545 const std::vector<OpenSwath::SwathMap>& swath_maps,
546 const OpenSwath::LightTargetedExperiment& transition_exp,
547 const Param& feature_finder_param,
548 const TransformationDescription& trafo,
549 const double rt_extraction_window,
550 FeatureMap& output,
551 OpenSwathOSWWriter& osw_writer,
552 int nr_ms1_isotopes = 0,
553 bool ms1only = false) const;
554
571 OpenSwath::LightTargetedExperiment& transition_exp_used, int batch_size, size_t batch_idx);
572
583 void copyBatchTransitions_(const std::vector<OpenSwath::LightCompound>& used_compounds,
584 const std::vector<OpenSwath::LightTransition>& all_transitions,
585 std::vector<OpenSwath::LightTransition>& output);
586 };
587}
588
589
A container for features.
Definition FeatureMap.h:82
The interface of a consumer of spectra and chromatograms.
Definition IMSDataConsumer.h:46
The representation of a group of transitions in a targeted proteomics experiment.
Definition MRMTransitionGroup.h:42
The representation of a chromatogram.
Definition MSChromatogram.h:30
Execute all steps for retention time and m/z calibration of SWATH-MS data.
Definition OpenSwathWorkflow.h:231
OpenSwathCalibrationWorkflow()
Definition OpenSwathWorkflow.h:234
TransformationDescription performRTNormalization(const OpenSwath::LightTargetedExperiment &irt_transitions, std::vector< OpenSwath::SwathMap > &swath_maps, TransformationDescription &im_trafo, double min_rsq, double min_coverage, const Param &feature_finder_param, const ChromExtractParams &cp_irt, const Param &irt_detection_param, const Param &calibration_param, const String &irt_mzml_out, Size debug_level, bool pasef=false, bool load_into_memory=false)
Perform RT and m/z correction of the input data using RT-normalization peptides.
double getEstimatedImWindow() const
Retrieve the estimated fragment ion mobility.
double getEstimatedMzWindow() const
Retrieve the estimated fragment m/z window (ppm)
void setEstimatedMzWindow(double estimatedMzWindow)
Set the estimated fragment m/z window (ppm)
static void addChromatograms(MSChromatogram &base_chrom, const MSChromatogram &newchrom)
Add two chromatograms.
OpenSwathCalibrationWorkflow(bool use_ms1_traces)
Definition OpenSwathWorkflow.h:239
void simpleExtractChromatograms_(const std::vector< OpenSwath::SwathMap > &swath_maps, const OpenSwath::LightTargetedExperiment &irt_transitions, std::vector< OpenMS::MSChromatogram > &chromatograms, const TransformationDescription &trafo, const ChromExtractParams &cp, bool pasef, bool load_into_memory)
Simple method to extract chromatograms (for the RT-normalization peptides)
TransformationDescription doDataNormalization_(const OpenSwath::LightTargetedExperiment &transition_exp_, const std::vector< OpenMS::MSChromatogram > &chromatograms, TransformationDescription &im_trafo, std::vector< OpenSwath::SwathMap > &swath_maps, double min_rsq, double min_coverage, const Param &default_ffparam, const Param &irt_detection_param, const Param &calibration_param, const bool pasef)
Perform retention time and m/z calibration.
double getEstimatedMs1MzWindow() const
Retrieve the estimated MS1 m/z window (ppm)
void setEstimatedImWindow(double estimatedImWindow)
Set the estimated fragment ion mobility.
void setEstimatedMs1MzWindow(double estimatedMs1MzWindow)
Set the estimated MS1 m/z window (ppm)
void setEstimatedMs1ImWindow(double estimatedMs1ImWindow)
Set the estimated MS1 ion mobility window.
double getEstimatedMs1ImWindow() const
Retrieve the estimated MS1 ion mobility window.
Class to write out an OpenSwath OSW SQLite output (PyProphet input).
Definition OpenSwathOSWWriter.h:90
Definition OpenSwathWorkflow.h:75
void MS1Extraction_(const OpenSwath::SpectrumAccessPtr &ms1_map, const std::vector< OpenSwath::SwathMap > &swath_maps, std::vector< MSChromatogram > &ms1_chromatograms, const ChromExtractParams &cp, const OpenSwath::LightTargetedExperiment &transition_exp, const TransformationDescription &trafo_inverse, bool ms1_only=false, int ms1_isotopes=0)
Perform MS1 extraction and store result in ms1_chromatograms.
bool prm_
Whether data is acquired in targeted DIA (e.g. PRM mode) with potentially overlapping windows.
Definition OpenSwathWorkflow.h:188
bool use_ms1_traces_
Whether to use the MS1 traces.
Definition OpenSwathWorkflow.h:175
int threads_outer_loop_
How many threads should be used for the outer loop.
Definition OpenSwathWorkflow.h:209
OpenSwathWorkflowBase()
Default constructor.
Definition OpenSwathWorkflow.h:84
bool use_ms1_ion_mobility_
Whether to use ion mobility extraction on MS1 traces.
Definition OpenSwathWorkflow.h:178
OpenSwathWorkflowBase(bool use_ms1_traces, bool use_ms1_ion_mobility, bool prm, bool pasef, int threads_outer_loop)
Constructor.
Definition OpenSwathWorkflow.h:108
void prepareExtractionCoordinates_(std::vector< OpenSwath::ChromatogramPtr > &chrom_list, std::vector< ChromatogramExtractorAlgorithm::ExtractionCoordinates > &coordinates, const OpenSwath::LightTargetedExperiment &transition_exp_used, const TransformationDescription &trafo_inverse, const ChromExtractParams &cp, const bool ms1=false, const int ms1_isotopes=-1) const
Function to prepare extraction coordinates that also correctly handles RT transformations.
bool pasef_
Whether data is diaPASEF data.
Definition OpenSwathWorkflow.h:198
Execute all steps in an OpenSwath analysis.
Definition OpenSwathWorkflow.h:417
MRMTransitionGroup< MSChromatogram, TransitionType > MRMTransitionGroupType
Definition OpenSwathWorkflow.h:419
OpenSwathWorkflow(bool use_ms1_traces, bool use_ms1_ion_mobility, bool prm, bool pasef, int threads_outer_loop)
Constructor.
Definition OpenSwathWorkflow.h:438
void writeOutFeaturesAndChroms_(std::vector< OpenMS::MSChromatogram > &chromatograms, std::vector< MSChromatogram > &ms1_chromatograms, const FeatureMap &featureFile, FeatureMap &out_featureFile, bool store_features, Interfaces::IMSDataConsumer *chromConsumer)
Write output features and chromatograms.
void selectCompoundsForBatch_(const OpenSwath::LightTargetedExperiment &transition_exp_used_all, OpenSwath::LightTargetedExperiment &transition_exp_used, int batch_size, size_t batch_idx)
Select which compounds to analyze in the next batch (and copy to output)
OpenSwath::LightTransition TransitionType
Definition OpenSwathWorkflow.h:418
void scoreAllChromatograms_(const std::vector< OpenMS::MSChromatogram > &ms2_chromatograms, const std::vector< OpenMS::MSChromatogram > &ms1_chromatograms, const std::vector< OpenSwath::SwathMap > &swath_maps, const OpenSwath::LightTargetedExperiment &transition_exp, const Param &feature_finder_param, const TransformationDescription &trafo, const double rt_extraction_window, FeatureMap &output, OpenSwathOSWWriter &osw_writer, int nr_ms1_isotopes=0, bool ms1only=false) const
Perform scoring on a set of chromatograms.
void performExtraction(const std::vector< OpenSwath::SwathMap > &swath_maps, const TransformationDescription &rt_trafo, const ChromExtractParams &chromatogram_extraction_params, const ChromExtractParams &ms1_chromatogram_extraction_params, const Param &feature_finder_param, const OpenSwath::LightTargetedExperiment &assay_library, FeatureMap &result_featureFile, bool store_features_in_featureFile, OpenSwathOSWWriter &result_osw, Interfaces::IMSDataConsumer *result_chromatograms, int batchSize, int ms1_isotopes, bool load_into_memory)
Execute OpenSWATH analysis on a set of SwathMaps and transitions.
void copyBatchTransitions_(const std::vector< OpenSwath::LightCompound > &used_compounds, const std::vector< OpenSwath::LightTransition > &all_transitions, std::vector< OpenSwath::LightTransition > &output)
Helper function for selectCompoundsForBatch_()
Management and storage of parameters / INI files.
Definition Param.h:46
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:27
A more convenient string class.
Definition String.h:34
Generic description of a coordinate transformation.
Definition TransformationDescription.h:37
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
double im_extraction_window
Extraction window in ion mobility.
Definition OpenSwathWorkflow.h:62
bool ppm
Whether the extraction window is given in ppm or Da.
Definition OpenSwathWorkflow.h:64
String extraction_function
The extraction function in mass space.
Definition OpenSwathWorkflow.h:66
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:70
double min_upper_edge_dist
Whether to not extract anything closer than this (in Da) from the upper edge.
Definition OpenSwathWorkflow.h:58
double mz_extraction_window
Extraction window in Da or ppm (e.g. 50ppm means extraction +/- 25ppm)
Definition OpenSwathWorkflow.h:60
double rt_extraction_window
The retention time extraction window.
Definition OpenSwathWorkflow.h:68
ChromatogramExtractor parameters.
Definition OpenSwathWorkflow.h:56
std::shared_ptr< ISpectrumAccess > SpectrumAccessPtr
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:131
Definition TransitionExperiment.h:356
Definition TransitionExperiment.h:105