Skip to content

[TEST] Point the FuzzyDiff caveat in ProteinQuantifier_29 at issue #9859 - #9860

Closed
timosachsenberg wants to merge 3 commits into
developfrom
fix/protein-quantifier-ratio-columns
Closed

timosachsenberg wants to merge 3 commits into
developfrom
fix/protein-quantifier-ratio-columns

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

One-line comment change. #9854 merged before this follow-up landed, so it is on its own.

src/tests/topp/CMakeLists.txt:2948 explains why TOPP_ProteinQuantifier_29_out1 cannot fail on its own and is paired with a textual assertion. It now names #9859, where the underlying cause is tracked: FuzzyStringComparator accepts any numeric comparison involving NaN, so a value regressing to NaN is invisible to all 778 \${DIFF} comparisons in the TOPP suite and to TEST_FILE_EQUAL in 12 class tests — not just to this one test.

No behaviour change; TOPP_ProteinQuantifier_29/30 pass unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ

Summary by CodeRabbit

  • Bug Fixes
    • Fixed protein ratio calculations to output nan when sample abundances are missing or non-positive.
    • Prevented invalid or misleading ratio values, including infinite results.
    • Kept ratio columns and row values aligned by showing them only for applicable sample-level outputs.
  • Tests
    • Added regression coverage for missing abundances and output formats.
  • Documentation
    • Clarified ratio behavior and SILAC sample ordering.

timosachsenberg and others added 2 commits August 4, 2026 22:01
Two defects in the '-ratios' / '-ratiosSILAC' columns, found while auditing the
"a stored zero is not a detected peptide" fixes (#9851, #9852). Both are
pre-existing and independent of those.

1. Undefined behaviour, and an unquantified protein reported as unchanged.

total_abundances is deliberately sparse: calculateProteinAbundances_ skips a
sample in which the protein has fewer than 'top:N' detected peptides. The ratio
blocks read it with find(0)->second and find(0)/find(1)/find(2)->second and no
end() check. The only guard is 'if (total_abundances.empty()) continue;', which
says the map has some key, not key 0 -- and fifteen lines earlier the same map is
read defensively for the abundance columns, so the writer contradicted itself.

Where the key did exist as 0.0 ("not detected") the division gave +-inf or NaN;
where it was absent the fallback printed 0.0, which in a log2-ratio column
asserts the sample is exactly equal to the reference. Reproducible on the shipped
fixture with stock defaults, exit code 0:

  "Protein" 1 0.9097 4  200.0 30.0 0.0  -inf -inf -2.7369655941662060

A ratio is now written only where both samples carry a positive abundance, and
'nan' otherwise, via SVOutStream::writeValueOrNan -- the missing-value
convention MSstats and every comparable tool use. Ratios of quantified proteins
are byte-identical: the original log(x)/log(2.0) is kept rather than std::log2,
which can differ in the last ulp, and the self-ratio stays the bare int 0.

2. Value columns the header never emitted.

writeProteinTableHeader_ emits the ratio names only in the branch it shares with
the sample-level abundance columns -- not for 'file_and_channel_level_output',
not for a single sample -- while the body wrote the values outside that branch
split. '-ratios -file_and_channel_level_output true' produced a 7-field header
over a 10-field row; pandas.read_csv then promotes column 0 to an index and
shifts every value. The body now uses the header's guard.

Tests. Neither defect was caught because TOPP_ProteinQuantifier_12/13, the only
tests exercising these flags, both pass 'top:include_all' -- the one
configuration in which no sample key can be missing. New _29 covers the sparse
case (one finite ratio next to two nan, so the finite path is pinned too) and
_30 the header/body mismatch.

Note for anyone extending this: FuzzyDiff compares these files numerically and
reports "No numeric differences were found" between 'nan' and '-inf', so a
reference diff alone CANNOT fail on defect 1 -- _29_out1 passes against the old
binary. _29_out2 asserts the token textually via FAIL_REGULAR_EXPRESSION, and
that one does fail pre-fix, as does _30_out1.

Whether these columns should exist at all is a separate question, raised in #9853:
nothing in the tree consumes them, and the field exchanges intensities rather
than precomputed ratios.

138 ProteinQuantifier / PeptideAndProteinQuant / IsobaricWorkflow / ProteomicsLFQ
tests pass; no existing reference file changes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VcFtJVe1PcMsBzMnnnpWBJ
The comment explaining why the reference diff alone cannot fail on defect 1 now
names OpenMS#9859, where the underlying comparator behaviour is tracked: any
numeric comparison involving NaN is accepted, so a value regressing to NaN is
invisible to all 778 ${DIFF} comparisons, not just this one.

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

coderabbitai Bot commented Aug 5, 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: f0a637ed-4668-4b49-b4f3-5817bab30e94

📥 Commits

Reviewing files that changed from the base of the PR and between 6d09f84 and c65c54d.

📒 Files selected for processing (5)
  • CHANGELOG
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/ProteinQuantifier_29_output.txt
  • src/tests/topp/ProteinQuantifier_30_output.txt
  • src/topp/ProteinQuantifier.cpp

📝 Walkthrough

Walkthrough

ProteinQuantifier now emits nan for ratios with missing or non-positive abundances. It also omits ratio fields when the output header does not define them. New TOPP tests cover both behaviors.

Changes

ProteinQuantifier ratio output

Layer / File(s) Summary
Guarded ratio generation
src/topp/ProteinQuantifier.cpp, CHANGELOG
Ratio calculations validate positive abundances, emit nan for unquantified comparisons, preserve valid logarithmic ratios, and restrict ratio fields to multi-sample sample-level output.
Ratio output regression coverage
src/tests/topp/CMakeLists.txt, src/tests/topp/ProteinQuantifier_29_output.txt, src/tests/topp/ProteinQuantifier_30_output.txt
TOPP tests verify nan output for missing abundances and matching header and row field counts without ratio columns.

Possibly related issues

Possibly related PRs

  • OpenMS/OpenMS#9854 — Directly addresses the same ProteinQuantifier ratio-handling fixes and regression tests.
  • OpenMS/OpenMS#9847 — Modifies ProteinQuantifier output handling and TOPP regression tests.
  • OpenMS/OpenMS#9852 — Addresses missing and zero protein abundances in an upstream quantification path.

Suggested reviewers: jpfeuffer

Poem

A rabbit checks each ratio line,
Finds missing hops and marks nan fine.
No phantom zeros cross the trail,
Headers and rows now match the tale.
Three samples rest beneath the moon.

🚥 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 describes the documentation change that links the ProteinQuantifier_29 FuzzyDiff caveat to issue #9859.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch fix/protein-quantifier-ratio-columns
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/protein-quantifier-ratio-columns

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