Skip to content

[FIX,TEST] ParquetDiff: restore observed_mz to the QPX feature primary key - #9877

Merged
timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:fix/qpx-feature-key-observed-mz
Aug 6, 2026
Merged

timosachsenberg merged 1 commit into
OpenMS:developfrom
timosachsenberg:fix/qpx-feature-key-observed-mz

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

ParquetTableComparator::qpxPrimaryKey("feature") returned four columns — (peptidoform, charge, run_file_name, rt) — where QPXValueValidation enforces five. The two must not disagree: a file validation accepts is then one this comparator silently drops rows from.

Why observed_mz is load-bearing

QPX permits unmapped features and ConsensusMapArrowExport writes them with an empty peptidoform. For those rows the four-column key collapses to (charge, run_file_name, rt) — and rt is float32 on write, where one ULP is 244 µs at a retention time of 3000 s. Two co-eluting unmapped features of one charge in one run therefore share a key although they are plainly different features.

This is the same reasoning #9825 recorded when it added the column ("Do not drop it back out"); #9865 landed afterwards and dropped it.

The consequence is worse than a duplicate report

buildKeys_ compares only the first row of a duplicate key. So the second row's values were never compared at all — a value assertion over such a file would have passed green while silently ignoring half its rows.

That is demonstrated, not argued. With the fix reverted, the new section fails on six assertions, and the decisive one is "a change confined to the second row must be reported": under the four-column key that change produces no value error whatsoever.

line 370: TEST_EQUAL(feature.size(), 5)              <- returns 4
line 375: TEST_STRING_EQUAL(feature[4], "observed_mz")
line 410: TEST_EQUAL(r.key_errors.empty(), true)     <- the two rows collide
line 411: TEST_EQUAL(r.rows_compared, 2)             <- only 1 compared
line 412: TEST_EQUAL(r.equal, true)
line 422: TEST_EQUAL(r.value_errors.empty(), false)  <- the silent drop

Latent, not live

No QPX feature table any current test produces collides under the four-column key — I checked all five. Stating that plainly rather than overselling the fix.

But it is close, and it was invisible for a structural reason: every QPX assertion in the suite is a sha256sum existence check, so nothing compares a feature table at all. Margin in the richest fixture:

fixture feature rows empty peptidoform dup under 4-col dup under 5-col
BSA_qpx_seeds_dir 298 210 0 0
BSA_qpx_dir 60 0 0 0
IsobaricWorkflow_qpx_dir 5 1 0 0
ProteinQuantifier_18/19_qpx_dir 9 / 2 0 0 0

In BSA_qpx_seeds_dir the closest same-(peptidoform, charge, run_file_name) retention-time pair is 9 float32 ULPs apart (9.7e-7 relative) — key ('', 2, 'BSA2_F2'), rt 2255.501953125 vs 2255.504150390625. It would have bitten as soon as anything compared a feature table, which is exactly what #9864's Phase 0.1 QPX value assertions set out to do. Hence fixing it first, on its own.

Test

The existing section asserted feature.size() == 4 — it had frozen the defect. It now pins all five column names, and a new section builds the colliding shape directly: two unmapped features at the same float32 rt in one run, differing only in observed_mz. It asserts both are matched with no duplicate-key error, that a change to the second is reported, and — so the section cannot go vacuous — that the four-column key really does collide on that input.

Targeted ctest -R "ParquetDiff|ParquetTableComparator|qpx": 34/34 pass.

Part of #9864 (Phase 0.1).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y9DY9JfJasCr76qof5n5rx

Summary by CodeRabbit

  • Bug Fixes

    • Improved QPX feature matching by distinguishing co-eluting unmapped features using observed mass-to-charge values.
    • Duplicate feature rows are now fully compared, ensuring changes to any matching row are detected.
  • Tests

    • Added regression coverage for feature matching, collision prevention, and duplicate-row change detection.
  • Documentation

    • Added a changelog entry describing the fix.

…y key

ParquetTableComparator::qpxPrimaryKey("feature") returned four columns
(peptidoform, charge, run_file_name, rt) where QPXValueValidation enforces five.

'observed_mz' is in that key for the sake of the unmapped rows, which QPX permits
and ConsensusMapArrowExport writes with an empty peptidoform. Without it the key
collapses to (charge, run_file_name, rt), and 'rt' is float32 on write - one ULP
is 244 us at a retention time of 3000 s - so two co-eluting unmapped features of
one charge in one run share a key although they are plainly different features.

The consequence is worse than a spurious duplicate report. buildKeys_ compares
only the first row of a duplicate key, so the second row's values were never
compared at all: a value assertion over such a file would have passed while
silently ignoring half its rows. Demonstrated, not argued - with the fix reverted,
the new section's "a change confined to the second row must be reported"
assertion fails, i.e. the change produces no value error whatsoever.

Latent rather than live: no QPX feature table any current test produces collides
under the four-column key. But BSA_qpx_seeds_dir carries 210 empty peptidoforms
in 298 rows, and its closest same-(peptidoform, charge, run) retention-time pair
is 9 float32 ULPs apart (9.7e-7 relative). It would have bitten as soon as
anything compared a feature table - which is exactly what the QPX value
assertions of OpenMS#9864 Phase 0.1 set out to do, and why this is fixed first.

The existing test asserted feature.size() == 4, so it had frozen the defect. It
now pins all five column names, and a new section builds the colliding shape
directly: two unmapped features at the same float32 rt in one run differing only
in observed_mz. It asserts both are matched with no duplicate-key error, that a
change to the second is reported, and - so the section cannot go vacuous - that
the four-column key really does collide on that input.

Part of OpenMS#9864.

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

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 55e64851-0086-48f5-a69d-fb6ff2da221c

📥 Commits

Reviewing files that changed from the base of the PR and between b51d520 and 647cbfc.

📒 Files selected for processing (3)
  • CHANGELOG
  • src/openms/source/FORMAT/ParquetTableComparator.cpp
  • src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp

📝 Walkthrough

Walkthrough

Changes

The QPX feature primary key now includes observed_mz. Tests verify distinct co-eluting unmapped features and detect changes in the second row. The changelog records the correction.

QPX feature matching

Layer / File(s) Summary
Extend the QPX feature key
src/openms/source/FORMAT/ParquetTableComparator.cpp
The feature key now uses peptidoform, charge, run file name, retention time, and observed_mz.
Validate feature matching
src/tests/class_tests/openms/source/ParquetTableComparator_test.cpp, CHANGELOG
Tests verify the five-column key, distinguish co-eluting unmapped features, detect second-row changes, and document the correction.

Possibly related PRs

  • OpenMS/OpenMS#9825: Introduced the QPX feature-view primary-key logic refined by this change.
  • OpenMS/OpenMS#9849: Also modifies QPX feature-key matching to include observed_mz.
  • OpenMS/OpenMS#9865: Refines the ParquetTableComparator::qpxPrimaryKey behavior and related tests.

Poem

A rabbit found two rows aligned,
With matching fields but m/z defined.
The key grew one precise new ear,
So both rows now compare clear.
“No collision!” hops the hare.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: restoring observed_mz to the QPX feature primary key.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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