Skip to content

[FIX] QPX export: the feature view accepted merged runs it cannot attribute - #9835

Merged
timosachsenberg merged 2 commits into
developfrom
qpx-feature-merge-index-guard
Jul 31, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
qpx-feature-merge-index-guard

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

The QPX feature view resolves id_run_file_name through IdentifierMSRunMapper, which falls back to the run's first file when a PSM carries no id_merge_index. For a merged run the column therefore named a file the best PSM did not come from — silently, and it is precisely the column whose purpose is to record that identification and quantification happened in different runs (match-between-runs).

The psm and pg views already refuse this input; the feature view did not.

Why this is worth refusing rather than nulling

ProteomicsLFQ and ProteinQuantifier write the three views in a fixed order — feature first, psm second, pg third. Accepting the input here and refusing it in pg left a wrong feature.parquet on disk next to a half-written collection, with a non-zero exit code. Refusing in all three means the run fails before anything is written.

Implementation

A preflight (requireResolvableIdRuns), single-threaded, before any OpenMP region and before the output file is opened — the same constraint as the existing requireUnambiguousIdentities, and for the same reason: an exception escaping the parallel batch build would be flattened into a boolean by the worker's catch-all, and one escaping the region at all is std::terminate. Wired into both exportToArrow and exportToParquetStreaming.

It reuses IdentifierMSRunMapper::validateMergeIndex, so all three views now apply one implementation of the check rather than three.

Review follow-ups (second commit)

An adversarial review of the preflight itself found two defects, both fixed here:

  • It was over-scoped. It validated every identification attached to a feature, but the row draws all identification-derived values from the winning hit alone — so a feature whose winner resolves perfectly was refused because a sibling, hitless or simply not selected, lacked an index nobody asks for. It now selects the same identity the row builder does and validates only that.

  • Duplicate identification-run identifiers were accepted here though the pg exporter refuses them. The mapper's forward map assigns with operator[], so two runs sharing an identifier leave only the last one's paths and a feature of the first is stamped with a file it never came from — one row, no warning.

    Placement mattered, and the test caught getting it wrong: the check must sit outside the existing try/catch, which swallows Exception::InvalidValue. That handler exists for the mapper's duplicate-path-list throw, safe to downgrade because the forward map is still complete; a duplicate identifier is the opposite case wearing the same exception type. Inside the try, the new throw was caught and logged as a warning while the export continued on the very mapping it was meant to reject.

Known limitation

The preflight narrows the partial-collection window without closing it. Unassigned identifications do not affect feature rows, but they do reach the PSM export, which validates them and can throw after quantms.feature.parquet is already on disk. Closing that means validating the whole collection in the caller before the first write, across three TOPP tools — a separate change.

Verification

  • New class-test section asserting both directions: the refusal, and that the same input with id_merge_index=1 exports and resolves to runB.
  • Confirmed the test discriminates — with the preflight removed it reports no exception thrown!.
  • 157/157 tests (ProteomicsLFQ, ProSE, ProteinQuantifier, IsobaricAnalyzer, Arrow/QPX class tests); no reference-file churn.

Found by an adversarial review pass over the QPX export surface after #9832; the gap is in code merged earlier, not from that PR. Tracked in #9817.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DF2YUewPQTC5tJWqn23pUm

Summary by CodeRabbit

  • Bug Fixes
    • Improved ConsensusMap Arrow and Parquet export validation for merged runs.
    • Exports now reject ambiguous or incomplete identification-run mappings with clear validation errors.
    • Correctly resolves merged run information when the selected identification provides a merge index.
    • Unselected hitless identifications no longer prevent successful exports when they lack an index.

…ribute

id_run_file_name is resolved through IdentifierMSRunMapper, which falls back to
the run's FIRST file when a PSM carries no 'id_merge_index'. So for a merged run
the column named a file the best PSM did not come from -- silently, and it is
the column whose whole purpose is recording that identification and
quantification happened in different runs.

The psm and pg views already refuse this input. Matching them matters beyond
consistency: ProteomicsLFQ and ProteinQuantifier write the feature view FIRST
and pg THIRD, so accepting here and refusing there left a wrong feature.parquet
on disk beside a half-written collection. Refusing in all three means the run
fails before anything is written.

Implemented as a preflight, single-threaded before any OpenMP region and before
the output file is opened, for the same reason requireUnambiguousIdentities is
-- an exception escaping the parallel batch build would be flattened into a
boolean by the worker's catch-all, and one escaping the region is
std::terminate. Wired into both exportToArrow and exportToParquetStreaming.

Test asserts both directions: the refusal, and that the same input with
id_merge_index=1 exports and resolves to runB. Verified it discriminates --
without the preflight it reports "no exception thrown!".

153/153 TOPP tests; Arrow/QPX class tests green.

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

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The export validates identification-run mappings before Arrow and streaming Parquet output. It rejects duplicate identifiers and unresolved selected hit mappings. Tests cover missing and valid merge indices, hitless identifications, and duplicate identifiers.

Changes

Merged-run export validation

Layer / File(s) Summary
Preflight validation and export wiring
src/openms/source/FORMAT/ConsensusMapArrowExport.cpp
buildFeatureIdLookups rejects duplicate identification identifiers. requireResolvableIdRuns validates the selected best-hit identification and skips hitless features. Both export paths run validation before output generation.
Merged-run regression coverage
src/tests/class_tests/openms/source/ConsensusMapArrowExport_test.cpp
Tests cover missing id_merge_index, resolution to runB with index 1, acceptance of an unselected hitless identification, and rejection of duplicate identifiers.

Possibly related issues

Possibly related PRs

  • OpenMS/OpenMS#9660 — Uses the same IdentifierMSRunMapper and id_merge_index run-resolution logic.
  • OpenMS/OpenMS#9818 — Adds related merged-run validation in ConsensusMapArrowExport.cpp.
  • OpenMS/OpenMS#9832 — Adds related merge-index and duplicate-identification validation.

Suggested reviewers: jpfeuffer

Poem

A rabbit maps each run with care,

Checks duplicate names in the air.
Missing indices stop the way,
Index one finds runB today.
Arrow and Parquet pass the fare.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 identifies the QPX feature export fix for merged runs that cannot be attributed.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch qpx-feature-merge-index-guard

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

🤖 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 1255-1277: Update the CHANGELOG entry for merged-run rejection to
also document ConsensusMapArrowExport and quantms.feature.parquet. State that
the feature-export preflight throws Exception::MissingInformation when merged
runs lack a usable id_merge_index, while preserving the existing QPX and
consensus:annotate_ids_with_subelements coverage.
- Around line 1255-1277: Update requireResolvableIdRuns to validate only the
identification returned by selectFeatureIdentity for each ConsensusFeature,
rather than iterating every PeptideIdentification. Skip features whose handles
cannot produce output, preserving the existing feature-export behavior, and pass
the selected identification with the correct PSM index to
mapper.validateMergeIndex.
🪄 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: 396494ba-dfb8-4699-bfb3-0327bd87b5fb

📥 Commits

Reviewing files that changed from the base of the PR and between 0c0c399 and 24712ff.

📒 Files selected for processing (2)
  • src/openms/source/FORMAT/ConsensusMapArrowExport.cpp
  • src/tests/class_tests/openms/source/ConsensusMapArrowExport_test.cpp

…ntifiers

Two defects found reviewing the preflight added in the previous commit.

1. It validated EVERY identification attached to a feature, but the row draws
   all identification-derived values from the winning hit alone. So a feature
   whose winner resolves perfectly was refused because a sibling -- hitless, or
   simply not selected -- lacked an index nobody asks for. Now it selects the
   same identity the row builder does (selectFeatureIdentity) and validates only
   that. Third over-scoped guard in this area: validate exactly the values the
   output depends on, not everything in reach.

2. Duplicate identification-run identifiers were accepted. The mapper's forward
   map assigns with operator[], so two runs sharing an identifier leave only the
   last one's paths and a feature of the first is stamped with a file it never
   came from -- silently, since one row gives nothing away. The pg exporter
   already refuses this.

   Placement matters and the test caught getting it wrong: the check must sit
   OUTSIDE the existing try/catch, which swallows Exception::InvalidValue. That
   handler exists for the mapper's duplicate-PATH-LIST throw, which is safe to
   downgrade because the forward map is still complete; a duplicate IDENTIFIER
   is the opposite case wearing the same exception type. Inside the try, the new
   throw was caught and logged as a warning while the export continued on the
   very mapping it was meant to reject.

Known limitation, unchanged: the preflight narrows the partial-collection window
without closing it. Unassigned identifications do not affect feature rows but do
reach the PSM export, which validates them and can throw after
quantms.feature.parquet is already written. Closing that means validating the
whole collection in the caller before the first write, in three TOPP tools.

157/157 tests.

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

@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.

♻️ Duplicate comments (1)
src/openms/source/FORMAT/ConsensusMapArrowExport.cpp (1)

1287-1294: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Skip validation for features that cannot emit a QPX row.

buildFeatureTableRange drops a feature when none of its handles has a matching entry in id_lut.run_columns. This preflight validates that feature before the drop. A selected identification without id_merge_index can then reject an export even though the feature cannot produce id_run_file_name or any output row.

Only call validateMergeIndex after confirming that the feature has at least one exportable handle. Add a regression test for a dropped feature with a selected identification and no id_merge_index.

Also applies to: 1296-1296

🤖 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/ConsensusMapArrowExport.cpp` around lines 1287 -
1294, The preflight validation around the feature loop currently validates
selected identifications before confirming the feature can emit a row. In the
loop over cmap features and before calling validateMergeIndex, first determine
whether at least one handle has a matching entry in id_lut.run_columns, matching
buildFeatureTableRange’s drop condition; skip validation for non-exportable
features, and add a regression test covering a dropped feature with a selected
identification lacking id_merge_index.
🧹 Nitpick comments (1)
src/openms/source/FORMAT/ConsensusMapArrowExport.cpp (1)

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

Format the conditional block on separate lines.

Put the opening and closing braces on aligned lines.

As per coding guidelines, C++ blocks must use braces on their own aligned lines.

🤖 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/ConsensusMapArrowExport.cpp` at line 1295, Reformat
the conditional in selectFeatureIdentity so the opening and closing braces
appear on separate, aligned lines, while preserving the existing continue
behavior.

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.

Duplicate comments:
In `@src/openms/source/FORMAT/ConsensusMapArrowExport.cpp`:
- Around line 1287-1294: The preflight validation around the feature loop
currently validates selected identifications before confirming the feature can
emit a row. In the loop over cmap features and before calling
validateMergeIndex, first determine whether at least one handle has a matching
entry in id_lut.run_columns, matching buildFeatureTableRange’s drop condition;
skip validation for non-exportable features, and add a regression test covering
a dropped feature with a selected identification lacking id_merge_index.

---

Nitpick comments:
In `@src/openms/source/FORMAT/ConsensusMapArrowExport.cpp`:
- Line 1295: Reformat the conditional in selectFeatureIdentity so the opening
and closing braces appear on separate, aligned lines, while preserving the
existing continue behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bcf05e50-c51a-4d40-a5b8-f67dd000a441

📥 Commits

Reviewing files that changed from the base of the PR and between 24712ff and b7a055f.

📒 Files selected for processing (2)
  • src/openms/source/FORMAT/ConsensusMapArrowExport.cpp
  • src/tests/class_tests/openms/source/ConsensusMapArrowExport_test.cpp

@timosachsenberg
timosachsenberg merged commit b96f9f8 into develop Jul 31, 2026
11 checks passed
@timosachsenberg
timosachsenberg deleted the qpx-feature-merge-index-guard branch July 31, 2026 17:31
timosachsenberg added a commit that referenced this pull request Aug 3, 2026
…9835, #9836 (#9841)

Backfills the QPX export spec-conformance series, the macOS PKG
notarization fix, and the Windows GUI DLL export fix that merged into
develop without changelog entries. #9805 and #9821 were intentionally
skipped (test-only / comment-only, no user-visible behavior change),
and #9818 was already documented.


Claude-Session: https://claude.ai/code/session_0118Yt3TZEMzhMhH6FwZPDVt

Co-authored-by: Claude <[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