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
12
17
18// Kernel and implementations
24
25// Helpers
27// #include <OpenMS/ANALYSIS/OPENSWATH/DATAACCESS/DataAccessHelper.h>
30
31// Algorithms
38#include <cassert>
39#include <limits>
40
41// #define OPENSWATH_WORKFLOW_DEBUG
42
43// The workflow class
44namespace OpenMS
45{
46
70
71 class OPENMS_DLLAPI OpenSwathWorkflowBase :
72 public ProgressLogger
73 {
74
75protected:
76
83 use_ms1_traces_(false),
84 use_ms1_ion_mobility_(false),
85 prm_(false),
86 pasef_(false),
87 mrm_(false),
88 threads_outer_loop_(-1)
89 {
90 }
91
112 OpenSwathWorkflowBase(bool use_ms1_traces, bool use_ms1_ion_mobility, bool prm, bool pasef, bool mrm, int threads_outer_loop) :
113 use_ms1_traces_(use_ms1_traces),
114 use_ms1_ion_mobility_(use_ms1_ion_mobility),
115 prm_(prm),
116 pasef_(pasef),
117 mrm_(mrm),
118 threads_outer_loop_(threads_outer_loop)
119 {
120 }
121
135 const std::vector<OpenSwath::SwathMap>& swath_maps,
136 std::vector<MSChromatogram>& ms1_chromatograms,
137 const ChromExtractParams& cp,
138 const OpenSwath::LightTargetedExperiment& transition_exp,
139 const TransformationDescription& trafo_inverse,
140 bool ms1_only = false,
141 int ms1_isotopes = 0);
142
161 void prepareExtractionCoordinates_(std::vector< OpenSwath::ChromatogramPtr > & chrom_list,
162 std::vector< ChromatogramExtractorAlgorithm::ExtractionCoordinates > & coordinates,
163 const OpenSwath::LightTargetedExperiment & transition_exp_used,
164 const TransformationDescription& trafo_inverse,
165 const ChromExtractParams & cp,
166 const bool ms1 = false,
167 const int ms1_isotopes = -1) const;
168
169
178
181
184
193 bool prm_;
194
203 bool pasef_;
204
210 bool mrm_;
211
225
226};
227
256 class OPENMS_DLLAPI OpenSwathWorkflow :
258 {
261
262 public:
263
280 OpenSwathWorkflow(bool use_ms1_traces, bool use_ms1_ion_mobility, bool prm, bool pasef, bool mrm, int threads_outer_loop) :
281 OpenSwathWorkflowBase(use_ms1_traces, use_ms1_ion_mobility, prm, pasef, mrm, threads_outer_loop)
282 {
283 }
284
296 OpenSwath::SpectrumAccessPtr loadMS1Map(const std::vector<OpenSwath::SwathMap>& swath_maps, bool load_into_memory);
297
333 void performExtraction(const std::vector<OpenSwath::SwathMap>& swath_maps,
334 const TransformationDescription& rt_trafo,
335 const ChromExtractParams & chromatogram_extraction_params,
336 const ChromExtractParams & ms1_chromatogram_extraction_params,
337 const Param & feature_finder_param,
338 const OpenSwath::LightTargetedExperiment& assay_library,
339 FeatureMap& result_featureFile,
340 bool store_features_in_featureFile,
341 OpenSwathOSWWriter & result_osw,
342 Interfaces::IMSDataConsumer * result_chromatograms,
343 int batchSize,
344 int ms1_isotopes,
345 bool load_into_memory,
346 const Param & mrm_mapping_param = Param(),
347 class MobilogramParquetConsumer * mobilogram_consumer = nullptr,
348 int innerBatchSize = -1,
349 int maxConcurrentSwaths = -1);
350
351 protected:
352
353
369 void writeOutFeaturesAndChroms_(std::vector< OpenMS::MSChromatogram > & chromatograms,
370 std::vector< MSChromatogram >& ms1_chromatograms,
371 const FeatureMap & featureFile,
372 FeatureMap& out_featureFile,
373 bool store_features,
374 Interfaces::IMSDataConsumer * chromConsumer);
375
415 const std::vector<OpenMS::MSChromatogram>& ms2_chromatograms,
416 const std::vector<OpenMS::MSChromatogram>& ms1_chromatograms,
417 const std::vector<OpenSwath::SwathMap>& swath_maps,
418 const OpenSwath::LightTargetedExperiment& transition_exp,
419 const Param& feature_finder_param,
420 const TransformationDescription& trafo,
421 const double rt_extraction_window,
422 FeatureMap& output,
423 OpenSwathOSWWriter& osw_writer,
424 int nr_ms1_isotopes = 0,
425 bool ms1only = false,
426 class MobilogramParquetConsumer * mobilogram_consumer = nullptr,
427 OpenSwathOSWWriter::OSWData* deferred_osw_output = nullptr) const;
428
445 OpenSwath::LightTargetedExperiment& transition_exp_used, int batch_size, size_t batch_idx);
446
457 void copyBatchTransitions_(const std::vector<OpenSwath::LightCompound>& used_compounds,
458 const std::vector<OpenSwath::LightTransition>& all_transitions,
459 std::vector<OpenSwath::LightTransition>& output);
460 };
461}
A container for features.
Definition FeatureMap.h:78
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
Writes Mobilograms (ion-mobility traces) to a Parquet file using a PyProphet-compatible-like schema.
Definition MobilogramParquetConsumer.h:25
Class to write out an OpenSwath OSW SQLite output (PyProphet input).
Definition OpenSwathOSWWriter.h:97
Definition OpenSwathWorkflow.h:73
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:193
bool use_ms1_traces_
Whether to use the MS1 traces.
Definition OpenSwathWorkflow.h:180
int threads_outer_loop_
How many threads should be used for the outer loop.
Definition OpenSwathWorkflow.h:224
OpenSwathWorkflowBase(bool use_ms1_traces, bool use_ms1_ion_mobility, bool prm, bool pasef, bool mrm, int threads_outer_loop)
Constructor.
Definition OpenSwathWorkflow.h:112
OpenSwathWorkflowBase()
Default constructor.
Definition OpenSwathWorkflow.h:82
bool use_ms1_ion_mobility_
Whether to use ion mobility extraction on MS1 traces.
Definition OpenSwathWorkflow.h:183
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 mrm_
Whether data is chromatogram-only SRM/MRM data.
Definition OpenSwathWorkflow.h:210
bool pasef_
Whether data is diaPASEF data.
Definition OpenSwathWorkflow.h:203
Execute all steps in an OpenSwath analysis.
Definition OpenSwathWorkflow.h:258
MRMTransitionGroup< MSChromatogram, TransitionType > MRMTransitionGroupType
Definition OpenSwathWorkflow.h:260
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, class MobilogramParquetConsumer *mobilogram_consumer=nullptr, OpenSwathOSWWriter::OSWData *deferred_osw_output=nullptr) 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, const Param &mrm_mapping_param=Param(), class MobilogramParquetConsumer *mobilogram_consumer=nullptr, int innerBatchSize=-1, int maxConcurrentSwaths=-1)
Execute OpenSWATH analysis on a set of SwathMaps and transitions.
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:259
OpenSwath::SpectrumAccessPtr loadMS1Map(const std::vector< OpenSwath::SwathMap > &swath_maps, bool load_into_memory)
Load MS1 SpectrumAccessPtr from given swath maps.
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_()
OpenSwathWorkflow(bool use_ms1_traces, bool use_ms1_ion_mobility, bool prm, bool pasef, bool mrm, int threads_outer_loop)
Constructor.
Definition OpenSwathWorkflow.h:280
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
Generic description of a coordinate transformation.
Definition TransformationDescription.h:38
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
double im_extraction_window
Extraction window in ion mobility.
Definition OpenSwathWorkflow.h:60
bool ppm
Whether the extraction window is given in ppm or Da.
Definition OpenSwathWorkflow.h:62
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:68
double min_upper_edge_dist
Whether to not extract anything closer than this (in Da) from the upper edge.
Definition OpenSwathWorkflow.h:56
double mz_extraction_window
Extraction window in Da or ppm (e.g. 50ppm means extraction +/- 25ppm)
Definition OpenSwathWorkflow.h:58
std::string extraction_function
The extraction function in mass space.
Definition OpenSwathWorkflow.h:64
double rt_extraction_window
The retention time extraction window.
Definition OpenSwathWorkflow.h:66
ChromatogramExtractor parameters.
Definition OpenSwathWorkflow.h:54
std::shared_ptr< ISpectrumAccess > SpectrumAccessPtr
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:131
Buffered OSW table rows ready for insertion through prepared statements.
Definition OpenSwathOSWWriter.h:183
Definition TransitionExperiment.h:369
Definition TransitionExperiment.h:106