Repository navigation
fix(BrukerTimsFile): off-by-one in MS1 centroid cap (#9230) - #9233
timosachsenberg merged 1 commit into
Conversation
The cap check `agg_buff.size() > max_peaks` permitted one extra peak past the limit, so capped MS1 spectra emitted exactly `max_peaks + 1` entries (e.g. defaultArrayLength="100001" at the default cap of 100000). Tighten to `>=` and drop the matching `+ 1` from the reserve. Adds a regression test that lowers the cap to 10 and asserts no centroided MS1 spectrum exceeds it, while confirming the cap actually fires on the fixture and that the IM array length stays aligned with the peak count. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
@jonasscheid — couldn't assign you directly (not a collaborator on the repo), so flagging here. This patch fixes the off-by-one cap that produced Could you re-run your pipeline (FileConverter → Comet/MSFragger) against a build of this branch and confirm:
If (1) holds but (2) still crashes, the cap was an aggravating factor and the underlying bug is downstream of OpenMS at large array sizes (OpenMS-side mzML emit was already length-consistent at 100001 — see the PR description for the audit notes). |
📝 WalkthroughWalkthroughCorrects an off-by-one peak-capping boundary in MS1 centroiding that caused spectra to exceed the configured Changes
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/tests/class_tests/openms/source/BrukerTimsFile_test.cpp (1)
537-540: Use braces for single-lineifstatements in this new regression section.The new block currently uses brace-less single-line
ifstatements (Line 537 and Line 539), which conflicts with repository C++ style rules.Proposed style-only patch
- if (spec.getMSLevel() != 1) continue; + if (spec.getMSLevel() != 1) + { + continue; + } max_observed = std::max(max_observed, spec.size()); - if (spec.size() == static_cast<Size>(cfg.ms1_centroid_max_peaks)) ++capped_count; + if (spec.size() == static_cast<Size>(cfg.ms1_centroid_max_peaks)) + { + ++capped_count; + }As per coding guidelines, "Braces must be on their own lines and aligned; always use braces even for single-line blocks (trivial one-liners may stay single-line)".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/tests/class_tests/openms/source/BrukerTimsFile_test.cpp` around lines 537 - 540, The new regression block uses brace-less single-line if statements; update the two conditionals involving spec.getMSLevel() and spec.size() to use explicit braces. Locate the lines with "if (spec.getMSLevel() != 1) continue;" and "if (spec.size() == static_cast<Size>(cfg.ms1_centroid_max_peaks)) ++capped_count;" and rewrite each as a proper block with opening and closing braces on their own lines while preserving the existing logic that updates max_observed and capped_count and keeps the IM array comment intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/tests/class_tests/openms/source/BrukerTimsFile_test.cpp`:
- Around line 537-540: The new regression block uses brace-less single-line if
statements; update the two conditionals involving spec.getMSLevel() and
spec.size() to use explicit braces. Locate the lines with "if (spec.getMSLevel()
!= 1) continue;" and "if (spec.size() ==
static_cast<Size>(cfg.ms1_centroid_max_peaks)) ++capped_count;" and rewrite each
as a proper block with opening and closing braces on their own lines while
preserving the existing logic that updates max_observed and capped_count and
keeps the IM array comment intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4d6d22e5-fe4e-4752-a36e-eca9481547a0
📒 Files selected for processing (2)
src/openms/source/FORMAT/BrukerTimsFile.cppsrc/tests/class_tests/openms/source/BrukerTimsFile_test.cpp
Added entries for: - Fix: BrukerTimsFile off-by-one in MS1 centroid cap (#9233) - Native .idparquet identification format (#9225, #9232): - PSMArrowIO new class, FileTypes::IDPARQUET, QPXFile::importFromArrow - Tool support: IDMerger, IDFileConverter, PercolatorAdapter, CometAdapter, MSGFPlusAdapter, SageAdapter Co-authored-by: GitHub Copilot <[email protected]> Co-authored-by: Copilot <[email protected]>
Summary
.dreader) caps MS1defaultArrayLengthat exactly 100001, crashing consumers (e.g. Comet) #9230. The MS1 centroiding cap inFrameCentroider::centroidallowed one extra peak pastmax_peaks, so capped spectra emitted exactlymax_peaks + 1entries — visible in the wild asdefaultArrayLength="100001"on 93% of MS1 spectra in a Bruker timsTOF run, which downstream consumers (Comet via pwiz, MSFragger) trip over.agg_buff.size() > max_peaksto>= max_peaksand drops the matching+ 1from the buffer reserve. Capped output is now exactly bounded by the configured limit.DDA MS1 centroiding cap is exact) that lowers the cap to 10 to force it to fire on every MS1 spectrum, then asserts (a) no spectrum exceeds the cap, (b) the cap actually fires (sanity), and (c) the IMFloatDataArraylength stays aligned with the peak count.Notes for the reviewer
A writer-side audit (
MzMLHandlerspectrum/binaryDataArray emit path) confirmed the OpenMS-emitted mzML was already internally length-consistent at 100001 —defaultArrayLength, m/z and intensity blob sizes (no per-arrayarrayLength, fall back todefaultArrayLength), and the IM array's explicitarrayLength="..."all matched. So this fix removes the surprising off-by-one but may not be sufficient to stop the downstream pwiz heap-corruption. Recommend the reporter re-run their pipeline against a build with this patch and confirm whether the Comet/MSFragger crash persists; if it does, the underlying bug is downstream of OpenMS at large array sizes.Test plan
BrukerTimsFile_test— new sectionDDA MS1 centroiding cap is exact (regression: issue #9230)passes; existing centroid/aggregation/round-trip sections continue to pass.defaultArrayLength > 100000and report whether downstream consumers still crash.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests