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

Stateful value and primary-key validator for QPX Arrow tables. More...

#include <OpenMS/FORMAT/QPXValueValidation.h>

Classes

struct  Result
 Result of validating one table or streaming batch. More...
 

Public Types

enum class  View { PSM , FEATURE , PROTEIN_GROUP }
 QPX table whose value contract is checked. More...
 

Public Member Functions

 QPXValueValidation (View view)
 Construct a validator for one QPX view.
 
 ~QPXValueValidation ()
 
 QPXValueValidation (QPXValueValidation &&) noexcept
 
QPXValueValidation & operator= (QPXValueValidation &&) noexcept
 
 QPXValueValidation (const QPXValueValidation &)=delete
 
QPXValueValidation & operator= (const QPXValueValidation &)=delete
 
Result validate (const std::shared_ptr< arrow::Table > &table)
 Validate one whole table or the next streaming batch.
 
void reset ()
 Forget primary keys accumulated from earlier validate() calls.
 
void setExtraColumnsAllowed (bool allowed)
 Allow optional columns after the view's own (QPX readers ignore columns they do not know)
 
void setThreads (int threads)
 Check the rows of a psm table in threads ranges in parallel (OpenMP; default 1: serial)
 

Private Attributes

std::unique_ptr< Impl > impl_
 

Detailed Description

Stateful value and primary-key validator for QPX Arrow tables.

Arrow schema validation checks declarations such as field type and nullability. It does not reject an empty string in an identity-bearing key, physical nulls under a non-nullable field, duplicate primary keys, or invalid nested values. This class supplies those write-time checks for the OpenMS QPX psm, feature, and pg views. QPX-permitted unmapped features retain OpenMS' empty peptidoform representation and are still distinguished by their remaining key fields.

A validator retains primary keys between validate() calls. Streaming writers can therefore validate consecutive batches with one instance and detect duplicates that cross a batch boundary. Use reset() before starting a different output file.

The contract this class enforces

This is the single place the QPX input contract is written down; the tools that offer -out_qpx (ProteinQuantifier, ProteomicsLFQ, IsobaricWorkflow, ProSE) point here rather than restating it, so it cannot drift from the code. A table that violates it is refused outright: the export writes nothing, rather than emitting rows that will not join.

Consensus maps produced by ProteomicsLFQ and IsobaricWorkflow satisfy the contract by construction, and they are the supported producers. A map assembled by a different pipeline may not, and the requirements it can fail are:

  • Every identification needs a scan. The scan primary-key component is derived from the identification's spectrum reference. Identifications carrying none - protein-inference output, some ID converters, transferred (match-between-runs) identifications - cannot be exported.
  • Every identification needs a resolvable origin file. run_file_name is the key the psm view is joined to the feature and pg views on. Protein inference commonly drops the path; restore it with ProteinIdentification::setPrimaryMSRunPath() before exporting.
  • Identifications must be unique per (peptidoform, charge, run, scan). IDMapper maps one MS2 identification onto every consensus feature whose RT/m-z window contains it, so the same identification can end up on two features. Resolve conflicts first, e.g. with IDConflictResolver.
  • Every channel needs a QPX label. The vocabulary is label-free, the TMT and iTRAQ plexes, and SILAC 2-/3-plex. Those labels are join keys against the run sidecar, so OpenMS refuses rather than guesses one. Maps from FeatureFinderMultiplex carrying ICPL*, Leu3, "label N" or no_label fall outside the vocabulary and cannot be exported.

Feature rows are keyed on (peptidoform, charge, run_file_name, rt, observed_mz). observed_mz is part of that key for the sake of unmapped features: QPX permits them, OpenMS writes them with an empty peptidoform, and rt is narrowed to float32 on write - so without the m/z two co-eluting unmapped features of one charge in one run would share a key and the export would be refused. Rows agreeing on all five are genuinely indistinguishable and are still refused.

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

Member Enumeration Documentation

◆ View

enum class View
strong

QPX table whose value contract is checked.

Enumerator
PSM 
FEATURE 
PROTEIN_GROUP 

Constructor & Destructor Documentation

◆ QPXValueValidation() [1/3]

QPXValueValidation ( View  view)
explicit

Construct a validator for one QPX view.

Parameters
[in]viewView whose schema, values, and primary key are checked

◆ ~QPXValueValidation()

◆ QPXValueValidation() [2/3]

◆ QPXValueValidation() [3/3]

QPXValueValidation ( const QPXValueValidation &  )
delete

Member Function Documentation

◆ operator=() [1/2]

QPXValueValidation & operator= ( const QPXValueValidation &  )
delete

◆ operator=() [2/2]

QPXValueValidation & operator= ( QPXValueValidation &&  )
noexcept

◆ reset()

void reset ( )

Forget primary keys accumulated from earlier validate() calls.

◆ setExtraColumnsAllowed()

void setExtraColumnsAllowed ( bool  allowed)

Allow optional columns after the view's own (QPX readers ignore columns they do not know)

Off by default: validate() then requires the view's columns exactly. On, each view column is still checked in place (name, type, nullability), and the further columns must have names distinct from each other and from the view's columns.

◆ setThreads()

void setThreads ( int  threads)

Check the rows of a psm table in threads ranges in parallel (OpenMP; default 1: serial)

The result is that of the serial check: the same errors in the same order, the same rows reported as duplicates. Inside a parallel region, or without OpenMP, the check is serial.

◆ validate()

Result validate ( const std::shared_ptr< arrow::Table > &  table)

Validate one whole table or the next streaming batch.

Checks the exact OpenMS QPX schema, physical nulls in required columns, non-empty identity-bearing primary-key values, primary-key uniqueness, canonical quantitative labels, and view-specific nested invariants. For pg data this includes non-empty, duplicate-free grouped_runs and run-disjointness within one (anchor_protein, label).

State is advanced only when the complete table is valid, so a rejected batch can be fixed and submitted again without first calling reset().

Parameters
[in]tableTable or streaming batch to validate
Returns
Structured validation result; valid is false if writing must be refused

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> impl_
private