OpenMS
Loading...
Searching...
No Matches
ProteinGroupArrowExport Class Reference

Export protein group data to Apache Arrow format following QPX pg schema. More...

#include <OpenMS/FORMAT/ProteinGroupArrowExport.h>

Static Public Member Functions

static std::shared_ptr< arrow::Table > exportToArrow (const ConsensusMap &cmap, const ExperimentalDesign &design)
 Export protein group data to Apache Arrow Table.
 
static std::shared_ptr< arrow::Table > exportToArrow (const ConsensusMap &cmap)
 Export protein group data to Apache Arrow Table, deriving the design from cmap.
 
static bool exportToParquet (const ConsensusMap &cmap, const ExperimentalDesign &design, const std::string &filename, const ParquetWriteConfig &config=ParquetWriteConfig{})
 Export protein group data to Parquet file.
 
static bool exportToParquet (const ConsensusMap &cmap, const std::string &filename, const ParquetWriteConfig &config=ParquetWriteConfig{})
 Export protein group data to Parquet file, deriving the design from cmap.
 
static std::shared_ptr< arrow::Table > exportToArrow (const std::vector< ProteinIdentification > &protein_identifications, const PeptideIdentificationList &peptide_identifications)
 Export protein group data to Arrow table from identification data (no quantification)
 
static bool exportToParquet (const std::vector< ProteinIdentification > &protein_identifications, const PeptideIdentificationList &peptide_identifications, const std::string &filename, const ParquetWriteConfig &config=ParquetWriteConfig{})
 Export protein group data to Parquet file from identification data (no quantification)
 
static bool exportToParquet (const std::shared_ptr< arrow::Table > &table, const std::string &filename, const ParquetWriteConfig &config=ParquetWriteConfig{})
 Write a pre-built QPX protein group Arrow table to a Parquet file.
 

Detailed Description

Export protein group data to Apache Arrow format following QPX pg schema.

This class provides static methods to export protein group quantification data from a ConsensusMap to Apache Arrow Tables and Parquet files. The schema follows the QPX (Quantitative Proteomics Exchange) protein group format.

Protein groups must have quantification annotated via PeptideAndProteinQuant::annotateQuantificationsToProteins() before export.

Experimental classes:
This API is experimental and may change in future versions.

Member Function Documentation

◆ exportToArrow() [1/3]

static std::shared_ptr< arrow::Table > exportToArrow ( const ConsensusMap &  cmap)
static

Export protein group data to Apache Arrow Table, deriving the design from cmap.

Convenience overload for callers that do not hold the design used for quantification. It reconstructs one with ExperimentalDesign::fromConsensusMap(), which recovers the fraction grouping from the column headers. Prefer the overload taking an explicit design whenever the caller has one — a reconstructed design only reproduces the original sample numbering when quantification was itself driven by a reconstructed design.

Parameters
[in]cmapThe ConsensusMap with annotated protein group quantification
Returns
Shared pointer to Arrow Table, or nullptr on error

◆ exportToArrow() [2/3]

static std::shared_ptr< arrow::Table > exportToArrow ( const ConsensusMap &  cmap,
const ExperimentalDesign &  design 
)
static

Export protein group data to Apache Arrow Table.

Exports indistinguishable protein groups following the active QPX 1.1 pg schema. One row is emitted per protein group, experimental-design fraction_group, and label. grouped_runs lists that fraction group's raw files, while scalar label and intensity carry one quantity. Together with anchor_protein these columns form the primary key.

A fraction group must be rectangular: every label it publishes has to exist in every one of its runs, which makes "(any file in grouped_runs, label) -> run.samples[]" resolvable. Designs that are ragged, assign one run to several fraction groups, or disagree about a label are refused. Reusing one sample in several fraction groups is valid and does not join them.

PeptideAndProteinQuant calculates protein quantities at (fraction_group, label) grain before protein aggregation and annotates them in named parallel data arrays. The exporter refuses a legacy sample-only annotation because an experiment-wide sample abundance cannot be split back into independent fraction-group quantities.

Groups without quantification are melted onto the fraction groups in which a member accession has peptide evidence, with null label and intensity.

Parameters
[in]cmapThe ConsensusMap with annotated protein group quantification
[in]designThe experimental design that was used to quantify cmap. It defines the exact fraction-group/label keys and their grouped runs. The exporter checks those keys against every quantified protein group.
Returns
Shared pointer to Arrow Table, or nullptr on error

◆ exportToArrow() [3/3]

static std::shared_ptr< arrow::Table > exportToArrow ( const std::vector< ProteinIdentification > &  protein_identifications,
const PeptideIdentificationList &  peptide_identifications 
)
static

Export protein group data to Arrow table from identification data (no quantification)

For search-engine output where no ConsensusMap is available. Populates required QPX pg fields (pg_accessions, anchor_protein, grouped_runs, is_decoy, peptides) and sets quantification columns (label, intensity, additional_intensities) to null.

This emits one row per protein group per run: the runs are those in which a member accession has peptide evidence, resolved per PSM through IdentifierMSRunMapper. A group in a single-file run is keyed on that file even without evidence; a group in a merged run with no evidence anywhere is skipped with a diagnostic, since grouped_runs is a QPX primary-key component that must not be empty.

Identification input carries no experimental design, so there is nothing to aggregate and every grouped_runs list has exactly one element — the single-element form the QPX 1.1 schema documents for unfractionated input.

peptides and peptide_counts are scoped to the emitted run, so the same group in two runs reports the peptides seen in each.

Parameters
[in]protein_identificationsProtein identifications with protein groups
[in]peptide_identificationsPeptide identifications (for peptide-per-protein counts)
Returns
Shared pointer to Arrow Table (empty table if no groups), or nullptr if an Arrow builder fails
Exceptions
Exception::MissingInformationif a PSM belongs to a merged run but carries no usable id_merge_index, so its origin file – and with it the row's key – is undetermined

◆ exportToParquet() [1/4]

static bool exportToParquet ( const ConsensusMap &  cmap,
const ExperimentalDesign &  design,
const std::string &  filename,
const ParquetWriteConfig &  config = ParquetWriteConfig{} 
)
static

Export protein group data to Parquet file.

Parameters
[in]cmapThe ConsensusMap with annotated protein group quantification
[in]designThe experimental design used to quantify cmap (see exportToArrow)
[in]filenameOutput file path
[in]configParquet writing options
Returns
true on success, false on error

◆ exportToParquet() [2/4]

static bool exportToParquet ( const ConsensusMap &  cmap,
const std::string &  filename,
const ParquetWriteConfig &  config = ParquetWriteConfig{} 
)
static

Export protein group data to Parquet file, deriving the design from cmap.

Parameters
[in]cmapThe ConsensusMap with annotated protein group quantification
[in]filenameOutput file path
[in]configParquet writing options
Returns
true on success, false on error

◆ exportToParquet() [3/4]

static bool exportToParquet ( const std::shared_ptr< arrow::Table > &  table,
const std::string &  filename,
const ParquetWriteConfig &  config = ParquetWriteConfig{} 
)
static

Write a pre-built QPX protein group Arrow table to a Parquet file.

The table is expected to follow QPXPgSchema (e.g., from exportToArrow). Attaches QPX file metadata (qpx_version, file_type="pg_file", UUID, creation_date) before writing. Use this overload when the caller already has the table built (e.g., for merged output) to avoid rebuilding it.

Parameters
[in]tableQPX pg Arrow table (must not be null)
[in]filenameOutput file path
[in]configParquet writing options
Returns
true on success, false on error

◆ exportToParquet() [4/4]

static bool exportToParquet ( const std::vector< ProteinIdentification > &  protein_identifications,
const PeptideIdentificationList &  peptide_identifications,
const std::string &  filename,
const ParquetWriteConfig &  config = ParquetWriteConfig{} 
)
static

Export protein group data to Parquet file from identification data (no quantification)

Parameters
[in]protein_identificationsProtein identifications with protein groups
[in]peptide_identificationsPeptide identifications (for peptide-per-protein counts)
[in]filenameOutput file path
[in]configParquet writing options
Returns
true on success, false on error