![]() |
OpenMS
|
Public helpers for writing and concatenating Arrow tables to Parquet files. More...
Functions | |
| std::string | generateUuidV4 () |
| Generate a lowercase hyphenated RFC 4122 version-4 UUID string. | |
| bool | writeTableToParquet (const std::shared_ptr< arrow::Table > &table, const std::string &filename, const ParquetWriteConfig &config=ParquetWriteConfig{}) |
| Write an Arrow table to a Parquet file. | |
| bool | concatenateAndWriteToParquet (const std::vector< std::shared_ptr< arrow::Table > > &tables, const std::string &filename, const ParquetWriteConfig &config=ParquetWriteConfig{}, const std::shared_ptr< const arrow::KeyValueMetadata > &metadata=nullptr) |
| Concatenate a vector of Arrow tables and write the result to a Parquet file. | |
| std::shared_ptr< const arrow::KeyValueMetadata > | qpxFileMetadata (const std::string &file_type, const ParquetWriteConfig &config=ParquetWriteConfig{}, const std::map< std::string, std::string > &extra={}) |
| Build the canonical QPX file-level key-value metadata. | |
| std::string | qpxScanFormat (const std::string &native_id) |
Classify a spectrum native ID into a QPX scan_format token. | |
| std::string | qpxScanFormat (const std::vector< std::string > &native_ids) |
Derive a single QPX scan_format token for a set of native IDs. | |
| std::string | qpxRunFileName (const std::string &ms_run_path) |
Reduce an MS run path to the QPX run_file_name form. | |
| bool | qpxWarnOnRunNameCollisions (const std::string &context, const std::vector< std::string > &ms_run_paths) |
Warn once per export about source files that collapse onto one run_file_name. | |
| std::string | qpxIntensityLabel (const std::string &column_label, const std::string &channel_name) |
QPX intensities[].label for a ConsensusMap column header. | |
| std::shared_ptr< arrow::Array > | getColumn (const std::shared_ptr< arrow::Table > &table, const std::string &name, bool required=true) |
| Fetch a named column from a table, combining chunks if needed. | |
| std::string | getStringValue (const std::shared_ptr< arrow::Array > &array, int64_t row) |
Read a string at row, or "" if null/out-of-bounds. | |
| double | getDoubleValue (const std::shared_ptr< arrow::Array > &array, int64_t row, double default_val=0.0) |
Read a double at row, or default_val if null. | |
| float | getFloatValue (const std::shared_ptr< arrow::Array > &array, int64_t row, float default_val=0.0f) |
Read a float at row, or default_val if null. | |
| int32_t | getInt32Value (const std::shared_ptr< arrow::Array > &array, int64_t row, int32_t default_val=0) |
Read an int32 at row, or default_val if null. | |
| int64_t | getInt64Value (const std::shared_ptr< arrow::Array > &array, int64_t row, int64_t default_val=0) |
Read an int64 at row, or default_val if null. | |
| bool | getBoolValue (const std::shared_ptr< arrow::Array > &array, int64_t row, bool default_val=false) |
Read a bool at row, or default_val if null. | |
| bool | isNull (const std::shared_ptr< arrow::Array > &array, int64_t row) |
Whether array is null at row (or unset) | |
| void | readMetaValues (const std::shared_ptr< arrow::Array > &array, int64_t row, MetaInfoInterface &target, const std::unordered_set< std::string > &excluded_keys={}) |
| Read metavalues from a list<struct{name,value,value_type}> column. | |
Public helpers for writing and concatenating Arrow tables to Parquet files.
TOPP tools link against libOpenMS (which exports these helpers) but not directly against Arrow/Parquet. These wrappers keep all Arrow/Parquet API calls inside libOpenMS so downstream binaries don't need to import Arrow symbols.
| bool concatenateAndWriteToParquet | ( | const std::vector< std::shared_ptr< arrow::Table > > & | tables, |
| const std::string & | filename, | ||
| const ParquetWriteConfig & | config = ParquetWriteConfig{}, |
||
| const std::shared_ptr< const arrow::KeyValueMetadata > & | metadata = nullptr |
||
| ) |
Concatenate a vector of Arrow tables and write the result to a Parquet file.
All tables must share the same schema. An empty input vector is a no-op (returns true without writing).
| [in] | tables | Vector of Arrow tables to concatenate (must share schema) |
| [in] | filename | Output file path |
| [in] | config | Parquet writer configuration |
| [in] | metadata | Schema key-value metadata for the merged file. Concatenation otherwise inherits the first input's metadata, i.e. that table's identity; pass a fresh one (see qpxFileMetadata()) so the merged file is its own. nullptr keeps whatever the concatenation produced. |
tables is empty), false on error | std::string generateUuidV4 | ( | ) |
Generate a lowercase hyphenated RFC 4122 version-4 UUID string.
Used by QPX Parquet exporters when attaching file metadata.
| bool getBoolValue | ( | const std::shared_ptr< arrow::Array > & | array, |
| int64_t | row, | ||
| bool | default_val = false |
||
| ) |
Read a bool at row, or default_val if null.
| std::shared_ptr< arrow::Array > getColumn | ( | const std::shared_ptr< arrow::Table > & | table, |
| const std::string & | name, | ||
| bool | required = true |
||
| ) |
Fetch a named column from a table, combining chunks if needed.
Returns nullptr if the column is missing or contains no chunks. When required is true, missing columns are logged as errors.
| double getDoubleValue | ( | const std::shared_ptr< arrow::Array > & | array, |
| int64_t | row, | ||
| double | default_val = 0.0 |
||
| ) |
Read a double at row, or default_val if null.
| float getFloatValue | ( | const std::shared_ptr< arrow::Array > & | array, |
| int64_t | row, | ||
| float | default_val = 0.0f |
||
| ) |
Read a float at row, or default_val if null.
| int32_t getInt32Value | ( | const std::shared_ptr< arrow::Array > & | array, |
| int64_t | row, | ||
| int32_t | default_val = 0 |
||
| ) |
Read an int32 at row, or default_val if null.
| int64_t getInt64Value | ( | const std::shared_ptr< arrow::Array > & | array, |
| int64_t | row, | ||
| int64_t | default_val = 0 |
||
| ) |
Read an int64 at row, or default_val if null.
| std::string getStringValue | ( | const std::shared_ptr< arrow::Array > & | array, |
| int64_t | row | ||
| ) |
Read a string at row, or "" if null/out-of-bounds.
| bool isNull | ( | const std::shared_ptr< arrow::Array > & | array, |
| int64_t | row | ||
| ) |
Whether array is null at row (or unset)
| std::shared_ptr< const arrow::KeyValueMetadata > qpxFileMetadata | ( | const std::string & | file_type, |
| const ParquetWriteConfig & | config = ParquetWriteConfig{}, |
||
| const std::map< std::string, std::string > & | extra = {} |
||
| ) |
Build the canonical QPX file-level key-value metadata.
Writes the keys defined by the QPX serialization spec: qpx_version, file_type, creator, software_provider, creation_date (ISO 8601), compression_format and uuid, plus any extra keys.
Build this once per output file and reuse the returned object for both the writer schema and every batch — each call mints a fresh uuid and creation_date, so calling it per batch would produce mismatched schemas.
| [in] | file_type | QPX view token: "psm_file", "feature_file" or "pg_file" |
| [in] | config | Write configuration; supplies compression_format |
| [in] | extra | Additional keys, e.g. {{"scan_format", "scan"}} |
nullptr if config selects a compression QPX does not define (LZ4). Callers must treat nullptr as a write failure. | std::string qpxIntensityLabel | ( | const std::string & | column_label, |
| const std::string & | channel_name | ||
| ) |
QPX intensities[].label for a ConsensusMap column header.
The label is a join key: QPX matches intensities[].label against the unnested run.samples[].label of run.parquet (docs/spec/views.md), so it must be a canonical channel token, not a channel index or a file name.
Isobaric channels resolve to the reporter name prefixed by the method family, using OpenMS' own channel names — "TMT126", "TMT131" (TMT10-plex channel 10), "ITRAQ114". Label-free maps resolve to "LFQ".
| [in] | column_label | ConsensusMap::ColumnHeader::label. IsobaricChannelExtractor writes "<methodname>_<channelname>" (e.g. "tmt10plex_126"); ProteomicsLFQ writes "label-free". |
| [in] | channel_name | The header's channel_name meta value (e.g. "126"); empty when the map is not isobaric. |
"" when channel_name names a channel whose quantitation method cannot be identified — writing a guessed token into a join key is worse than writing none, so callers must handle the empty result. | std::string qpxRunFileName | ( | const std::string & | ms_run_path | ) |
Reduce an MS run path to the QPX run_file_name form.
QPX defines run_file_name as the raw data file name without extension, and uses it as a primary-key component in the psm, feature and pg views (and to join them against run.parquet). The full name with extension belongs in run.file_name.
| [in] | ms_run_path | Source path, e.g. /data/proj/S1_Frontal_1.mzML |
S1_Frontal_1; empty input yields an empty result. | std::string qpxScanFormat | ( | const std::string & | native_id | ) |
Classify a spectrum native ID into a QPX scan_format token.
| [in] | native_id | A spectrum native ID (e.g. controllerType=0 ... scan=1234) |
"index" for index= IDs, "scan" for other recognized native IDs, or "" when the convention cannot be determined.| std::string qpxScanFormat | ( | const std::vector< std::string > & | native_ids | ) |
Derive a single QPX scan_format token for a set of native IDs.
Unrecognized IDs are ignored. Returns "" when no ID is recognized, or when the inputs disagree — mixed conventions are reported once via the log rather than guessed at, so an ambiguous export omits scan_format instead of mislabeling it.
| bool qpxWarnOnRunNameCollisions | ( | const std::string & | context, |
| const std::vector< std::string > & | ms_run_paths | ||
| ) |
Warn once per export about source files that collapse onto one run_file_name.
QPX defines the column as the file name without path or extension, so two distinct paths sharing a stem (/a/run1.mzML and /b/run1.mzML) become indistinguishable as a join and partition key. Same-named files in different directories are a legitimate layout and the origin is known – only the spec's representation cannot express it – so this warns rather than failing, matching the policy the PSM exporter already applies.
| [in] | context | Caller name for the log line |
| [in] | ms_run_paths | Source paths participating in one QPX collection |
| void readMetaValues | ( | const std::shared_ptr< arrow::Array > & | array, |
| int64_t | row, | ||
| MetaInfoInterface & | target, | ||
| const std::unordered_set< std::string > & | excluded_keys = {} |
||
| ) |
Read metavalues from a list<struct{name,value,value_type}> column.
Decodes typed entries (int, double/float, *_list, string) and assigns them to target. Keys in excluded_keys are skipped.
| bool writeTableToParquet | ( | const std::shared_ptr< arrow::Table > & | table, |
| const std::string & | filename, | ||
| const ParquetWriteConfig & | config = ParquetWriteConfig{} |
||
| ) |
Write an Arrow table to a Parquet file.
| [in] | table | The Arrow table to write (must not be null) |
| [in] | filename | Output file path |
| [in] | config | Parquet writer configuration (compression, row group size, ...) |