Skip to content

[FIX] QPX 1.1: re-key the pg view onto grouped_runs, bump qpx_version (#9817) - #9843

Merged
timosachsenberg merged 7 commits into
developfrom
qpx-1.1-pg-grouped-runs
Aug 3, 2026
Merged

timosachsenberg merged 7 commits into
developfrom
qpx-1.1-pg-grouped-runs

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Aligns OpenMS QPX export with the active, unreleased QPX 1.1 contract on bigbio/qpx's dev branch, as merged in bigbio/qpx#224 and pinned here at 381986f5.

Part of #9817.

QPX 1.1 contract implemented

  • QPX metadata declares qpx_version=1.1.
  • The pg view matches the active 21-field schema: one row per label with scalar nullable label and intensity.
  • The pg primary key is (anchor_protein, grouped_runs, label).
  • grouped_runs comes from the exact OpenMS ExperimentalDesign::fraction_group; it is not inferred from sample connectivity.
  • Identification-only protein groups use singleton grouped_runs and null label/intensity.
  • Feature and PSM row shapes remain unchanged by QPX 1.1.

Quantification grain

PeptideAndProteinQuant now preserves quantities at both existing sample grain and QPX's required (fraction_group, label) grain. Normalization, top-N aggregation, iBAQ, protein transfer, named data arrays, and pyOpenMS bindings carry the fraction-group quantities through to export.

This is necessary because sample-level totals cannot be split back into independent fraction-group quantities after aggregation.

Complete collection preflight

QPXCollectionExport::requireExportable() validates all three views before the first Parquet file is opened. It now covers:

  • missing protein identifications or indistinguishable groups;
  • malformed or conflicting experimental-design cells and out-of-range sample indices;
  • label disagreements within a fraction group;
  • duplicate identification-run identifiers;
  • unresolved merged-run PSM indices;
  • feature/PSM identity ambiguity and protein-group schema prerequisites.

The PSM preflight has a pointer overload so IsobaricWorkflow does not deep-copy millions of identifications.

Additional fixes

  • IsobaricWorkflow no longer indexes before the experiment when an MS2 spectrum has no preceding MS1; precursor purity remains unavailable while quantification continues.
  • feature_counts.total_features follows the feature view's one-row-per-(feature, run) grain.
  • The quantified and identification-only pg writers share the registry schema and null semantics.
  • Duplicate-key and row-count checks follow the flattened QPX 1.1 pg representation.

Integration with current develop

The branch is rebased over OpenMS #9844, which persists protein-group data arrays in consensusXML. The new fraction-group abundance/label arrays use that generic persistence path, and #9844's safe zero-aware normalization and IsobaricWorkflow consensusXML regression test are retained.

Verification

Focused coverage includes:

  • PeptideAndProteinQuant_test
  • ProteinGroupArrowExport_test
  • QPXCollectionExport_test
  • QPXFile_test
  • ArrowSchemaRegistry_test
  • pyOpenMS binding syntax and Python test syntax
  • IsobaricWorkflow consensusXML, missing-preceding-MS1, and QPX collection paths

The focused C++ suite passed 5/5 before the rebase. On head d08816dc6a, GitHub's five-platform Build and Test matrix, cppcheck, and CodeRabbit pass; the pyOpenMS wheel matrix is still running.

Summary by CodeRabbit

  • New Features

    • Updated QPX exports to version 1.1 with grouped raw-run information and improved protein-group quantification.
    • Added experimental-design-aware exports with fraction-group and label-level quantities.
    • Added QPX export support to relevant quantification workflows.
  • Bug Fixes

    • Added pre-export validation for invalid identifiers, mappings, designs, channels, and annotations.
    • Improved handling of missing or unquantified protein-group values.
    • Prevented precursor-purity errors when no preceding MS1 spectrum is available.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

QPX exports now follow version 1.1. Protein-group rows use grouped runs and nullable scalar quantities. Quantification preserves fraction-group and label data. Collection preflight validates inputs before file creation. IsobaricWorkflow handles missing MS1 spectra safely.

Changes

QPX 1.1 export flow

Layer / File(s) Summary
QPX contracts and shared data
src/openms/include/OpenMS/FORMAT/*, src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h
Defines grouped_runs, scalar label and intensity, design-aware export overloads, fraction-group abundance data, and merge-index preflight APIs.
Fraction-group quantification
src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp, src/pyOpenMS/bindings/bind_analysis.cpp
Stores, aggregates, normalizes, annotates, and exposes fraction-group/label abundances for peptide and protein results.
Design-aware protein-group export
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp, src/openms/source/FORMAT/ArrowSchemaRegistry.cpp
Emits grouped-run rows with scalar quantities and validates experimental-design mappings.
Collection validation and workflow integration
src/openms/source/FORMAT/QPXCollectionExport.cpp, src/topp/*.cpp
Validates identifiers, merge indices, channels, designs, and protein-group annotations before QPX files are written.
Compatibility and test coverage
src/tests/class_tests/openms/source/*, src/tests/topp/*, src/pyOpenMS/tests/*, src/pyOpenMS/pyopenms/addons/*
Updates QPX 1.1 expectations and adds coverage for schemas, quantification, exports, validation, and missing preceding MS1 spectra.

Sequence Diagram(s)

sequenceDiagram
  participant Workflow
  participant QPXCollectionExport
  participant ProteinGroupArrowExport
  participant QPXParquetFiles
  Workflow->>QPXCollectionExport: Validate the complete collection
  QPXCollectionExport->>ProteinGroupArrowExport: Validate design and protein-group data
  QPXCollectionExport-->>Workflow: Return exportability
  Workflow->>QPXParquetFiles: Write feature, PSM, and protein-group files
Loading

Possibly related issues

Possibly related PRs

  • OpenMS/OpenMS#9833 — Relates to QPX schema conformance, channel consistency, validation, and unquantified groups.
  • OpenMS/OpenMS#9835 — Relates to merged-run validation in ConsensusMapArrowExport.
  • OpenMS/OpenMS#9844 — Relates to fraction-group abundance data consumed by protein-group exports.

Suggested reviewers: cbielow

Poem

I’m a rabbit with grouped runs in sight,
Hopping through labels, designs, and bytes.
Fractions stay sorted, nulls sit clear,
Preflight checks keep bad files far from here.
QPX 1.1 bounds through the night.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main QPX 1.1 changes: re-keying the protein-group view with grouped_runs and updating qpx_version.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch qpx-1.1-pg-grouped-runs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp (1)

554-570: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low value

Consider applying the same null-versus-empty rule to additional_intensities.

The new comment states the rule clearly: null means "no quantification", and an empty list means "quantified across zero channels". intensities now follows that rule in both overloads. additional_intensities does not. The quantified overload appends an empty list on Line 574, while the identification-only overload appends null on Line 1309. Both are valid against the nullable schema field, so a consumer reading two QPX pg_file outputs sees two encodings for the same absence.

Align the two producers on one encoding.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp` around lines 554 - 570,
Apply the same null-versus-empty encoding rule used for intensities to
additional_intensities: update the quantified overload to append null when its
channel map is empty, while preserving the nested list output for non-empty
values and matching the identification-only overload.
src/tests/class_tests/openms/source/QPXCollectionExport_test.cpp (1)

99-120: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

omit_row is never used.

Every call site passes only paths, and the ragged-design section at Line 174 builds its own MSFileSection inline instead of using this helper. Remove the parameter, or use it in the ragged section to reduce the duplicated design construction.

♻️ Proposed simplification
-  /// A one-sample design over `@p` paths, optionally omitting one (path, label) row.
-  ExperimentalDesign makeDesign(const std::vector<std::string>& paths, int omit_row = -1)
+  /// A one-sample design over `@p` paths.
+  ExperimentalDesign makeDesign(const std::vector<std::string>& paths)
   {
     ExperimentalDesign::MSFileSection section;
     for (Size m = 0; m < paths.size(); ++m)
     {
-      if (static_cast<int>(m) == omit_row) { continue; }
       ExperimentalDesign::MSFileSectionEntry e;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/class_tests/openms/source/QPXCollectionExport_test.cpp` around
lines 99 - 120, Remove the unused omit_row parameter from makeDesign and its
conditional skip logic, since all callers provide only paths and the
ragged-design construction is separate. Keep the existing design-building
behavior unchanged for the remaining call sites.
src/openms/source/FORMAT/QPXCollectionExport.cpp (1)

43-54: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Avoid copying all PSMs for requireResolvableMergeIndices in this preflight.

IsobaricWorkflow passes QPXFile::exportToParquetStreaming its existing std::vector<const PeptideIdentification*>, but this block copies every assigned and unassigned PeptideIdentification into PeptideIdentificationList before passing it to QPXFile::requireResolvableMergeIndices. Add/use a public pointer-based merge-index validation overload that delegates to the existing pointer overload, so the preflight can reject unexportable inputs without duplicating millions of PSMs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/source/FORMAT/QPXCollectionExport.cpp` around lines 43 - 54,
Update the preflight block in QPXCollectionExport to avoid constructing and
populating the copied PeptideIdentificationList; expose or reuse a public
pointer-based requireResolvableMergeIndices overload matching IsobaricWorkflow’s
std::vector<const PeptideIdentification*> input, delegate it to the existing
pointer validation, and pass collected peptide-identification pointers through
the preflight while preserving validation of assigned and unassigned entries.
src/tests/topp/CMakeLists.txt (1)

1012-1017: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding an output check for TOPP_IsobaricWorkflow_1.

TOPP_IsobaricWorkflow_1 runs the tool and writes IsobaricWorkflow_1_output.tmp.consensusXML, but no test compares that output. The test therefore only asserts a zero exit code. A FuzzyDiff check against a committed reference would catch quantification regressions in the iTRAQ4plex path.

TOPP_IsobaricWorkflow_2_no_preceding_ms1 is a crash regression guard, so a bare run is sufficient there.

♻️ Sketch of the added check
          -out ${TESTS_TEMP_DIR}/IsobaricWorkflow_1_output.tmp.consensusXML
          -out_mzTab ${TESTS_TEMP_DIR}/IsobaricWorkflow_1_output.tmp.mzTab)
+add_test("TOPP_IsobaricWorkflow_1_out1" ${DIFF} -whitelist "id=" "<map" "?xml-stylesheet"
+         -in1 ${TESTS_TEMP_DIR}/IsobaricWorkflow_1_output.tmp.consensusXML
+         -in2 ${DATA_DIR_TOPP}/IsobaricWorkflow_1_output.consensusXML)
+set_tests_properties("TOPP_IsobaricWorkflow_1_out1" PROPERTIES DEPENDS "TOPP_IsobaricWorkflow_1")

As per coding guidelines "TOPP tests must be registered in src/tests/topp/CMakeLists.txt; use small test data and FuzzyDiff for numeric comparisons."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/topp/CMakeLists.txt` around lines 1012 - 1017, Extend the
TOPP_IsobaricWorkflow_1 registration in CMakeLists.txt with a FuzzyDiff output
comparison for IsobaricWorkflow_1_output.tmp.consensusXML against a committed
reference file, while leaving TOPP_IsobaricWorkflow_2_no_preceding_ms1 as a
run-only crash regression test.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openms/source/FORMAT/ConsensusMapArrowExport.cpp`:
- Around line 1326-1333: Reject duplicate ProteinIdentification::getIdentifier()
values before constructing any run mapper. In
ConsensusMapArrowExport::requireResolvableIdRuns, perform the uniqueness
validation before mapper.create(); apply the same preflight validation in
QPXFile.cpp before buildRunMapper() processes PSM merge indices. Update both
src/openms/source/FORMAT/ConsensusMapArrowExport.cpp:1326-1333 and
src/openms/source/FORMAT/QPXFile.cpp:145-150; preserve existing validation
behavior for unique identifiers.

---

Nitpick comments:
In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 554-570: Apply the same null-versus-empty encoding rule used for
intensities to additional_intensities: update the quantified overload to append
null when its channel map is empty, while preserving the nested list output for
non-empty values and matching the identification-only overload.

In `@src/openms/source/FORMAT/QPXCollectionExport.cpp`:
- Around line 43-54: Update the preflight block in QPXCollectionExport to avoid
constructing and populating the copied PeptideIdentificationList; expose or
reuse a public pointer-based requireResolvableMergeIndices overload matching
IsobaricWorkflow’s std::vector<const PeptideIdentification*> input, delegate it
to the existing pointer validation, and pass collected peptide-identification
pointers through the preflight while preserving validation of assigned and
unassigned entries.

In `@src/tests/class_tests/openms/source/QPXCollectionExport_test.cpp`:
- Around line 99-120: Remove the unused omit_row parameter from makeDesign and
its conditional skip logic, since all callers provide only paths and the
ragged-design construction is separate. Keep the existing design-building
behavior unchanged for the remaining call sites.

In `@src/tests/topp/CMakeLists.txt`:
- Around line 1012-1017: Extend the TOPP_IsobaricWorkflow_1 registration in
CMakeLists.txt with a FuzzyDiff output comparison for
IsobaricWorkflow_1_output.tmp.consensusXML against a committed reference file,
while leaving TOPP_IsobaricWorkflow_2_no_preceding_ms1 as a run-only crash
regression test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 27e58d88-276b-49c8-b29e-92be84364469

📥 Commits

Reviewing files that changed from the base of the PR and between 552802a and 78b2988.

📒 Files selected for processing (29)
  • CHANGELOG
  • src/openms/include/OpenMS/FORMAT/ArrowSchemaRegistry.h
  • src/openms/include/OpenMS/FORMAT/ConsensusMapArrowExport.h
  • src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport.h
  • src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.h
  • src/openms/include/OpenMS/FORMAT/QPXCollectionExport.h
  • src/openms/include/OpenMS/FORMAT/QPXFile.h
  • src/openms/include/OpenMS/FORMAT/sources.cmake
  • src/openms/source/FORMAT/ArrowIOHelpers.cpp
  • src/openms/source/FORMAT/ArrowSchemaRegistry.cpp
  • src/openms/source/FORMAT/ConsensusMapArrowExport.cpp
  • src/openms/source/FORMAT/ProteinGroupArrowExport.cpp
  • src/openms/source/FORMAT/QPXCollectionExport.cpp
  • src/openms/source/FORMAT/QPXFile.cpp
  • src/openms/source/FORMAT/sources.cmake
  • src/pyOpenMS/pyopenms/addons/consensusmap.py
  • src/pyOpenMS/pyopenms/addons/peptideidentificationlist.py
  • src/pyOpenMS/tests/unittests/test_feature_dataframe.py
  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/ArrowIOHelpers_test.cpp
  • src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp
  • src/tests/class_tests/openms/source/QPXCollectionExport_test.cpp
  • src/tests/class_tests/openms/source/QPXFile_test.cpp
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/IsobaricWorkflow_1_input.idXML
  • src/tests/topp/IsobaricWorkflow_2_input.idXML
  • src/topp/IsobaricWorkflow.cpp
  • src/topp/ProteinQuantifier.cpp
  • src/topp/ProteomicsLFQ.cpp

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

Confirmed findings (deduped)

  1. requireExportable() misses the pg view's empty-groups refusal — real partial collection QPXCollectionExport.cpp:97
    The only pg-group loop is guarded by if (!getProteinIdentifications().empty()) and iterates getIndistinguishableProteins(); both empty cases fall through to return true. ProteinGroupArrowExport.cpp:177-181 and :190-194 refuse both. ProteomicsLFQ (:1882) and IsobaricWorkflow (:964) guard earlier — ProteinQuantifier does not: -protein_groups is optional (ProteinQuantifier.cpp:340), its empty-groups throw only fires when that flag is given (:1113), and :1026 inserts a default-constructed proteins_ at index 0. Reviewer reproduced it against your build:
    $ ProteinQuantifier -test -in pq_noids.consensusXML -out out.csv -out_qpx pq_noids ...
    ProteinGroupArrowExport: No indistinguishable protein groups found
    EXIT=5
    $ ls pq_noids → quantms.feature.parquet quantms.psm.parquet (pg.parquet missing)
    Not a regression (pre-PR did the same), but it's the exact outcome the new class exists to prevent, and it's uncovered by QPXCollectionExport_test.cpp.

  2. Three of the refusals have no test — which contradicts the PR description's "Every new refusal was probe-verified":

  • duplicatedSample() — the section that looks like it covers it (ProteinGroupArrowExport_test.cpp:773, "a sample reused across units is refused") actually fires ambiguousLabel(): the shared REF sample merges both plexes into one component, then label 2 disagrees (S0 vs S1). TEST_EQUAL(..., nullptr) can't tell the two apart. The real shape (one run, two labels → same sample) is realistic for SDRF-derived designs, where two channels sharing a source name collapse to one Sample.
  • inconsistent() (ProteinGroupArrowExport.cpp:292) — no test constructs two rows with equal (path, label) and differing sample.
  • out-of-range sample index (ProteinGroupArrowExport.cpp:781) — delete the guard and (*abundances)[7] is an OOB read on a 1-element array; nothing goes red.
  1. @throw in QPXCollectionExport.h:66 is inaccurate — it documents Exception::InvalidValue if two identification runs share an identifier, but nothing in the body checks that; the feature writer does. Either hoist the check or drop the line.

  2. The preflight deep-copies every PeptideIdentification (QPXCollectionExport.cpp:44) — flagged independently by two dimensions and by CodeRabbit. In IsobaricWorkflow this lands 3 lines before the comment at :1010-1013 that says it is "avoiding deep-copying millions of PeptideIdentifications". Fix: add a pointer-taking requireResolvableMergeIndices overload — the private impl already exists at QPXFile.cpp:134.

  3. Contested (verifiers split): per-channel sample-index bounds check missing from the preflight (:111) — one verifier says the shape isn't constructible via MSFileSectionEntry; and whether the exit-code-only TOPP_IsobaricWorkflow_1/_2 tests are a defe

timosachsenberg commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Consolidated independent review

Verdict: request changes; do not merge yet. I reviewed the current head (78b29887b7073f099a5d535bddbf49a826799f76) independently and consolidated the earlier partial review with the additional findings below.

Target contract: OpenMS is targeting the active, unreleased QPX 1.1 development line on bigbio/qpx's dev branch, not the intermediate layout currently on main. bigbio/qpx#224 targeted dev, was merged there by ypriverol, and dev still points exactly at its merge commit (381986f5); no revert occurred.

Blockers

  1. The emitted pg table is incompatible with the active QPX 1.1 schema on dev.

    The PR stamps every table with qpx_version=1.1, but QPXPgSchema::schema() still emits the intermediate nested intensities: list<struct<label, intensity>> representation and treats (anchor_protein, grouped_runs) as the primary key.

    bigbio/qpx#224 was merged into dev on August 2, before this PR was opened, and finalized pg 1.1 as one row per label, with scalar nullable label and intensity, and primary key (anchor_protein, grouped_runs, label). See the current dev schema and pg specification.

    This is not merely a difference between two readable 1.1 shapes: the QPX dev compatibility guard explicitly rejects grouped_runs plus the nested intensities list as a pre-flatten 1.1 layout. QPX main still carries that intermediate mzML.gz files are not recognized as correct input [220] #220 shape, but it is not the target contract for this OpenMS work.

    As written, OpenMS therefore produces files stamped QPX 1.1 that the active QPX 1.1 development reader rejects. The schema, row-melting logic, duplicate-key checks, and tests need to be updated together and validated against the dev QPX validator.

  2. The quantification grain conflicts with the active dev grouped_runs contract.

    QuantificationUnits deliberately groups runs as connected components of run/sample incidence and explicitly does not use OpenMS fraction_group (ProteinGroupArrowExport_impl.h:51-74). The merged QPX dev change instead defines OpenMS fraction_group as the source of grouped_runs.

    This is not a mechanical regrouping: PeptideAndProteinQuant's current abundances aggregate by sample across all files/fractions/channels, so they cannot be split after the fact into quantities at the required (fraction_group, label) grain. The quantity must be calculated or preserved at that grain upstream. The current connected-component model also explains the refusal/misrepresentation risk around shared-reference plexes and technical replicates.

Major correctness and contract issues

  1. The collection preflight can still allow partial output.

    • If there are no protein identifications, or the first identification has no indistinguishable groups, QPXCollectionExport::requireExportable() reaches return true because its group loop is guarded by !getProteinIdentifications().empty() (QPXCollectionExport.cpp:97-122). The pg exporter later refuses both cases (ProteinGroupArrowExport.cpp:177-194). This independently confirms the partial-collection case reproduced in the earlier comment.
    • The preflight only compares abundance-array length with design.getNumberOfSamples(); it does not validate each channel.sample index. That shape is constructible through the public ExperimentalDesign setters. The pg exporter catches it later at ProteinGroupArrowExport.cpp:781, after preceding views may already have been written.
  2. The preflight deep-copies every PSM.

    QPXCollectionExport.cpp:39-53 materializes a new PeptideIdentificationList. For IsobaricWorkflow, this defeats the pointer-based streaming path specifically intended to avoid copying millions of identifications (IsobaricWorkflow.cpp:1010) and creates an avoidable OOM risk before export. Add/use a pointer-taking requireResolvableMergeIndices overload; the private pointer implementation already exists in QPXFile.cpp:134.

  3. Conflicting labels across runs are warned about and silently coerced.

    QuantificationUnits::resolveLabels() logs a warning and keeps the first run's label when another run in the unit names the channel differently (ProteinGroupArrowExport_impl.h:258-275). A grouped row must resolve consistently through every run it names; choosing one label makes the output arbitrary. This should be a refusal.

  4. Duplicate protein-identification identifiers are not rejected by the public preflights.

    ConsensusMapArrowExport::requireResolvableIdRuns() catches the mapper's Exception::InvalidValue for duplicate identifiers and continues (ConsensusMapArrowExport.cpp:1326-1333). The actual feature writer rejects them before opening its file, so the public preflight contract and the new @throws documentation are inaccurate. Reject them in preflight or remove the documented promise.

Test and documentation gaps

  • The test beginning at ProteinGroupArrowExport_test.cpp:773, described as covering a sample reused across units, actually reaches the ambiguous-label condition because the shared reference merges the plexes into one component. It does not exercise duplicatedSample().
  • There are no focused tests for conflicting duplicate design cells or an out-of-range sample index.
  • The new QPX TOPP integration tests check only that files exist; they do not validate their schemas with the upstream QPX validator, which is why the primary blocker is invisible.
  • The five newly added Doxygen @throw tags should be @throws (or @exception) per OpenMS style.

Confirmed good changes

  • The missing-preceding-MS1 guard in IsobaricWorkflow looks correct, and the regression fixture genuinely starts with an MS2 spectrum.
  • The feature_counts.total_features correction is internally consistent with the feature view's one-row-per-(feature, run) melting.

I did not count the additional_intensities empty-vs-null behavior as a regression; blame shows that it predates this PR.

Validation performed without a local build, per the repository instructions: git diff --check passed, and both newly added idXML fixtures passed xmllint.

timosachsenberg and others added 3 commits August 3, 2026 16:06
…#9817)

bigbio/qpx#220 (merged) defines QPX format 1.1. The protein-group view drops the
scalar required column run_file_name and gains grouped_runs (list<string>); the
primary key becomes [anchor_protein, grouped_runs], and every QPX view declares
qpx_version 1.1. The psm and feature views are otherwise unchanged by 1.1 and
keep their scalar run_file_name.

This is a change of GRAIN, not a rename. A pg row used to carry a per-file cell
from the group's file_channel_level_abundance array; it now carries the
SAMPLE-level value from the array PeptideAndProteinQuant names "abundances". The
two are not interchangeable: the quantifier accumulates
total_abundances[sample] += abundance over every fraction, file, charge and
channel of a sample, while the per-file cells aggregate within a file, so summing
them does not reproduce the sample value. Measured on the shipped BSA fixture,
summing BSA1's two per-file cells gives 304,924,936 against a true 214,289,808;
the export now emits 214,289,808.

A quantification unit is a CONNECTED COMPONENT of the (run, sample) incidence:
two runs join as soon as they share one sample, transitively. That is the weakest
grouping under which no sample straddles two units, which is what makes the
spec's "(any file in grouped_runs, label) -> run.samples[]" well defined. It is
deliberately neither of the two obvious alternatives:

  * the design's fraction_group --
    share/OpenMS/examples/FRACTIONS/BSA_design_onetable_nonconsec.tsv puts
    BSA1_F1 in fraction group 1 and BSA1_F2 in fraction group 4 while both are
    sample BSA1, so that key emits one sample's quantity twice under two keys;
  * equality of a run's whole (label -> sample) map -- OpenMS accepts designs
    with missing rows on purpose (ExperimentalDesign_test.cpp: "missing fractions
    and wrong orders should work now"), and in the shipped 4-plex
    ExperimentalDesign_input_2_wrong.tsv one fraction has no label-1 row.
    Requiring equal maps splits that plex into units that then share samples,
    refusing a design the loader accepts.

ProteinGroupArrowExport gained overloads taking the ExperimentalDesign that drove
quantification: it supplies both the grouping and the sample index space the
abundances are stored under. ProteomicsLFQ, ProteinQuantifier and
IsobaricWorkflow pass theirs; the convenience overload reconstructs one with
fromConsensusMap() and is documented as best-effort. Identification-only output
(ProSE, protein inference) has no design and writes single-element lists, the
form the 1.1 schema documents for unfractionated input.

Four shapes are refused rather than guessed at, because the row cannot represent
them: a design whose sample count does not match the abundance array (it is not
the design that produced it); a label that means two different samples within one
unit (a common reference channel shared across plexes joins the plexes, and the
remaining channels then disagree about what each label means); a sample filling
two labels of one unit, whose single aggregated quantity would be published
twice; and a label mapped to a sample the sample section does not describe.
Design files the ConsensusMap has no column header for contributed nothing and
are left out of grouped_runs, which also keeps the pg run names a subset of what
psm and feature can join to.

Two adjacent corrections. feature_counts.total_features now counts (feature, run)
pairs: the feature view melts one ConsensusFeature into one row per run, so a
feature spanning two fractions of a unit is two feature rows, and counting bare
feature indices made pg disagree with feature.parquet; unique_features stays keyed
on peptidoform+charge and does not grow. And a group melted onto a run it was only
identified in wrote an empty intensities list where the identification-only
overload writes null -- one column meaning two things depending on which overload
produced the file, contradicting the code's own comment.

The ConsensusMap overload now builds its table on QPXPgSchema::schema() instead of
restating the 20 fields inline, which is what let the two definitions drift apart.

Tests: eight new sections pin the grain, the sample-vs-fraction-group unit, the
missing-design-row unit, the foreign-design refusal, the ambiguous-label refusal,
the header intersection, the feature-row count and the null-intensity convention.
Each was verified to fail against the previous behaviour before being kept. Zero
reference-file churn: the -out_qpx TOPP tests only sha256sum for existence and no
reference file contains a pg column name.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm
Preserve protein quantities at fraction-group and label grain and emit the scalar protein-group schema used by active QPX development.

Complete collection preflight and add regression coverage for schema, grouping, label resolution, and malformed annotations.
Reject duplicate identification-run identifiers in both merge-index preflight overloads and cover the value and pointer paths.

Preserve develop's safe normalization fallback for fraction-group quantities after integrating #9844.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (5)
src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.h (1)

87-192: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

The second run_in_several_groups_ check cannot trigger.

run_info stores exactly one fraction_group per run, so runs_by_fraction_group places each run in exactly one bucket. The unit_of_run_ duplicate branch at lines 184-188 is therefore unreachable; the real detection is the info.fraction_group != entry.fraction_group branch at lines 122-127. Keep the branch only if you intend it as a defensive invariant, and say so in a comment; otherwise remove it to avoid suggesting two independent detections exist.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.h` around lines
87 - 192, Remove the unreachable duplicate check around unit_of_run_.emplace in
the fraction-group construction, since each run is already assigned to one
bucket by run_info and runs_by_fraction_group. Retain the existing detection in
the info.fraction_group != entry.fraction_group branch as the sole
fraction-group inconsistency check.
src/openms/source/FORMAT/ProteinGroupArrowExport.cpp (2)

493-499: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Make the label/intensity pairing explicit in emitRow.

The signature accepts label and intensity as independent optionals, but the append logic branches on label alone and dereferences *intensity in the else branch. A future caller that passes a label without an intensity dereferences an empty optional, which is undefined behavior. Both current call sites pass the two together (lines 833 and 860), so this is a latent hazard rather than a live defect. Pass one std::optional<std::pair<std::string, float>>, or assert the invariant.

🛡️ Minimal defensive change
     else
     {
+      OPENMS_PRECONDITION(intensity.has_value(),
+                          "a labelled pg row must carry an intensity");
       (void)label_builder.Append(*label);
       (void)intensity_builder.Append(*intensity);
     }

Also applies to: 559-573

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp` around lines 493 - 499,
Update the emitRow lambda to make label and intensity a single paired optional,
or explicitly validate that both independent optionals are present together
before dereferencing. Adjust the append logic and both current call sites to
preserve the existing labeled-quantity behavior while preventing an empty
intensity from being accessed when a label is provided.

741-745: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer \n over std::endl in the new log statements.

The new and modified diagnostics in this file end with std::endl, which forces a stream flush on every message. The surrounding code uses the same style, so this is a consistency question rather than a defect; apply it to the changed lines if you touch them.

As per coding guidelines, "Prefer \n over std::endl".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp` around lines 741 - 745,
Update the new diagnostic in the channel-label handling logic near the visible
ProteinGroupArrowExport error log to terminate the message with "\n" instead of
std::endl, avoiding a forced flush while preserving the existing message and
return behavior.

Source: Coding guidelines

src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h (1)

448-471: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document the thrown exceptions with @throws.

buildSampleIDLookup_() throws Exception::MissingInformation for invalid samples, conflicting cells, conflicting run fraction groups, and ambiguous fraction-group labels (see PeptideAndProteinQuant.cpp lines 192-229). getSampleIDFromFilenameAndChannel_() propagates the throw of getDesignCellFromFilenameAndChannel_(). Both descriptions state the rejection in prose only. Add explicit tags so the documented exceptions match the required Doxygen form.

As per coding guidelines, "documented exceptions should use @throws or @exception".

📝 Proposed documentation change
          Maps each (basename without extension, channel/label) of the MS file section to its
          sample and fraction group. Conflicting duplicate cells and fraction-group labels that
          resolve to different samples are rejected. Called whenever the experimental design is
          (re)set.
+
+         `@throws` Exception::MissingInformation if a design cell refers to a sample outside the
+                 sample section, or if duplicate cells, run fraction groups, or fraction-group
+                 labels conflict
     */
     void buildSampleIDLookup_();
@@
-    /// Map (filename, channel) to sample using the precomputed design-cell lookup.
+    /**
+         `@brief` Map (filename, channel) to sample using the precomputed design-cell lookup.
+
+         `@param`[in] filename The base filename (without path/extension)
+         `@param`[in] channel_or_label The channel/label identifier
+         `@return` The sample of the design cell
+         `@throws` Exception::MissingInformation if the (filename, channel) pair is not in the
+                 experimental design
+    */
     Size getSampleIDFromFilenameAndChannel_(const std::string& filename,
                                             UInt channel_or_label) const;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h`
around lines 448 - 471, Update the Doxygen comments for buildSampleIDLookup_()
and getSampleIDFromFilenameAndChannel_() to add explicit `@throws`
Exception::MissingInformation entries. Describe that buildSampleIDLookup_()
throws for invalid or conflicting design cells, fraction groups, or ambiguous
labels, and that getSampleIDFromFilenameAndChannel_() propagates the exception
from getDesignCellFromFilenameAndChannel_().

Source: Coding guidelines

src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp (1)

510-510: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add negative coverage for the new design validations.

buildSampleIDLookup_() now rejects four distinct malformed designs: a sample index outside the sample section, conflicting (run, label) cells, one run in two fraction groups, and one fraction-group label resolving to two samples (PeptideAndProteinQuant.cpp lines 192-229). No section exercises those throws. The existing file already uses TEST_EXCEPTION(Exception::MissingInformation, ...) at line 179, so each case is a short addition.

As per coding guidelines, "Write unit tests for new functionality".

Also applies to: 535-535, 545-547

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp` at line
510, Extend the existing PeptideAndProteinQuant design-validation tests around
buildSampleIDLookup_() with four negative cases: an out-of-range sample index,
conflicting (run, label) cells, a run assigned to multiple fraction groups, and
a fraction-group label resolving to multiple samples. Use the established
TEST_EXCEPTION(Exception::MissingInformation, ...) pattern and minimal malformed
design fixtures, asserting each case throws the expected validation exception.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.h`:
- Around line 286-350: Update fractionGroupAbundances to reject fraction-group
keys less than or equal to zero, matching the existing 1-based validation for
labels. Keep the current key conversion and duplicate detection unchanged, and
revise the validation error text to state that both fraction-group and label
keys must be 1-based.

In `@src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp`:
- Around line 930-935: Update
PeptideAndProteinQuant::annotateQuantificationsToProteins() so QPX quantity
arrays are populated only for (fraction_group, label) pairs retained by
QuantificationUnits, excluding design runs without ConsensusMap column headers.
Ensure emitted annotation keys match
ProteinGroupArrowExport::expected_quantity_keys rather than relying on all
ExperimentalDesign::MSFileSection entries.

In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 748-836: Extract the duplicated exportability checks from the
protein-group loop and QPXCollectionExport::requireExportable into a shared
helper in ProteinGroupArrowExport_impl.h that returns a diagnostic string. The
helper must validate quantities.valid, sample-abundance count, sample-only
annotations, empty units, expected key count, and every required
fraction-group/label lookup in that order. Update both call sites to invoke the
helper and format its returned diagnostic consistently, preserving their
existing success behavior and aborting when a diagnostic is present.

---

Nitpick comments:
In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h`:
- Around line 448-471: Update the Doxygen comments for buildSampleIDLookup_()
and getSampleIDFromFilenameAndChannel_() to add explicit `@throws`
Exception::MissingInformation entries. Describe that buildSampleIDLookup_()
throws for invalid or conflicting design cells, fraction groups, or ambiguous
labels, and that getSampleIDFromFilenameAndChannel_() propagates the exception
from getDesignCellFromFilenameAndChannel_().

In `@src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.h`:
- Around line 87-192: Remove the unreachable duplicate check around
unit_of_run_.emplace in the fraction-group construction, since each run is
already assigned to one bucket by run_info and runs_by_fraction_group. Retain
the existing detection in the info.fraction_group != entry.fraction_group branch
as the sole fraction-group inconsistency check.

In `@src/openms/source/FORMAT/ProteinGroupArrowExport.cpp`:
- Around line 493-499: Update the emitRow lambda to make label and intensity a
single paired optional, or explicitly validate that both independent optionals
are present together before dereferencing. Adjust the append logic and both
current call sites to preserve the existing labeled-quantity behavior while
preventing an empty intensity from being accessed when a label is provided.
- Around line 741-745: Update the new diagnostic in the channel-label handling
logic near the visible ProteinGroupArrowExport error log to terminate the
message with "\n" instead of std::endl, avoiding a forced flush while preserving
the existing message and return behavior.

In `@src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp`:
- Line 510: Extend the existing PeptideAndProteinQuant design-validation tests
around buildSampleIDLookup_() with four negative cases: an out-of-range sample
index, conflicting (run, label) cells, a run assigned to multiple fraction
groups, and a fraction-group label resolving to multiple samples. Use the
established TEST_EXCEPTION(Exception::MissingInformation, ...) pattern and
minimal malformed design fixtures, asserting each case throws the expected
validation exception.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b0518b28-754e-4d80-aaf8-460f0035f6f3

📥 Commits

Reviewing files that changed from the base of the PR and between 78b2988 and aea3ca5.

📒 Files selected for processing (21)
  • CHANGELOG
  • src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h
  • src/openms/include/OpenMS/FORMAT/ArrowSchemaRegistry.h
  • src/openms/include/OpenMS/FORMAT/ConsensusMapArrowExport.h
  • src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport.h
  • src/openms/include/OpenMS/FORMAT/ProteinGroupArrowExport_impl.h
  • src/openms/include/OpenMS/FORMAT/QPXCollectionExport.h
  • src/openms/include/OpenMS/FORMAT/QPXFile.h
  • src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp
  • src/openms/source/FORMAT/ArrowSchemaRegistry.cpp
  • src/openms/source/FORMAT/ConsensusMapArrowExport.cpp
  • src/openms/source/FORMAT/ProteinGroupArrowExport.cpp
  • src/openms/source/FORMAT/QPXCollectionExport.cpp
  • src/openms/source/FORMAT/QPXFile.cpp
  • src/pyOpenMS/bindings/bind_analysis.cpp
  • src/pyOpenMS/tests/unittests/test_PeptideAndProteinQuant.py
  • src/tests/class_tests/openms/source/ArrowSchemaRegistry_test.cpp
  • src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp
  • src/tests/class_tests/openms/source/ProteinGroupArrowExport_test.cpp
  • src/tests/class_tests/openms/source/QPXCollectionExport_test.cpp
  • src/tests/class_tests/openms/source/QPXFile_test.cpp
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/openms/include/OpenMS/FORMAT/QPXCollectionExport.h
  • src/openms/include/OpenMS/FORMAT/ConsensusMapArrowExport.h
  • src/openms/source/FORMAT/QPXFile.cpp
  • src/openms/include/OpenMS/FORMAT/ArrowSchemaRegistry.h
  • src/openms/source/FORMAT/QPXCollectionExport.cpp
  • CHANGELOG
  • src/openms/source/FORMAT/ConsensusMapArrowExport.cpp

@timosachsenberg
timosachsenberg force-pushed the qpx-1.1-pg-grouped-runs branch from aea3ca5 to 022878a Compare August 3, 2026 14:11
Use the design-cell lookup introduced by the QPX fraction-group work when naming samples without positive abundance.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h (1)

455-477: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the full exception contract for the lookup methods.

buildSampleIDLookup_() can throw Exception::MissingInformation for invalid sample indices, conflicting duplicate cells, conflicting run/fraction-group assignments, and conflicting (fraction_group, label) sample mappings. The current documentation lists only some conflicts and has no @throws tag.

getSampleIDFromFilenameAndChannel_() delegates to getDesignCellFromFilenameAndChannel_(), so it can also throw Exception::MissingInformation. Document that exception at the declaration.

As per coding guidelines, possible exceptions must be documented with @throws or @exception.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h`
around lines 455 - 477, Add complete `@throws Exception::MissingInformation`
documentation to buildSampleIDLookup_() that covers all exception cases: invalid
sample indices, conflicting duplicate cells, conflicting run/fraction-group
assignments, and conflicting (fraction_group, label) sample mappings.
Additionally, add `@throws Exception::MissingInformation` documentation to
getSampleIDFromFilenameAndChannel_() to document that it can throw the exception
because it delegates to getDesignCellFromFilenameAndChannel_(), which already
documents this exception.

Source: Coding guidelines

🧹 Nitpick comments (1)
src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h (1)

43-45: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the required Doxygen block form for the new declarations.

The added /// comments do not contain the required @brief tags. The getSampleIDFromFilenameAndChannel_ comment also lacks @param[in] tags. Convert these new comments to /** ... */ blocks.

Example
-    /// Mapping: experimental-design fraction group -> label/channel -> abundance
+    /** `@brief` Mapping from experimental-design fraction groups to label/channel abundances. */

As per coding guidelines, Doxygen comments must use /** */ with @ tags, and @brief is required.

Also applies to: 58-60, 83-85, 97-99, 229-235, 265-268, 475-477

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h`
around lines 43 - 45, Convert all newly added Doxygen comments in the
declarations, including FractionGroupAbundances and
getSampleIDFromFilenameAndChannel_, from /// form to /** ... */ blocks. Add an
`@brief` tag to each block, and add `@param`[in] tags for every input parameter of
getSampleIDFromFilenameAndChannel_; apply the same required format to the other
referenced declarations.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h`:
- Around line 455-477: Add complete `@throws Exception::MissingInformation`
documentation to buildSampleIDLookup_() that covers all exception cases: invalid
sample indices, conflicting duplicate cells, conflicting run/fraction-group
assignments, and conflicting (fraction_group, label) sample mappings.
Additionally, add `@throws Exception::MissingInformation` documentation to
getSampleIDFromFilenameAndChannel_() to document that it can throw the exception
because it delegates to getDesignCellFromFilenameAndChannel_(), which already
documents this exception.

---

Nitpick comments:
In `@src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h`:
- Around line 43-45: Convert all newly added Doxygen comments in the
declarations, including FractionGroupAbundances and
getSampleIDFromFilenameAndChannel_, from /// form to /** ... */ blocks. Add an
`@brief` tag to each block, and add `@param`[in] tags for every input parameter of
getSampleIDFromFilenameAndChannel_; apply the same required format to the other
referenced declarations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 39c03d5e-86d4-4d58-8d3c-011b2c6682b9

📥 Commits

Reviewing files that changed from the base of the PR and between fea7288 and 7db86b5.

📒 Files selected for processing (3)
  • src/openms/include/OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h
  • src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp
  • src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/tests/class_tests/openms/source/PeptideAndProteinQuant_test.cpp
  • src/openms/source/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.cpp

@timosachsenberg timosachsenberg mentioned this pull request Aug 3, 2026
8 of 11 tasks
Centralize the protein-group annotation contract so preflight and export cannot drift. Document design lookup exceptions and cover each malformed-design rejection.
@timosachsenberg

Copy link
Copy Markdown
Contributor Author

first part of qpx 1.1 (WIP) support. This needs a bit of back and forth because we need to adapt between sdrf, qpx, OpenMS and other qpx enabled workflows

@timosachsenberg
timosachsenberg merged commit 6035f07 into develop Aug 3, 2026
11 checks passed
@timosachsenberg
timosachsenberg deleted the qpx-1.1-pg-grouped-runs branch August 3, 2026 16:38
timosachsenberg added a commit that referenced this pull request Aug 4, 2026
…e a partial collection (#9849)

* [FIX,TEST] QPX: separate unmapped features, never leave a partial collection

Three defects in the QPX export contract added by #9846/#9843, found reviewing
#9847. Tightening the contract is fine where the producers can satisfy it; these
are cases where they cannot, or where the enforcement is not clean.

1. Feature primary key refused maps OpenMS itself produces.
   The key is (peptidoform, charge, run_file_name, rt). QPX permits unmapped
   features and ConsensusMapArrowExport writes them with an empty peptidoform, so
   for those rows the key collapses to (charge, run_file_name, rt) - and 'rt' is
   narrowed to float32 on write, one ULP being 244 us at 3000 s. Two co-eluting
   unmapped features of the same charge in one run then share a key although they
   are plainly different features, and the whole table is refused.
   Not a corner case for the tools that write QPX: ProteomicsLFQ with seeds
   leaves 79 % of the ProteomicsLFQ_3 fixture's consensus features unidentified,
   and a real run carries tens of thousands, where the birthday bound over the
   ~2.2e7 representable float32 retention times makes a collision expected. The
   only ProteomicsLFQ QPX test uses the unseeded configuration, whose features are
   all identified, so nothing exercised it.
   'observed_mz' - written one column over, previously excluded - joins the key.
   Genuine duplicates (same run, charge, rt AND m/z) are still refused.

2. A refused collection left its earlier files behind.
   requireExportable() catches everything decidable from the input, but a view can
   still refuse a row it only sees while building its table, and a write can fail
   on I/O; by then quantms.feature.parquet is on disk, and a directory holding it
   without a PSM file is indistinguishable from a complete export of a smaller
   dataset. New QPXCollectionExport::Transaction scope guard: constructed before
   the first write, committed after the last, and on any other exit - a view
   returning false, a writer throwing, an early return - it removes every
   collection file present. Used by ProteinQuantifier, ProteomicsLFQ and
   IsobaricWorkflow. Guarding the scope rather than enumerating the failure sites
   covers the next refusal mode without anyone having to remember it.

3. QPXFile::exportToParquetStreaming() left a truncated PSM file.
   One validator spans all batches so it can fail on a late one, and the writer
   and sink are closed regardless, so the footer is written and the file reads as
   a valid, merely smaller, PSM table. It is now removed, matching what
   ConsensusMapArrowExport's streaming writer already did for the same situation.

Each fix ships with a test that was confirmed to fail without it: the feature-key
section fails at the validate() of two co-eluting unmapped features, and the
streaming section at TEST_FALSE(File::exists(duplicate_file)).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ

* [DOC,TEST] QPX: record the input contract once, and test the validator directly

Documentation and tests only; no behaviour change.

The QPX input contract was not written down anywhere a user could find it: the
tools that offer -out_qpx just fail with UnableToCreateFile, and the four
requirements a foreign consensus map can miss (a scan per identification, a
resolvable origin file, uniqueness per (peptidoform, charge, run, scan), and a
channel label from the QPX vocabulary) were only discoverable by reading
QPXValueValidation. It is now stated on that class - the code that enforces it,
so it cannot drift - and nowhere else. ProteinQuantifier's -out_qpx parameter and
its documentation page point there rather than restating it, naming ProteomicsLFQ
and IsobaricWorkflow as the producers that satisfy the contract by construction.

QPXValueValidation had no test file of its own although every sibling QPX class
has one, and it is a 600-line OPENMS_DLLAPI class that decides whether an export
happens at all. QPXValueValidation_test covers all three views: the psm view's
empty-scan, empty/blank run_file_name and duplicate-key refusals, the feature
view's separation of unmapped rows by observed_mz and its non-finite coordinate
refusals, the documented statefulness (a validator spans batches so a key
repeated after a batch boundary is caught; a rejected batch does not advance the
key state; reset() starts a new file), the schema-mismatch path, multi-chunk
columns, null and 0-row tables, and Result::toString().

The invalid inputs are built through the exporters rather than by patching
columns, so each section exercises a shape a producer really emits - an
identification without a spectrum reference, or the one-MS2-on-two-features
duplication IDMapper creates.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ

* [FIX,TEST] Transaction must not delete a collection that predates it

Addresses the CodeRabbit review on #9849.

The scope guard removed every collection file in the output directory on a failed
export, including files that were already there. Re-running a pipeline into the
same -out_qpx directory is the normal case, so a failed re-run destroyed the
previous, complete result. The test encoded that behaviour by creating its stub
files before constructing the guard.

The guard now records which of the three files exist at construction and removes
only the ones this export created. A run that fails after overwriting a
pre-existing file still leaves the directory mixing two exports - that cannot be
undone without staging - so the destructor names the surviving files in a warning
instead of letting the directory look coherent. The test creates its files inside
the guard's lifetime, as an export does, and gains coverage that a failed export
preserves a complete previous collection; that assertion fails without the fix.

Also from the same review:
- QPXFile and ConsensusMapArrowExport left a zero-byte .parquet behind when
  parquet::arrow::FileWriter::Open failed: arrow::io::FileOutputStream::Open had
  already created and truncated the file, and this early return happens before
  the close-and-remove block that covers every later failure. Both now close and
  remove it. (ConsensusMapArrowExport is not otherwise part of this PR's changes,
  but the two writers are deliberately symmetric here.)
- Doxygen: the Transaction constructor, destructor and commit() use /** */ with
  @brief, and the constructor documents @PARAM[in] directory.
- Style: braces on their own aligned lines, and '\n' instead of std::endl in the
  new logging.

Verified end to end: a failed export into a fresh directory still leaves it
empty, and a failed export into a directory holding a previous collection leaves
all three of its files in place with the warning.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ

* [FIX] Link QPXValueValidation_test against Arrow

Fixes the windows-2025/cl.exe build failure on this branch: 37 LNK2019s, all
unresolved __declspec(dllimport) arrow:: symbols, on
QPXValueValidation_test.exe.

The test was added to executables.cmake without the matching
target_link_libraries(... ${OPENMS_ARROW_TARGET} ${OPENMS_PARQUET_TARGET}) that
every other Arrow-using class test carries. It builds its invalid inputs with
arrow::FloatBuilder and ArrayData::Make rather than through the exporters -
deliberately, so each section exercises a shape a producer really emits - so it
needs Arrow itself, not just what OpenMS re-exports. On Linux/macOS libOpenMS
statically links Arrow and re-exports its symbols, so the link happens to
succeed; on Windows they are dllimport and nothing satisfies them.

QPXCollectionExport_test, added alongside it, uses no Arrow type and correctly
stays unlinked.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ

* [FIX,TEST] Remove the partial file when a one-shot Parquet write fails

This PR taught both streaming writers to clean up after themselves, but the
one-shot writers next to them still leak. arrow::io::FileOutputStream::Open
creates and truncates the file before the table is written, so a write that
fails afterwards leaves a fragment carrying little more than the Parquet magic
bytes - no footer, so a reader reports it as corrupt rather than as the smaller
table it looks like.

Two sites, both now closing the stream and removing the file on any failure
after the open:

- ConsensusMapArrowExport::exportToParquet, directly above the streaming
  function this PR already fixed.
- ArrowIOHelpers::writeTableToParquet, the shared path behind the psm, pg,
  OpenSwath and MSExperiment exports.

ConsensusMapArrowExport::exportToParquet additionally closes explicitly instead
of leaving it to the stream's destructor, which discards the error: the final
flush is where a full disk surfaces, and that used to be reported as success
with a truncated file on disk.

Inside the three tools this was contained by QPXCollectionExport::Transaction,
which is why it did not show up as a bug; it was not contained for pyOpenMS and
library callers, or for ProSE, whose -out_qpx layout the guard cannot cover.

Each fix ships with a test confirmed to fail without it - both at the
TEST_FALSE(File::exists(...)) line, with the write failing for the intended
reason. A row group size of 0 is refused by Parquet for a non-empty table, which
reaches a post-open write failure deterministically on every platform.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ

* [TEST] Cover -out_qpx from the seeded ProteomicsLFQ configuration

The feature-key defect this PR fixes reached develop because the only
ProteomicsLFQ QPX test runs -targeted_only true, whose consensus features are
all identified: 0 of its 60 feature rows are unmapped, so nothing ever exported
the shape the key could not distinguish. The class test added here reproduces
that shape synthetically, but nothing asserts that the tool still produces it.

New TOPP_ProteomicsLFQ_qpx_seeds runs TOPP_ProteomicsLFQ_3's seeded
configuration with -out_qpx: 210 of 298 feature rows are unmapped, and all three
collection files must exist afterwards. Kept as a separate run rather than
folded into TOPP_ProteomicsLFQ_3 so no reference file is touched.

What it guards is that the shape reaches the exporter and clears it end to end.
It is not a reproducer for the float32-rt collision itself - measured on the
produced table, the pre-fix key happens not to collide at this fixture's size -
and the comment says so rather than implying more; ConsensusMapArrowExport_test
covers that directly.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ

---------

Co-authored-by: Claude Opus 5 (1M context) <[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