Skip to content

Fix out-of-bounds reads, merge window, peak fraction and R package installation in MetaProSIP - #2

Merged
timosachsenberg merged 4 commits into
mainfrom
claude/admiring-tesla-n9a3lm-fixes
Dec 2, 2026
Merged

timosachsenberg merged 4 commits into
mainfrom
claude/admiring-tesla-n9a3lm-fixes

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes the bugs CodeRabbit found while reviewing the move (#1). They all predate the move: MetaProSIP.cpp there is byte-identical to OpenMS develop. Stacked on #1; retarget to main once that is merged.

Finding Fix
Apex neighbours: max_trace_int_idx < mono_trace.size() - (Int)i wraps when i > size (a feature without convex hull leaves one trace point), then reads past mono_trace max_trace_int_idx + i < mono_trace.size()
Merge window (two places): after the loop over [low, high) the coefficient at high, the first one beyond the window, was added too sum over the window only
A feature whose identifications all have empty hit lists indexed getHits()[0] of an empty list skip the feature
observed_peak_fraction ("fraction of observed/expected peaks") was compared with the fraction of missing peaks minimum fraction of observed peaks, as documented; identical at the default 0.5; an empty window counts as no peaks instead of 0/0
Negative weight_merge_window made the merge loops start behind their end setMinFloat_(..., 0.0)
-use_averagine_ids -labeling_element O: the averagine 18O generator made one pattern per oxygen (step 100/n), but decomposition and correlation use one per isotopic trace (2n, as the sequence-based 18O generator does), so the decomposition read patterns[n..2n-1] past the end, and the correlation mislabelled the rates averagine 18O steps by 100/(2n); the decomposition also checks the pattern count and never reads past a pattern (the averagine generators can be shorter than the rows read) or assumes 5 rows / 3 columns
QC setup installed a missing R package from http://cran.rstudio.com/ after update.packages() missing packages are reported with an install.packages(...) hint; nothing is installed
QC heat map: heatmap.2 needs at least 2×2 (one peptide, or -heatmap_bins 1), so no plot was made such matrices are drawn with base R image(); PNG at least 200 px high; bin labels use the real bin bounds (no integer division)

Not changed here: CodeRabbit's minor findings in MetaProSIP.cpp (CSV column alignment, escaping in the QC HTML, MS2 blacklisting, charge-0 precursors, TIC fraction above 100 %, unused fit maps). They can follow separately.

Tests

  • TOPP_MetaProSIP_4: input with a second feature whose only identification has no hits; the outputs must equal those of test 1.
  • TOPP_MetaProSIP_5: -weight_merge_window -1 is rejected.
  • TOPP_MetaProSIP_6 / _7: -use_averagine_ids on the test data (11 MS2 spectra, so averagine pseudo-features are made), with -labeling_element O (the out-of-bounds path) and with 13C. These check that the run succeeds.
  • CI now uploads the outputs of failed tests as an artifact.

Reference update (merge-window fix). The first CI run (Linux) passed every run test (including the new 18O averagine run, which read out of bounds before, and the empty-hit feature) and failed only the four CSV comparisons of tests 1 and 4 (test 4's outputs are byte-identical to test 1's). The outputs (artifact of the run) differ from the references in INT 2 of the 36.5 % incorporation, 146376 → 134085 (the dropped out-of-window coefficient, 12291), and in the TIC fraction that follows from it (0.831888 → 0.825412); INT 1 is unchanged. Only these two fields are updated in MetaProSIP_1_output_{1,2}.csv; all other fields still match within FuzzyDiff's tolerance (checked against the CI outputs). The references date from 2019, so the remaining tiny differences (e.g. Global LR in the 5th digit, which depends only on the extracted intensities, not on anything changed here) are drift within the tolerance that predates this PR.

Also in this PR: the correct minor findings of the second review of #1 (documentation URL of --help/CTD points to this repository; inherited OPENMS_TOOL_REGISTRY_PATH unset in the tests; registry test renamed TOPP_MetaProSIP_tool_registry_is_readable; branch name via env in CI; .gitattributes patterns; README --helphelp).

Verification: CI runs on this branch via workflow_dispatch (the workflow's pull_request trigger only covers PRs into main). First run (on 479d938): https://github.com/OpenMS/OpenMS-MetaProSIP/actions/runs/46867742143. A run on the current head follows once that run's macOS/Windows core builds are cached.

https://claude.ai/code/session_0149aXmZhZtnMkPBQ7zPTrXN


Generated by Claude Code

@timosachsenberg
timosachsenberg added this pull request to stack #3 December 2, 2026 11:23
@timosachsenberg
timosachsenberg marked this pull request as ready for review December 2, 2026 11:23
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 309a9d3b-82f8-44d5-ba85-a1e8e1edeae5
Commits

Reviewing files that changed from the base of the PR and between fbc0a24 and 9766b8e.

Files ignored due to path filters: 2

  • src/tests/topp/MetaProSIP_1_output_1.csv is excluded by !**/*.csv
  • src/tests/topp/MetaProSIP_1_output_2.csv is excluded by !**/*.csv
Files selected for processing: 8

  • .gitattributes
  • .github/actions/build/action.yml
  • .github/workflows/nightly.yml
  • README.md
  • src/tests/CMakeLists.txt
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/MetaProSIP_2_input.featureXML
  • src/topp/MetaProSIP.cpp
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Base automatically changed from claude/admiring-tesla-n9a3lm to main December 2, 2026 14:46
…stallation

Bugs found in review of the move (OpenMS-MetaProSIP#1); all predate it:

- apex neighbours: max_trace_int_idx < size - i wrapped when i > size, so the
  guard passed and read past mono_trace (a feature without a convex hull leaves
  one trace point)
- merge window: after the loop over [low, high), the coefficient at high, the
  first one beyond the window, was added as well (two places); abundances are
  now the sum over the window only
- a feature whose identifications all have empty hit lists indexed an empty
  hit list; it is skipped
- observed_peak_fraction compared the fraction of missing peaks; it is now the
  minimum fraction of observed peaks, as documented (same at the default 0.5),
  and an empty window has none
- weight_merge_window must not be negative (the merge loops would start behind
  their end)
- 18O with averagine pseudo-features: one isotopic pattern per oxygen was made,
  but the decomposition and the correlation use one per isotopic trace (two per
  oxygen, as for sequences), so the decomposition read past the patterns; the
  decomposition also no longer reads past a pattern or the pattern list
- R: a missing package was installed from an http:// CRAN mirror after
  update.packages(); missing packages are now reported with an install hint
- QC heat map: heatmap.2 needs at least 2x2, so one peptide or -heatmap_bins 1
  gave no plot; those are drawn with image(); the PNG is at least 200 px high and
  the bin labels use the real bin bounds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0149aXmZhZtnMkPBQ7zPTrXN
- TOPP_MetaProSIP_4: a feature whose only identification has no hits is skipped
  (results as in test 1)
- TOPP_MetaProSIP_5: a negative weight_merge_window is rejected
- TOPP_MetaProSIP_6/7: averagine pseudo-features for the unidentified MS2 spectra
  of the input, with 18O (read past the patterns before) and 13C labeling
- CI uploads the outputs of failed tests as an artifact

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0149aXmZhZtnMkPBQ7zPTrXN
- MetaProSIP: the documentation URL of --help and the CTD points to this
  repository; the default of TOPPBase is the page in the OpenMS documentation,
  which no longer has one for MetaProSIP
- tests: OPENMS_TOOL_REGISTRY_PATH inherited from ctest's environment is unset
  where the tests run without this build's registry (it would register
  MetaProSIP twice); the registry check is named TOPP_MetaProSIP_* so that
  ctest -R MetaProSIP selects it
- CI: the cache key's branch name goes through env, not the script text
- .gitattributes: git does not expand braces; CRLF patterns for .cmd/.bat fixed
- README: --helphelp lists all parameters; nightly.yml comment on the cache

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0149aXmZhZtnMkPBQ7zPTrXN
With the coefficient beyond the merge window no longer added, the abundance of
the 36.5 % incorporation of the test peptide drops from 146376 to 134085 (the
dropped coefficient: 12291); the explained TIC fraction follows from it
(0.831888 * (1432379 + 134085) / (1432379 + 146376) = 0.825412). INT 1 is
unchanged: the coefficient after its window was zero.

Only these two fields are updated, from the outputs of CI (artifact
test-outputs-Linux-X64-g++ of run 46867742143). The other fields still match the
references within FuzzyDiff's tolerance; the references date from 2019.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0149aXmZhZtnMkPBQ7zPTrXN
@timosachsenberg
timosachsenberg force-pushed the claude/admiring-tesla-n9a3lm-fixes branch from 9766b8e to edb3a45 Compare December 2, 2026 14:46
@timosachsenberg
timosachsenberg merged commit 5696212 into main Dec 2, 2026
2 of 3 checks passed
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.

2 participants