OpenMS
Loading...
Searching...
No Matches
QPXDatasetExport.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: Timo Sachsenberg $
6// $Authors: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/config.h>
14
15#include <map>
16#include <memory>
17#include <optional>
18#include <string>
19#include <utility>
20#include <vector>
21
22namespace OpenMS
23{
24 class MSExperiment;
25 class MSSpectrum;
26 class Param;
27 class PeptideIdentificationList;
28
44class OPENMS_DLLAPI QPXDatasetExport
45{
46public:
49
60 static std::string scoreName(const std::string& name);
61
85 static std::vector<Column> psmColumns(const PeptideIdentificationList& peptide_ids,
86 const std::vector<bool>& has_spectrum,
87 bool isotope_observed_minus_theoretical);
88
94 {
96 double window = 100.0;
98 Size top = 100;
102 bool deisotoped = false;
104 int max_charge = 3;
106 bool cap_at_precursor = true;
107 };
108
128 static std::vector<Size> keptPeaks(const MSSpectrum& spectrum, const std::vector<PeptideHit::PeakAnnotation>& annotations,
129 int precursor_charge, const PeakFilter& filter);
130
133 struct MzView
134 {
136 std::shared_ptr<arrow::Table> table;
139 std::vector<bool> has_spectrum;
141 Size without_spectrum = 0;
144 Size unresolved = 0;
146 Size peaks_read = 0;
148 Size peaks_kept = 0;
149 };
150
177 static MzView mzView(const MSExperiment& spectra, const PeptideIdentificationList& peptide_ids,
178 const std::string& run_file_name, const PeakFilter& filter);
179
182 {
184 std::string accession;
186 std::string label = "LFQ";
188 std::optional<Int32> biological_replicate;
190 std::optional<Int32> technical_replicate;
191 };
192
194 struct Run
195 {
197 std::string accession;
199 std::string run_file_name;
201 std::string file_name;
203 std::vector<RunSample> samples;
205 std::optional<std::string> fraction;
207 std::optional<std::string> instrument;
209 std::optional<std::string> dissociation_method;
211 std::optional<std::string> acquisition_method;
213 std::vector<std::string> enzymes;
215 std::vector<std::string> fixed_modifications;
217 std::vector<std::string> variable_modifications;
218 };
219
221 struct Sample
222 {
224 std::string accession;
226 std::string organism = "not available";
228 std::string organism_part = "not available";
229 };
230
233 {
235 std::string category;
237 std::string name;
239 std::string tool;
241 std::vector<std::pair<std::string, std::string>> parameters;
243 std::string config;
245 std::vector<std::string> output_views;
246 };
247
262 static std::shared_ptr<arrow::Table> runView(const std::vector<Run>& runs);
263
272 static std::shared_ptr<arrow::Table> sampleView(const std::vector<Sample>& samples);
273
284 static std::shared_ptr<arrow::Table> provenanceView(const std::vector<ProvenanceStep>& steps);
285
296 static std::string paramToJSON(const Param& param);
297
306 static std::string formatNumber(double value, const std::string& non_finite = "null");
307
309 struct View
310 {
313 std::vector<std::shared_ptr<arrow::Table>> tables;
317 std::map<std::string, std::string> metadata;
318 };
319
336 static bool writeDataset(const std::string& directory, const std::string& prefix,
337 const std::map<std::string, View>& views);
338};
339
340} // namespace OpenMS
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
The representation of a 1D spectrum.
Definition MSSpectrum.h:44
Management and storage of parameters / INI files.
Definition Param.h:46
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
The parts of a QPX dataset that a search engine adds to the views of QPXFile.
Definition QPXDatasetExport.h:45
static std::shared_ptr< arrow::Table > sampleView(const std::vector< Sample > &samples)
The QPX sample view: one row per sample, in the order of samples.
std::string config
The config (e.g. paramToJSON() of the tool's parameters; "": null)
Definition QPXDatasetExport.h:243
std::shared_ptr< arrow::Table > table
The mz view (null if it could not be built; the error is logged)
Definition QPXDatasetExport.h:136
static std::vector< Column > psmColumns(const PeptideIdentificationList &peptide_ids, const std::vector< bool > &has_spectrum, bool isotope_observed_minus_theoretical)
The optional columns of the QPX psm view, one entry per row of the view (the best hit of each element...
std::string tool
The tool_name (e.g. "ProSE")
Definition QPXDatasetExport.h:239
static bool writeDataset(const std::string &directory, const std::string &prefix, const std::map< std::string, View > &views)
Write the QPX dataset views to directory: directory/prefix.VIEW.parquet per view (VIEW: its name)
std::vector< std::shared_ptr< arrow::Table > > tables
Definition QPXDatasetExport.h:313
std::optional< std::string > dissociation_method
The dissociation_method (none or "": null)
Definition QPXDatasetExport.h:209
std::string run_file_name
The run_file_name (as in the psm and mz views)
Definition QPXDatasetExport.h:199
std::optional< std::string > instrument
The instrument (none or "": null)
Definition QPXDatasetExport.h:207
static std::vector< Size > keptPeaks(const MSSpectrum &spectrum, const std::vector< PeptideHit::PeakAnnotation > &annotations, int precursor_charge, const PeakFilter &filter)
The indices of the peaks of spectrum that filter keeps: the most intense ones per window and those of...
std::vector< std::string > fixed_modifications
The fixed modifications of the search, by their OpenMS names (e.g. "Carbamidomethyl (C)")
Definition QPXDatasetExport.h:215
std::map< std::string, std::string > metadata
Extra keys of the file's footer (ArrowIOHelpers::qpxFileMetadata())
Definition QPXDatasetExport.h:317
std::optional< Int32 > biological_replicate
The biological replicate (none: null)
Definition QPXDatasetExport.h:188
std::string file_name
The file_name (e.g. the base name of the input file; "": null)
Definition QPXDatasetExport.h:201
std::optional< Int32 > technical_replicate
The technical replicate (none: null)
Definition QPXDatasetExport.h:190
static std::shared_ptr< arrow::Table > runView(const std::vector< Run > &runs)
The QPX run view: one row per run, in the order of runs.
static std::shared_ptr< arrow::Table > provenanceView(const std::vector< ProvenanceStep > &steps)
The QPX provenance view: one row per step, in the order of steps.
std::string name
The step_name (e.g. "peptide_search")
Definition QPXDatasetExport.h:237
std::vector< std::string > enzymes
The enzymes (empty: null)
Definition QPXDatasetExport.h:213
static std::string formatNumber(double value, const std::string &non_finite="null")
value as a locale-independent number: the shortest of 15 to 17 significant digits that reads back as ...
std::vector< std::pair< std::string, std::string > > parameters
The parameters, as key and value, in this order.
Definition QPXDatasetExport.h:241
std::vector< std::string > variable_modifications
The variable modifications of the search, by their OpenMS names (e.g. "Oxidation (M)")
Definition QPXDatasetExport.h:217
std::vector< RunSample > samples
The samples of the run.
Definition QPXDatasetExport.h:203
std::optional< std::string > fraction
The fraction (none or "": null)
Definition QPXDatasetExport.h:205
std::vector< std::string > output_views
The output_views (e.g. "psm"; empty: null)
Definition QPXDatasetExport.h:245
std::string category
The step_category (e.g. "database_search")
Definition QPXDatasetExport.h:235
static std::string scoreName(const std::string &name)
The name of a score or meta value in the snake_case of the QPX additional_scores.
std::string accession
The sample's sample_accession (of the sample view)
Definition QPXDatasetExport.h:184
ParquetWriteConfig config
The writer configuration.
Definition QPXDatasetExport.h:315
std::vector< bool > has_spectrum
Definition QPXDatasetExport.h:139
static MzView mzView(const MSExperiment &spectra, const PeptideIdentificationList &peptide_ids, const std::string &run_file_name, const PeakFilter &filter)
The QPX mz view of the MS2 spectra of the PSMs of one run, with the peaks filter keeps.
std::optional< std::string > acquisition_method
The acquisition_method (none or "": null)
Definition QPXDatasetExport.h:211
static std::string paramToJSON(const Param &param)
param as one JSON object of its full parameter names (e.g. "Search:precursor:mass_tolerance_lower") a...
Definition QPXDatasetExport.h:134
The peak filter of the mz view: the top most intense peaks per window Th (top 0: all peaks),...
Definition QPXDatasetExport.h:94
A step of the processing (a row of the provenance view, provenanceView())
Definition QPXDatasetExport.h:233
A run of the dataset (a row of the run view, runView())
Definition QPXDatasetExport.h:195
A sample of a run (the run view's samples)
Definition QPXDatasetExport.h:182
A sample of the dataset (a row of the sample view, sampleView())
Definition QPXDatasetExport.h:222
A view of the dataset for writeDataset()
Definition QPXDatasetExport.h:310
OpenMS looks in the< code > OPENMS_THERMO_MANAGED_DIR</code > environment variable then in the share directory
Definition common-cmake-parameters.doxygen:199
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
One column for withColumns(), built without Arrow types.
Definition ArrowIOHelpers.h:94
Configuration for Parquet file writing.
Definition MSExperimentArrowExport.h:136