![]() |
OpenMS
|
Class to write out an OpenSwath OSW SQLite output (PyProphet input). More...
#include <OpenMS/ANALYSIS/OPENSWATH/OpenSwathOSWWriter.h>
Classes | |
| struct | OSWData |
| Buffered OSW table rows ready for insertion through prepared statements. More... | |
| struct | OSWValue |
| Typed OSW cell value used for direct SQLite binding. More... | |
Public Types | |
| using | FeatureRow = std::array< OSWValue, FEATURE_COLUMN_COUNT > |
| using | FeatureMS1Row = std::array< OSWValue, FEATURE_MS1_COLUMN_COUNT > |
| using | FeatureMS2Row = std::array< OSWValue, FEATURE_MS2_COLUMN_COUNT > |
| using | FeaturePrecursorRow = std::array< OSWValue, FEATURE_PRECURSOR_COLUMN_COUNT > |
| using | FeatureTransitionRow = std::array< OSWValue, FEATURE_TRANSITION_COLUMN_COUNT > |
Public Member Functions | |
| OpenSwathOSWWriter (const std::string &output_filename, bool uis_scores=false) | |
| bool | isActive () const |
| void | writeHeader () |
| Initializes file by generating SQLite tables. | |
| void | addRun (const UInt64 run_id, const std::string &input_filename) |
| Add a RUN entry to the OSW file. Can be called multiple times to register multiple runs. | |
| void | setRunId (const UInt64 run_id) |
| Set the current run id used when prepareLine generates FEATURE entries. | |
| std::string | getScore (const Feature &feature, const std::string &score_name) const |
| Prepare scores for SQLite insertion. | |
| std::vector< std::string > | getSeparateScore (const Feature &feature, const std::string &score_name) const |
| Prepare concatenated scores for SQLite insertion. | |
| OSWData | prepareRows (const OpenSwath::LightCompound &pep, const OpenSwath::LightTransition *transition, const FeatureMap &output, const std::string &id) const |
| Prepare feature rows for SQLite insertion. | |
| void | prepareRowsInto (OSWData &rows, const OpenSwath::LightCompound &pep, const OpenSwath::LightTransition *transition, const FeatureMap &output, const std::string &id) const |
| Append feature rows for SQLite insertion into an existing buffer. | |
| std::string | prepareLine (const OpenSwath::LightCompound &pep, const OpenSwath::LightTransition *transition, const FeatureMap &output, const std::string &id) const |
| Prepare a single line (feature) for output. | |
| void | writeRows (const OSWData &osw_output) |
| Write buffered OSW rows to disk. | |
| void | writeLines (const std::vector< std::string > &to_osw_output) |
| Write data to disk. | |
Static Public Attributes | |
| static constexpr Size | FEATURE_COLUMN_COUNT = 11 |
| static constexpr Size | FEATURE_MS1_COLUMN_COUNT = 18 |
| static constexpr Size | FEATURE_MS2_COLUMN_COUNT = 38 |
| static constexpr Size | FEATURE_PRECURSOR_COLUMN_COUNT = 4 |
| static constexpr Size | FEATURE_TRANSITION_COLUMN_COUNT = 43 |
Private Attributes | |
| std::string | output_filename_ |
| OpenMS::UInt64 | run_id_ = 0 |
| bool | doWrite_ |
| bool | enable_uis_scoring_ |
| std::unique_ptr< SqliteConnector > | conn_ |
| std::mutex | conn_mutex_ |
Class to write out an OpenSwath OSW SQLite output (PyProphet input).
The class can take a FeatureMap and create buffered rows from it suitable for output to OSW using the prepareRows function. The SQL data is directly linked to the PQP file format described in the TransitionPQPFile class. See also OpenSwathTSVWriter for another output format.
The file format has the following tables:
| RUN | ||
|---|---|---|
| ID | INT | Primary Key (run id) |
| FILENAME | TEXT | Original filename associated with the run |
| FEATURE | ||
|---|---|---|
| ID | INT | Primary Key (feature id) |
| RUN_ID | INT | Foreign Key (RUN.ID) |
| PRECURSOR_ID | INT | Foreign Key (TransitionPQPFile PRECURSOR.ID) |
| EXP_RT | REAL | Experimental RT (retention time) of the feature |
| NORM_RT | REAL | Normalized RT (retention time) of the feature. The position of the peak group in the normalized retention time space (e.g. fx(RT) where fx describes the transformation fx) |
| DELTA_RT | REAL | The difference in retention between expected retention time of the assay and the measured feature retention time (EXP_RT) |
| LEFT_WIDTH | REAL | Retention time start of the peak (left width) in seconds |
| RIGHT_WIDTH | REAL | Retention time end of the peak (right width) in seconds |
| FEATURE_MS1 | ||
|---|---|---|
| FEATURE_ID | INT | Foreign Key (FEATURE.ID) |
| AREA_INTENSITY | REAL | Precursor intensity (area) |
| APEX_INTENSITY | REAL | Precursor intensity (apex) |
| VAR_... | REAL | Precursor score used in pyProphet |
| FEATURE_MS2 | ||
|---|---|---|
| FEATURE_ID | INT | Foreign Key (FEATURE.ID) |
| AREA_INTENSITY | REAL | Summed fragment ion intensity (area) |
| TOTAL_AREA_INTENSITY | REAL | Summed total XIC of the whole chromatogram |
| APEX_INTENSITY | REAL | Summed fragment ion intensity (apex) |
| TOTAL_MI | REAL | Total mutual information (MI) |
| VAR_... | REAL | Fragment ion score used in pyProphet |
| FEATURE_PRECURSOR | ||
|---|---|---|
| FEATURE_ID | INT | Foreign Key (FEATURE.ID) |
| ISOTOPE | INT | Isotope identifier |
| AREA_INTENSITY | REAL | Precursor isotope ion intensity (area) |
| APEX_INTENSITY | REAL | Precursor isotope ion intensity (apex) |
| FEATURE_TRANSITION | ||
|---|---|---|
| FEATURE_ID | INT | Foreign Key (FEATURE.ID) |
| TRANSITION_ID | INT | Foreign Key (transition identifier) |
| AREA_INTENSITY | REAL | Fragment ion intensity (area) |
| TOTAL_AREA_INTENSITY | REAL | Total XIC of the whole chromatogram |
| APEX_INTENSITY | REAL | Fragment ion intensity (apex) |
| TOTAL_MI | REAL | Total mutual information (MI) |
| VAR_... | REAL | Fragment ion score used in pyProphet |
| using FeatureMS1Row = std::array<OSWValue, FEATURE_MS1_COLUMN_COUNT> |
| using FeatureMS2Row = std::array<OSWValue, FEATURE_MS2_COLUMN_COUNT> |
| using FeaturePrecursorRow = std::array<OSWValue, FEATURE_PRECURSOR_COLUMN_COUNT> |
| using FeatureRow = std::array<OSWValue, FEATURE_COLUMN_COUNT> |
| using FeatureTransitionRow = std::array<OSWValue, FEATURE_TRANSITION_COLUMN_COUNT> |
| OpenSwathOSWWriter | ( | const std::string & | output_filename, |
| bool | uis_scores = false |
||
| ) |
| void addRun | ( | const UInt64 | run_id, |
| const std::string & | input_filename | ||
| ) |
Add a RUN entry to the OSW file. Can be called multiple times to register multiple runs.
| std::string getScore | ( | const Feature & | feature, |
| const std::string & | score_name | ||
| ) | const |
Prepare scores for SQLite insertion.
Some scores might not be defined, those are reported as NULL
| [in] | feature | The feature being evaluated |
| [in] | score_name | The name of the queried score |
| std::vector< std::string > getSeparateScore | ( | const Feature & | feature, |
| const std::string & | score_name | ||
| ) | const |
Prepare concatenated scores for SQLite insertion.
Some scores might not be defined, those are reported as NULL
| [in] | feature | The feature being evaluated |
| [in] | score_name | The name of the queried score |
| bool isActive | ( | ) | const |
| std::string prepareLine | ( | const OpenSwath::LightCompound & | pep, |
| const OpenSwath::LightTransition * | transition, | ||
| const FeatureMap & | output, | ||
| const std::string & | id | ||
| ) | const |
Prepare a single line (feature) for output.
The result can be flushed to disk using writeLines (either line by line or after collecting several lines).
| [in] | pep | The compound (peptide/metabolite) used for extraction |
| [in] | transition | The transition used for extraction |
| [in] | output | The feature map containing all features (each feature will generate one entry in the output) |
| [in] | id | The transition group identifier (peptide/metabolite id) |
| OSWData prepareRows | ( | const OpenSwath::LightCompound & | pep, |
| const OpenSwath::LightTransition * | transition, | ||
| const FeatureMap & | output, | ||
| const std::string & | id | ||
| ) | const |
Prepare feature rows for SQLite insertion.
This is the preferred high-throughput path. It avoids constructing full SQL statements for every feature and lets writeRows bind values into reusable prepared statements.
| [in] | pep | The compound (peptide/metabolite) used for extraction |
| [in] | transition | The transition used for extraction |
| [in] | output | The feature map containing all features |
| [in] | id | The transition group identifier (peptide/metabolite id) |
| void prepareRowsInto | ( | OSWData & | rows, |
| const OpenSwath::LightCompound & | pep, | ||
| const OpenSwath::LightTransition * | transition, | ||
| const FeatureMap & | output, | ||
| const std::string & | id | ||
| ) | const |
Append feature rows for SQLite insertion into an existing buffer.
This avoids constructing small per-assay OSWData buffers in high-throughput schedulers.
| [in,out] | rows | The row buffer to append to |
| [in] | pep | The compound (peptide/metabolite) used for extraction |
| [in] | transition | The transition used for extraction |
| [in] | output | The feature map containing all features |
| [in] | id | The transition group identifier (peptide/metabolite id) |
| void setRunId | ( | const UInt64 | run_id | ) |
Set the current run id used when prepareLine generates FEATURE entries.
| void writeHeader | ( | ) |
Initializes file by generating SQLite tables.
| void writeLines | ( | const std::vector< std::string > & | to_osw_output | ) |
Write data to disk.
Takes a set of pre-prepared data statements from prepareLine and flushes them to disk
| [in] | to_osw_output | Statements generated by prepareLine |
| void writeRows | ( | const OSWData & | osw_output | ) |
Write buffered OSW rows to disk.
Uses one SQLite transaction and reusable prepared statements for each OSW table. This is the preferred writer path for newly generated output.
| [in] | osw_output | Rows generated by prepareRows |
|
mutableprivate |
|
mutableprivate |
|
private |
|
private |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
private |
|
private |