Skip to content

[FEATURE,PARAM,IO] ProSE: -qpx_extended, the QPX psm, mz, run and provenance views of a result viewer - #10676

Merged
timosachsenberg merged 69 commits into
developfrom
claude/prose-qpx-spectra
Oct 23, 2026
Merged

timosachsenberg merged 69 commits into
developfrom
claude/prose-qpx-spectra

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Split

This PR was split. The three PRs it depended on are merged into develop:

develop is merged into this branch, so what remains is the ProSE part: ProSE.cpp and its TOPP tests. -qpx_extended uses QPXDatasetExport, and ProSE.cpp keeps only ProSE's own parts (inputs, PeptDeep predictions, the run view's extra columns, the provenance contents, the footer keys). The output is file-by-file identical to before the split, apart from the runs/ paths. develop also has #10707 (protein inference on PEP-scored PSMs at a looser q-value cutoff); like #10707's own call, ProSE.cpp passes the search's inference-only PSMs to applyCompleteSetProteinFDR().

What

Outputs for viewers of ProSE results, so that a viewer can show a search from the QPX files alone. All are opt-in; plain -out_qpx output is unchanged.

  • -qpx_extended (ProSE, with -out_qpx): optional columns in the QPX psm view, named as proposed in Consumer use case: reading search results from QPX alone (optional PSM/run fields for viewers and QC) bigbio/qpx#355 (and spectrum_reference of psm/feature: no field carries the native spectrum reference, and the scan component convention is undefined outside Waters bigbio/qpx#259), so they need no rename if QPX adopts them. QPX readers ignore columns they do not know (QPX serialization.md).
    • additional_scores holds every numeric score and meta value of the PSM in snake_case, with higher_better where known: global_qvalue (the PSM-level q-value, computed over the PSMs of its input file), ln_hyperscore, percolator_score, percolator_qvalue, percolator_pep, precursor_mz_error_ppm, isotope_error, delta_mass, the Percolator features. (Without the flag the QPX writer keeps only the known scores, under OpenMS names such as MS:1001492.)
    • spectrum_reference (string): the native ID; null exactly when the mz view has no row of the PSM's own spectrum (null = no stored spectrum; of a written mz view: if the mz write fails, the references stay and the input fails with exit code 12): its native ID has the mz row of another spectrum (unresolved, see below), its spectrum was not found again, or the input's re-read failed. So no join gives a PSM another spectrum's peaks, or none.
    • isotope_error (int16, also in additional_scores): 13C peaks from the monoisotopic to the selected precursor peak, observed minus theoretical, with either report:isotope_error_convention (null if the meta value is neither an integer nor an integral double).
    • protein_mappings (list<struct{accession, start, end, aa_before, aa_after}>): 1-based first/last position, - at a protein terminus.
    • Per-input files only: predicted_ion_type_array (b3+, y5++), predicted_mz_array, predicted_intensity_array: the b/y ions of charge 1 and (precursor charge >= 2) 2 with PeptDeep's intensity relative to the most intense; ions of 0.01 or less left out; precursor charges 1 to 6.
  • The QPX mz view for the spectra (the spec's place for them, mz.md): per input runs/<stem>.mz.parquet with one row per MS2 spectrum of the written PSMs only, in the order of its first PSM (one row per native ID, the view's key: of several spectra of one native ID only the first's, so the PSMs of the others have no spectrum there and a null spectrum_reference; a reader must not look them up by scan either): id (the native ID = the psm's spectrum_reference), run_file_name, scan, ms_level, centroid, scan_start_time (minutes), inverse_ion_mobility, ion_injection_time, total_ion_current, precursors, cv_params, and mz/intensity (float32) filtered: the -qpx_peak_top (default 100) most intense per -qpx_peak_window (default 100 Th) in jumping windows (each starting at its first peak; the last window keeps the full quota too, unlike WindowMower, which drops the top end of most spectra), plus the peaks of the fragment annotations (mz_array) of its PSMs — of deisotoped spectra also the raw 2+/3+ peak of a fragment that deisotoping moved to its 1+ m/z, at the charges the search's deisotoping tried (up to the spectrum's recorded precursor charge, 3 if unknown — not the PSM's charge), so every annotated fragment keeps its peak; -qpx_peak_top 0 keeps all. Its footer records the filter (prose_peak_window, prose_peak_top, prose_peak_annotated).
  • Files: each per-input psm file and mz view is written as soon as its input is done (neither is held for the rest of the run) into runs/, in row groups of 256 rows (a viewer reads one PSM's spectrum and prediction by decoding one row group), the m/z and intensity columns without dictionary encoding. quantms.psm.parquet on top has the rows of the inputs whose psm file was written, without the prediction columns (and no rows if no input has any). The per-input psm footer has prose_prediction_ms2_model, prose_prediction_instrument. The output folder is exactly one QPX dataset: the aggregate files (quantms.*) are on top and the per-input files in runs/.
  • QPX run, sample and provenance views (per output directory, on top: quantms.run.parquet, quantms.sample.parquet, quantms.provenance.parquet; proposal in Consumer use case: reading search results from QPX alone (optional PSM/run fields for viewers and QC) bigbio/qpx#355):
    • run: one row per input with every column of the spec's run schema: run_accession, run_file_name (the input's stem), file_name, samples (one sample per run, label LFQ: ProSE knows no design), fraction, instrument, dissociation_method, acquisition_method, additional_terms (null: unknown to ProSE), enzymes, modification_parameters; plus optional search_status, ms2_spectra_count, identified_spectra_count, decoy_psm_count, psm_rows (its rows in quantms.psm.parquet), rescoring_applied / rescoring_skipped_reason / rescoring_warning, prediction_nce, precursor_error_median_ppm, precursor_error_mad_ppm, precursor_tolerance_recommended_ppm, fragment_error_median_ppm, fragment_error_mad_ppm, fragment_tolerance_recommended_ppm, search_seconds (0 with -test, so that the view can be compared with a reference).
    • sample: one row per run (sample = stem; organism, organism_part "not available", the SDRF value, as ProSE does not know them), so that run.samples refers to a sample.
    • provenance: one row per step — database_search/peptide_search (ProSE; curated parameters such as tolerances, charges, enzyme and specificity, missed cleavages, peptide length, modifications, decoys, the isotope-error convention, database and index sizes, timings; config = the complete ProSE parameters as JSON), rescoring/spectrum_prediction (tool OpenMS: PeptDeep's models; the closest QPX category), rescoring/psm_rescoring (tool OpenMS: its Percolator), fdr_filtering/target_decoy_fdr (PSM and protein FDR, protein_fdr_applied), protein_inference/protein_grouping. tool_version is the OpenMS version.
    • Every view ProSE writes (psm, mz, pg, run, sample, provenance) passes bigbio/qpx's own validator (load_schema(view).validate_full(table, strict=True), qpx 0dd22d2f; the qpxc validate CLI crashes with DuckDB 2.0, Validator: fields documented as not required are rejected when absent (run view); qpxc validate crashes with DuckDB 2.0 bigbio/qpx#356). OpenMS' own QPX validation covers psm and pg only.
  • Protein groups: with -qpx_extended, a run without protein inference gets one group per protein in its pg.parquet (with a null global_qvalue: [FIX] ProteinGroupArrowExport: null global_qvalue for a group without a q-value #10700, now in develop), and with -out_merged and several inputs quantms.pg.parquet holds the groups of the pooled inference (with its protein FDR) instead of the concatenated per-input groups (which are empty for such runs).
  • The extra read and its cost. After rescoring and the FDR filters, each input is read once more (streamed, MS2 only; .mzML.gz works) for the peaks of the written PSMs. The tool's in-memory spectra are not used because they are preprocessed.
  • Predictions for every written PSM, also without PeptDeep rescoring, at the NCE: of the rescoring (Search:peptdeep:enable; recomputed at that NCE), else Search:peptdeep:nce, else the one PeptDeepRescoring::annotate() selects on a copy of the written PSMs. Stored on the run (peptdeep_nce), reported in the run view.
  • Failures and builds without ONNX: a failed re-read (or an mz table that cannot be built) is a warning, leaves out the input's mz view and makes the spectrum_reference of its PSMs null; a failed prediction is a warning and leaves the prediction columns null; std::bad_alloc propagates and fails the input; without ONNX Runtime the prediction columns are null.
  • -keep_decoys (ProSE): keeps the decoy PSMs and proteins that pass the protein FDR (one input; -out_merged), via applyCompleteSetProteinFDR()'s remove_decoys ([FEATURE,API] ProSEAlgorithm: applyCompleteSetProteinFDR returns whether it applied the FDR; remove_decoys #10704). With one input the provenance's protein_fdr_applied is that function's return value: false when it skips the picked-protein FDR (no decoy protein left after the inference, or an empty decoy marker).
  • Pooled proteins in OpenMS Parquet: with -out_merged and -out_parquet, merged.proteins.parquet and merged.pg.parquet on top. An input named merged is searched like any other; its files are in runs/, next to the pooled merged.* on top.

Library changes

These are in develop with #10705 (QPXDatasetExport, ArrowIOHelpers::withColumns()/tableOfColumns(), ParquetWriteConfig::plain_columns/qpx_extra_columns and the Extensible validation); this PR only uses them.

The peak filter default (measured)

On an Orbitrap HCD run (iPRG2015 JD_06232014_sample1_A, Q Exactive, ~1,130 points per identified MS2 spectrum, 20,716 PSMs), against a viewer's annotation (b/y/a/c/x/z ions, charge 1-2, 20 ppm) of the unfiltered spectra of every second target PSM (229,246 matched peaks):

peaks per 100 Th peaks kept per spectrum matched peaks lost b/y matches lost matched intensity lost matches of intensity > 0 lost <stem>.mz.parquet
all 1,130 0 0 0 0 90.4 MB
300 1,008 1.35 % 0.24 % 0.000 % 0 82.1 MB
100 (default) 631 6.2 % 1.2 % 0.001 % 0.026 % 57.2 MB
50 401 9.5 % 1.9 % 0.05 % 0.87 % 40.8 MB

Nearly all lost matches are zero-intensity points of the file (chance matches, mostly of c/x/a/z ions). The input's psm file (with the predictions) is 10.3 MB, quantms.psm.parquet 6.7 MB. ProSE's own annotation: every annotated m/z keeps its peak (0 violations of 245,076; 7,199 kept through their 2+/3+ peak).

Why

The ProSE desktop app (a Tauri app that runs the native ProSE tool and shows its outputs in the ProSE web app's screens) reads only QPX: OpenMS' internal Parquet schema may change, QPX is the exchange format. Its tables, QC and PSM view need values that were in no QPX output: all scores, the native ID, the isotope error, protein positions and flanking residues, the peaks and PeptDeep's prediction, per-file statistics and search parameters, and the pooled protein groups. The app has no C++ of its own, so these values have to come from ProSE's outputs.

Tests

Test 14 compares ProSE's QPX views with references in the same way as develop's QPX value references: ParquetDiff -out_tsv dumps compared with ${QPX_DIFF}. The view rules (peak filter, deisotoped spectra, unknown precursor charge, duplicate native IDs, unsorted spectra) are class tests of QPXDatasetExport_test in #10705.

  • TOPP_ProSE_14 runs Test 1's search on two inputs, both copies of its 3-spectrum run, one of them .mzML.gz. It adds -out_merged, -qpx_extended, -Search:peptdeep:nce 30 and the theoretical_minus_observed isotope convention. The references are:

    • ProSE_14_merged_psm.tsv: quantms.psm.parquet, the rows of both inputs, without prediction columns.
    • ProSE_14_mz.tsv: the first input's mz view.
    • ProSE_14_psm.tsv, with ONNX only: the first input's psm file, with the extended columns and the predictions.
    • ProSE_14_run.tsv, with ONNX only: the run view, including prediction_nce. With -test, search_seconds is 0.

    The four references are 1.6-20 KB each. They were identical across repeated runs and with -threads 1 and -threads 8. Both pg files get -schema pg checks. The provenance view is checked with check_file_contains, because its tool_version is the build's version.

  • _keep_decoys: one input with the protein FDR, Percolator and -keep_decoys. It checks the decoys in the idXML and the pg file, and protein_fdr_applied true and keep_decoys in the provenance. With ONNX it also checks the NCE logged as "selected".

  • _protein_fdr_skipped: the skip is logged, and protein_fdr_applied is false in the provenance.

  • _empty: valid psm files with the columns and no rows.

  • _failed_prediction (ONNX only): an MS2 model that cannot be loaded is logged, and the run succeeds.

  • _mz_write_fails: the mz view cannot be written (a folder at its path). The input fails with exit code 12, and its rows are still in quantms.psm.parquet.

  • _merged_name: inputs named merged and other with -out_merged and -out_parquet. runs/merged.* and the pooled merged.proteins.parquet/merged.pg.parquet on top both exist and differ.

  • _same_name and _qpx_extended_needs_qpx: both runs are refused with exit code 6.

  • The tests use develop's check_exit_code.cmake and check_file_contains.cmake. One helper is new: ProSE_14_prepare.cmake, which copies the input and gzips one copy, like MS1LabeledWorkflow_prepare.cmake.

  • Linux, Release, with ONNX, local, at 9fea393bdd: ctest -R "ProSE|QPX|Arrow|ProteinInference|FalseDiscoveryRate|ClassFDR" 212/212 passed. Doxygen 1.12 on ProSE.cpp (at 55cf554fb5) reports no unsupported-tag warning. Scenarios S0 to S8 (on 223ed2edb7, before [FIX,API,PARAM] ProSE: protein inference on PEP-scored PSMs at a looser q-value cutoff #10707 changed the protein inference) gave outputs identical to those before the split, except for the runs/ paths.

  • CI: green at 9fea393bdd.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an optional extended QPX output mode with identification, spectrum, protein-mapping, prediction, sample, provenance, and run-level data.
    • Added an option to retain decoy proteins and peptide-spectrum matches during protein FDR processing.
    • Added support for creating Parquet tables with typed columns and including additional columns in QPX output.
  • Improvements
    • Parquet exports can write selected columns without dictionary encoding.
    • Extended QPX validation checks required columns while allowing configured extra columns.

timosachsenberg and others added 13 commits October 20, 2026 22:42
exportPSMsToQPXArrow() takes, per peptide identification, the peaks of its
spectrum and predicted fragment intensities (QPXFile::PSMSpectrum) and writes
them as five columns after the QPX ones: peak_mz_array, peak_intensity_array,
predicted_ion_type_array, predicted_mz_array, predicted_intensity_array
(QPXPSMSchema::schemaWithSpectra(), an OpenMS extension of the psm view, null
where unknown). The write-time checks (exportToParquet, QPXValueValidation)
accept the psm schema with or without them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ng features

selectNCE() runs the per-run NCE selection of annotate() (or takes 'nce') and
records it as 'peptdeep_nce' on the runs, without predicting retention times,
adding features or changing the PSMs. It lets a caller predict spectra at the
energy annotate() would use for PSMs that were not rescored with PeptDeep.
annotate() and selectNCE() share annotate_(); annotateRun_() returns after the
NCE selection when there is nothing to annotate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…NCE and decoy marker in the summary

applyCompleteSetProteinFDR() can keep the decoy PSMs and proteins that pass, as
mergeFileResults() can (remove_decoys), and returns whether the picked-protein
FDR was applied. renderRunSummaryYaml() reports per file the Percolator outcome
(applied, skipped_reason, warning) and the NCE of the PeptDeep predictions
('peptdeep_nce' of the run, null if none), and the decoy marker of the search.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n Parquet

-qpx_spectra adds to every row of the QPX psm.parquet files the peaks of its
spectrum, read again from the input after rescoring and FDR (only the written
PSMs, one file at a time), and the b/y intensities PeptDeep predicts at the NCE
of the file: the one PeptDeep rescoring used, else one selected as it selects it
(PeptDeepRescoring::selectNCE()). Without ONNX Runtime or the model the peaks
are written and the predictions are null.

-keep_decoys keeps the decoy PSMs and proteins that pass the protein FDR (one
input, -out_merged). With -out_merged and -out_parquet the pooled proteins and
protein groups are written as merged.proteins.parquet and merged.pg.parquet.
The summary reports whether the protein FDR was applied.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TOPP_ProSE_14 searches the data of TOPP_ProSE_11_rescore with -qpx_spectra,
without and with 'peptdeep:enable': every row has as many peaks as its spectrum
in the mzML, every row of charge 1 to 6 a prediction, and the prediction of one
PSM equals PeptDeepMS2Inference's at the reported NCE (reference values of the
model). Also checked: the summary, -keep_decoys with one input, and the merged
proteins and protein groups in Parquet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A set NCE needs no selection, so it is recorded on the run directly instead of
through PeptDeepRescoring::selectNCE(), which would also refuse PSMs without
peak annotations. TOPP_ProSE_14 gets a variant with 'peptdeep:nce' 30.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reverts eb31f5e. The QPX outputs stay as the QPX schema defines them; ProSE
writes the spectra to a sidecar file instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reverts 4c556b9. ProSE selects the NCE of PSMs that were not rescored with
PeptDeep by running annotate() on a copy of them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oteinFDR stays void

The summary read PeptDeepRescoring::NCE_META_VALUE, whose header is included
only with ONNX Runtime; it spells the meta value "peptdeep_nce" out. The protein
FDR keeps its void return (the ProSE tool tells by itself whether it applies),
and the summary no longer reports the decoy marker, which no consumer needs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…thout Arrow types

TOPP tools do not link Arrow; writeColumnsToParquet() writes int64, utf8,
list<float32> and list<utf8> columns given as plain vectors, e.g. a sidecar
keyed by a QPX identity column.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… sidecar

Replaces -qpx_spectra: the peaks and PeptDeep predictions go to a sidecar per
input, <stem>.psm_spectra.parquet, one row per row of the QPX psm view, keyed by
its psm_id, written as soon as the input is done; the QPX outputs keep their
schema. The NCE is the one PeptDeep rescoring used (the predictions are
recomputed at it), else 'peptdeep:nce' if set, else the one
PeptDeepRescoring::annotate() selects on a copy of the written PSMs. A failed
re-read or prediction is a warning with null columns, not a failed input; an
MS2 model of another layout leaves null predictions with a warning. Whether the
protein FDR of one input applies is told from the decoy proteins its PSMs refer
to.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TOPP_ProSE_14 checks the sidecar against the psm view and the mzML, the
prediction of one PSM against PeptDeepMS2Inference, and where the NCE comes
from (selected, PeptDeep rescoring's as it logged it, or set). The desktop
app's run: two inputs, one gzipped, -out_merged, -keep_decoys: a sidecar per
input with the rows of its psm view, an NCE per input, the same peaks from the
.mzML.gz as from the .mzML, the merged proteins. Two inputs of one name in
different folders are refused. A failed re-read (test hook) and a failed
prediction (a model ONNX Runtime cannot load) leave null columns and a
successful run. (check_prose_qpx_spectra.cmake was removed with 0eb2ddc.)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@timosachsenberg timosachsenberg changed the title [FEATURE] ProSE: spectra and PeptDeep predictions in QPX, outputs for result viewers [FEATURE] ProSE: PSM spectra and PeptDeep predictions as a QPX sidecar, outputs for result viewers Oct 20, 2026
… FDR

TOPP_ProSE_14_empty: a database whose decoys are the real proteins and whose targets are their
reversed sequences, so that no PSM passes the PSM FDR (protein FDR off). The run ends with exit code
0 and the sidecar is valid Parquet with psm_id and the five columns and no rows, as the QPX and
OpenMS psm tables. check_prose_psm_spectra.cmake takes -DROWS=<n> for an exact row count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Oct 21, 2026
The same file as the empty-result test of the -out_psm_spectra sidecar (#10676) uses, so that the two
branches add one file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@timosachsenberg

Copy link
Copy Markdown
Contributor Author

@claude can you double-check if QPX already defines how peak annotation should be used? I think the schema contains anything about it . If not I think it's the perfect time to open an issue in QPX, describe the problem, and suggest an optional extension to QPX

timosachsenberg and others added 2 commits October 21, 2026 18:16
… input

collectPSMSpectra_() took every std::exception of the re-read of the spectra and of the PeptDeep predictions for
an unreadable file or a failed prediction: a std::bad_alloc became a warning and null columns. It now propagates, and
the caller fails the input as it does for a failed write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts test

The environment variable OPENMS_PROSE_TEST_FAIL_SPECTRA_READ made the re-read of -out_psm_spectra fail in -test runs;
a test-only hook in the tool is not worth its test. A failed prediction keeps its test, which uses a real model that
ONNX Runtime cannot load. The comment of the two-input run no longer names an application.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Oct 21, 2026
timosachsenberg and others added 3 commits October 21, 2026 23:16
… table

Replaces writeColumnsToParquet() (added in this PR for the PSM spectra sidecar,
which -qpx_extended replaces): TOPP tools, which do not link Arrow, give columns
as plain vectors and get the table with them added, or replacing the column of
the same name in its place; the schema metadata is kept. Besides int64, utf8,
list<float32> and list<utf8>: int16, the struct list of the QPX
additional_scores, and a list of protein mappings (accession, start, end,
aa_before, aa_after); every column can have null rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
QPX readers ignore columns they do not know (docs/spec/serialization.md), so a
producer may add optional columns to a view. The validation of QPX tables
before they are written (QPXValueValidation) refused any column beyond the
view's schema; it now uses the new ArrowSchemaValidation::Mode::Extensible:
every column of the view in its place, with its type and nullability, and any
further columns after them. QPXFile::exportToParquet() keeps its exact (Strict)
check of the tables it builds itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A viewer can now show a search from the QPX files alone. With -out_qpx,
-qpx_extended adds optional columns to the QPX psm view, named as proposed in
bigbio/qpx#355 and #259: additional_scores with every numeric score and meta
value in snake_case (global_qvalue, ln_hyperscore, percolator_score/qvalue/pep,
the Percolator features), spectrum_reference, isotope_error (observed minus
theoretical), protein_mappings (1-based start/end, flanking residues), the
peaks of the spectrum and PeptDeep's predicted b/y intensities. The peaks are
filtered: the -qpx_peak_top (default 300) most intense per -qpx_peak_window
(100 Th) with WindowMower's jumping windows, plus every peak of the fragment
annotation; 0 keeps all. The statistics of the run (what -summary_out reports
per file and shared, the protein FDR outcome, the peak filter, the
modification-analysis tables) go to the footer of every psm.parquet as
'prose_' keys; the per-input files are therefore written at the end of the run.
A run without protein inference gets one protein group per protein in its
pg.parquet, and with -out_merged and several inputs quantms.pg.parquet holds
the groups of the pooled inference.

-out_psm_spectra and its sidecar files are removed (no release had them); the
Test 14 TOPP tests check the columns, the filter (annotated peaks kept), the
footer, the merged files, an empty result and the singleton groups.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Oct 21, 2026
@timosachsenberg timosachsenberg changed the title [FEATURE] ProSE: PSM spectra and PeptDeep predictions as a QPX sidecar, outputs for result viewers [FEATURE] ProSE: -qpx_extended, the QPX psm view with the columns and run statistics of a result viewer Oct 21, 2026
timosachsenberg and others added 3 commits October 22, 2026 07:25
…t-in extra columns

- ArrowIOHelpers::ParquetColumn: INT32, BOOL, DOUBLE and STRUCT_LIST (a list of structs of UTF8, INT32 and
  BOOL fields) columns, non-null columns; tableOfColumns() builds a table of such columns, so that a TOPP tool
  (which cannot use Arrow) can write e.g. a QPX run or provenance view. INT16/INT32 values outside their range
  are an error instead of wrapping.
- ParquetWriteConfig::plain_columns: columns written without dictionary encoding (with small row groups, a
  dictionary page per row group made peak m/z columns 40 % larger); ParquetWriteConfig::qpx_extra_columns:
  QPX write validation allows optional columns after the view's own only when the writer asks for it
  (QPXValueValidation::setExtraColumnsAllowed); otherwise the view's columns exactly, as before.
- ArrowSchemaValidation Extensible: a further column must not repeat the name of an expected or another
  further column.
- ProteinGroupArrowExport: a group without a q-value (NaN) gets a null global_qvalue.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tra per input written at once

- The statistics of the run move from the psm footer to the QPX run view (quantms.run.parquet: one row per input,
  with ms2_spectra_count, identified_spectra_count, decoy_psm_count, psm_rows, search_status,
  rescoring_applied/_skipped_reason/_warning, prediction_nce, the mass error estimates, search_seconds), the
  sample view (one sample per input) and the provenance view (quantms.provenance.parquet: database_search,
  PeptDeep's prediction, Percolator rescoring, FDR filtering and protein inference, with curated parameters and
  the complete ProSE parameters as JSON in 'config'). The psm footer keeps only what describes the optional
  columns (peak filter, prediction model).
- Each per-input psm file is written as soon as its input is done, in row groups of 256 rows and with the m/z
  and intensity columns without dictionary; its peaks and predictions are no longer held to the end of the run.
  quantms.psm.parquet gets the rows of the inputs whose file was written, without the peak and prediction
  columns (also without rows if no input has any).
- isotope_error (column and additional_scores) is observed minus theoretical with either
  report:isotope_error_convention (it was inverted with theoretical_minus_observed); the provenance says the
  convention of ProSE's meta value.
- Peak filter: the last window keeps the full top-N too (WindowMower scaled it by its width); of deisotoped
  spectra the raw 2+/3+ peak of a fragment that deisotoping moved to its 1+ m/z is kept, so every annotated
  fragment keeps its peak. Default -qpx_peak_top 100.
- TOPP tests: deisotoped spectra (ProSE_14_deisotope.mzML) with both isotope conventions, the run, sample and
  provenance views, the merged file without spectrum columns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Oct 22, 2026
@timosachsenberg timosachsenberg changed the title [FEATURE] ProSE: -qpx_extended, the QPX psm view with the columns and run statistics of a result viewer [FEATURE] ProSE: -qpx_extended, the QPX psm, run and provenance views of a result viewer Oct 22, 2026
timosachsenberg and others added 11 commits October 23, 2026 07:45
…its rows in quantms.psm.parquet

The per-input psm file is written first, with its own writeDataset() call; the
mz view and the protein groups follow in a second call. A failed mz or pg file
fails the input but no longer drops its rows from quantms.psm.parquet (and its
psm_rows from the run view), as before the move to QPXDatasetExport.

TOPP_ProSE_14_mz_write_fails puts a folder in the place of the input's mz file:
the run fails (exit code 12) and quantms.psm.parquet has the rows of the
input's psm file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… per failed psm write, test fixtures

- The tool doc and the comment of the per-input write say the rule as it is: quantms.psm.parquet has the rows of the
  inputs whose psm file was written (a failed mz or pg file does not remove them).
- A failed per-input psm write is logged once, by writeDataset() (the view and its file).
- The scan_format of quantms.psm.parquet is worked out only with -out_qpx.
- TOPP_ProSE_14_mz_write_fails sets up its folder with fixtures, so that it also passes when run alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…XDatasetExport_test

Test 14 keeps the runs that check ProSE end to end: _app (two inputs, one gzipped, -out_merged, -keep_decoys: the
runs/ layout, quantms.psm.parquet with the rows of both as the run view says, the pooled pg with decoys, the same peaks
from both copies, the NCE logged as selected, the provenance and sample views), _single (FDR:protein 0, peptdeep:nce
30, isotope_error_convention theoretical_minus_observed: the prediction against ProSE_14_AATAQYLSPR_2.tsv, the NCE
logged as set, one protein group per protein, the convention in the provenance view), _empty (both psm files with the
QPX psm columns and those of -qpx_extended, no rows), _failed_prediction, _mz_write_fails, and protein_fdr_skipped,
keep_decoys, same_name, qpx_extended_needs_qpx unchanged. 108 TOPP_ProSE_14 tests become 59;
check_prose_qpx_extended.cmake 612 lines 249.

The rules of the views are QPXDatasetExport_test's; the removed TOPP checks and their class test sections:
- qpx_plain (PEAKS ALL, -qpx_peak_top 0): keptPeaks "top 0: all peaks"; "mzView sorts unsorted spectra". Its NCE
  source "selected": _app.
- qpx_peptdeep, qpx_nce30 (PEAKS FILTERED, SOME_FEWER): keptPeaks jumping windows, nearest annotated peak, full quota
  of the last window; "mzView sorts unsorted spectra" (the most intense per 100 Th). The NCE set: _single.
- deisotope_* (CONVERTED: 2+ peaks of fragments deisotoping moved to 1+): keptPeaks "deisotoped ... at charge 2 and
  3, up to the precursor's charge"; mzView "the precursor charge caps ... the spectrum's (2+), not the PSM's".
- deisotope_* (ISOTOPE_VALUES, ISOTOPE_TWIN): psmColumns isotope_error "flipped to observed minus theoretical" and
  "observed minus theoretical: the meta value as it is", additional_scores with the same sign (the flip, given the
  convention). The convention ProSE derives and writes to the provenance view: _single (theoretical_minus_observed) and
  _app (observed_minus_theoretical).
- unknown_charge (UNKNOWN_CHARGE): keptPeaks "unknown charge: up to 3"; mzView "a spectrum of unknown precursor
  charge: up to 3+" (also with a 2+ PSM).
- duplicate_ids (SHARED_ID, the RT of the joined row): mzView rows per native ID in the order of the first PSM, the
  PSM of the later spectrum unresolved, "the peaks of the spectrum at 60 s, not those at 180 s"; psmColumns
  spectrum_reference null without a spectrum.
- empty (ROWS 0): ParquetDiff -schema psm on both psm files (its exit code 11 for the -qpx_extended columns replaced
  by regular expressions that require them); psmColumns "no elements"; writeDataset.
- qpx_plain provenance/sample, singletons: moved to _app and _single; provenanceView, sampleView.

Not covered any more: the NCE source "from PeptDeep rescoring" (qpx_peptdeep), and end to end ProSE's wiring of the
moved rules (setDeisotoping_ for the filter, the has_spectrum of mzView into psmColumns), which the class tests get as
inputs.

ProSE_14_deisotope.mzML and ProSE_14_unknown_charge.mzML are no longer used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rum of unknown precursor charge

A spectrum without a recorded precursor charge was deisotoped by the search up to 3+, whatever the charge of its PSMs;
with a 2+ PSM the mz view keeps the raw 3+ peak of an annotated fragment. Fails if the cap falls back to the PSM's
charge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s/pg.parquet of -out_parquet

With -out_merged and several inputs, -out_parquet writes the pooled proteins as merged.proteins.parquet and
merged.pg.parquet; an input named merged has its files in runs/. Both pairs are written and differ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… unresolved count's second case

"<view>" in the writeDataset doc made Doxygen warn "Unsupported xml/html tag" (Doxygen_Warning_test failed on
Linux); it reads VIEW now. MzView::unresolved also counts a PSM whose native ID has a row while none of the spectra
of that native ID is at its RT.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lements in TEST_EQUAL)

ClassTest's testEqual cannot make libc++'s std::__bit_const_reference from a bool, so the macOS build failed;
the elements are compared as bool(...).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
psmColumns cast the isotope_error/IsotopeError meta value to int, which throws ConversionError for a double (as
PercolatorInfile reads it back from a pin file) or a string. An integral double in the INT16 range is now taken as
its integer; any other value gives a null isotope_error. An int meta value (ProSE's) is written as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Doxygen warned "Unsupported xml/html tag <basename>" three times, failing Doxygen_Warning_test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@timosachsenberg timosachsenberg changed the title [FEATURE] ProSE: -qpx_extended, the QPX psm, mz, run and provenance views of a result viewer [FEATURE,PARAM,IO] ProSE: -qpx_extended, the QPX psm, mz, run and provenance views of a result viewer Oct 23, 2026
@timosachsenberg

Copy link
Copy Markdown
Contributor Author

Answer to the question above, on whether QPX already defines how peak annotations are used:

Only partly. The psm view has optional mz_array, intensity_array, charge_array and ion_type_array for the annotated peaks. There was nothing for the full peak list or for predicted spectra, and no rule tying a PSM to its spectrum (bigbio/qpx#259).

I opened two issues:

Following @jpfeuffer's suggestion there, this PR writes the observed peaks into QPX's own mz view (runs/<stem>.mz.parquet), joined via spectrum_reference = mz id. Only PeptDeep's predicted fragments go into extra psm columns, since QPX has no place for them.

🤖 Generated with Claude Code

timosachsenberg and others added 2 commits October 23, 2026 10:06
…ate id (one run per mz view)

mzView() builds the mz view of one run, whose native IDs are unique, but
writeDataset() concatenates the tables of a view: the mz tables of two runs
that both have "scan=1" gave a file with a duplicate id, the primary key of
QPX's mz schema. writeDataset() now logs the duplicate id, writes no mz file
and returns false. The doc of mzView, MzView and writeDataset states the
one-run contract. The id format is unchanged (run-qualified ids wait for
bigbio/qpx#355).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
timosachsenberg and others added 3 commits October 23, 2026 14:10
develop has #10705 (QPXDatasetExport) and #10707 (protein inference on PEP-scored PSMs at a looser q-value cutoff).
ProSEAlgorithm.h/.cpp and its test are taken from develop: the branch had them as develop before #10707. ProSE.cpp
keeps this branch's side and passes the search's inference-only PSMs to applyCompleteSetProteinFDR(), as #10707 does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Test 14 checked the -qpx_extended outputs with a CMake script of its own (check_prose_qpx_extended.cmake) and two more
helpers (check_pin_later_decoys.cmake, run_logged.cmake). It now works like the QPX value references of the other
tools: ParquetDiff -out_tsv dumps compared with QPX_DIFF.

- One run (Test 1's search, two inputs, one gzipped, -out_merged, the NCE set, the other isotope error convention) with
  four references: quantms.psm, the first input's mz view and, with ONNX Runtime (predictions), its psm file and the
  run view.
- The other runs check exit codes and log lines with check_exit_code.cmake, the provenance and idXML with
  check_file_contains.cmake, and the pg files with ParquetDiff -schema. They run on the 3-spectrum fixture where possible.
- With -test, the run view's search_seconds is 0, so the view can be compared with a reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant