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 <set>
17#include <memory>
18#include <optional>
19#include <string>
20#include <utility>
21#include <vector>
22
23namespace OpenMS
24{
25 class MSExperiment;
26 class MSSpectrum;
27 class Param;
28 class PeptideIdentificationList;
29
45class OPENMS_DLLAPI QPXDatasetExport
46{
47public:
50
61 static std::string scoreName(const std::string& name);
62
86 static std::vector<Column> psmColumns(const PeptideIdentificationList& peptide_ids,
87 const std::vector<bool>& has_spectrum,
88 bool isotope_observed_minus_theoretical);
89
95 {
97 double window = 100.0;
99 Size top = 100;
103 bool deisotoped = false;
105 int max_charge = 3;
107 bool cap_at_precursor = true;
108 };
109
129 static std::vector<Size> keptPeaks(const MSSpectrum& spectrum, const std::vector<PeptideHit::PeakAnnotation>& annotations,
130 int precursor_charge, const PeakFilter& filter);
131
134 struct MzView
135 {
137 std::shared_ptr<arrow::Table> table;
140 std::vector<bool> has_spectrum;
142 Size without_spectrum = 0;
145 Size unresolved = 0;
147 Size peaks_read = 0;
149 Size peaks_kept = 0;
150 };
151
178 static MzView mzView(const MSExperiment& spectra, const PeptideIdentificationList& peptide_ids,
179 const std::string& run_file_name, const PeakFilter& filter);
180
183 {
185 std::string accession;
187 std::string label = "LFQ";
189 std::optional<Int32> biological_replicate;
191 std::optional<Int32> technical_replicate;
192 };
193
195 struct Run
196 {
198 std::string accession;
200 std::string run_file_name;
202 std::string file_name;
204 std::vector<RunSample> samples;
206 std::optional<std::string> fraction;
208 std::optional<std::string> instrument;
210 std::optional<std::string> dissociation_method;
212 std::optional<std::string> acquisition_method;
214 std::vector<std::string> enzymes;
216 std::vector<std::string> fixed_modifications;
218 std::vector<std::string> variable_modifications;
219 };
220
222 struct Sample
223 {
225 std::string accession;
227 std::string organism = "not available";
229 std::string organism_part = "not available";
230 };
231
234 {
236 std::string category;
238 std::string name;
240 std::string tool;
242 std::vector<std::pair<std::string, std::string>> parameters;
244 std::string config;
246 std::vector<std::string> output_views;
247 };
248
263 static std::shared_ptr<arrow::Table> runView(const std::vector<Run>& runs);
264
273 static std::shared_ptr<arrow::Table> sampleView(const std::vector<Sample>& samples);
274
285 static std::shared_ptr<arrow::Table> provenanceView(const std::vector<ProvenanceStep>& steps);
286
297 static std::string paramToJSON(const Param& param);
298
307 static std::string formatNumber(double value, const std::string& non_finite = "null");
308
310 struct View
311 {
314 std::vector<std::shared_ptr<arrow::Table>> tables;
318 std::map<std::string, std::string> metadata;
319 };
320
338 static bool writeDataset(const std::string& directory, const std::string& prefix,
339 const std::map<std::string, View>& views, std::set<std::string>* failed = nullptr);
340};
341
342} // namespace OpenMS
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
The representation of a 1D spectrum.
Definition MSSpectrum.h:45
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:46
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:244
std::shared_ptr< arrow::Table > table
The mz view (null if it could not be built; the error is logged)
Definition QPXDatasetExport.h:137
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:240
std::vector< std::shared_ptr< arrow::Table > > tables
Definition QPXDatasetExport.h:314
std::optional< std::string > dissociation_method
The dissociation_method (none or "": null)
Definition QPXDatasetExport.h:210
std::string run_file_name
The run_file_name (as in the psm and mz views)
Definition QPXDatasetExport.h:200
std::optional< std::string > instrument
The instrument (none or "": null)
Definition QPXDatasetExport.h:208
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:216
std::map< std::string, std::string > metadata
Extra keys of the file's footer (ArrowIOHelpers::qpxFileMetadata())
Definition QPXDatasetExport.h:318
std::optional< Int32 > biological_replicate
The biological replicate (none: null)
Definition QPXDatasetExport.h:189
std::string file_name
The file_name (e.g. the base name of the input file; "": null)
Definition QPXDatasetExport.h:202
std::optional< Int32 > technical_replicate
The technical replicate (none: null)
Definition QPXDatasetExport.h:191
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:238
std::vector< std::string > enzymes
The enzymes (empty: null)
Definition QPXDatasetExport.h:214
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:242
std::vector< std::string > variable_modifications
The variable modifications of the search, by their OpenMS names (e.g. "Oxidation (M)")
Definition QPXDatasetExport.h:218
std::vector< RunSample > samples
The samples of the run.
Definition QPXDatasetExport.h:204
static bool writeDataset(const std::string &directory, const std::string &prefix, const std::map< std::string, View > &views, std::set< std::string > *failed=nullptr)
Write the QPX dataset views to directory: directory/prefix.VIEW.parquet per view (VIEW: its name)
std::optional< std::string > fraction
The fraction (none or "": null)
Definition QPXDatasetExport.h:206
std::vector< std::string > output_views
The output_views (e.g. "psm"; empty: null)
Definition QPXDatasetExport.h:246
std::string category
The step_category (e.g. "database_search")
Definition QPXDatasetExport.h:236
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:185
ParquetWriteConfig config
The writer configuration.
Definition QPXDatasetExport.h:316
std::vector< bool > has_spectrum
Definition QPXDatasetExport.h:140
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:212
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:135
The peak filter of the mz view: the top most intense peaks per window Th (top 0: all peaks),...
Definition QPXDatasetExport.h:95
A step of the processing (a row of the provenance view, provenanceView())
Definition QPXDatasetExport.h:234
A run of the dataset (a row of the run view, runView())
Definition QPXDatasetExport.h:196
A sample of a run (the run view's samples)
Definition QPXDatasetExport.h:183
A sample of the dataset (a row of the sample view, sampleView())
Definition QPXDatasetExport.h:223
A view of the dataset for writeDataset()
Definition QPXDatasetExport.h:311
OpenMS looks in the< code > OPENMS_THERMO_MANAGED_DIR</code > environment variable then in the share directory
Definition common-cmake-parameters.doxygen:179
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