Skip to content

[FIX] TheoreticalSpectrumGenerator: generate the last internal fragment - #9600

Merged
timosachsenberg merged 6 commits into
OpenMS:developfrom
timosachsenberg:fix/issue-9597-boundary-math-bugs
Oct 15, 2026
Merged

timosachsenberg merged 6 commits into
OpenMS:developfrom
timosachsenberg:fix/issue-9597-boundary-math-bugs

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

TheoreticalSpectrumGenerator: the last internal fragment was never generated

With add_internal_fragments, the loop over start positions stopped one position early (l + 3 < size). The internal fragment that ends next to the C-terminal residue was therefore never generated (e.g. ID of PEPTIDE), and peptides of 4 residues got none at all. The bound is l + 2 < size now: the fragment still starts after the N-terminal residue, ends before the C-terminal residue, and has at least 2 residues. A test checks GASP (AS), GASPK (AS, ASP, SP) and GAS (none).

OpenNuXL references: OpenNuXL annotates spectra with internal fragments, so in its 9 references (OpenNuXL_{1..6}_output.idXML, OpenNuXL_{3,4,6}_output2.tsv) only fragment_annotation lines change:

  • the new fragments are added, e.g. VL, QL, NP, DK-H3N1+;
  • at m/z 242.1496, QL now annotates the peak that SSL-CO-H2O1+ annotated before (same mass).

No identification, score or localization changes. The new references were made by taking only the changed lines from the test outputs. Lines whose numbers differ only in the last digits were kept as they were, and the test outputs match the references within FuzzyDiff's tolerance (checked locally, Linux, GCC 13).

Dropped from the original version

develop is merged in, and the tracker references are gone.

🤖 Generated with Claude Code

https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL

Summary by CodeRabbit

  • Bug Fixes
    • Internal-fragment generation now includes eligible fragments ending next to the C-terminal residue, including in four-residue peptides.
    • OpenNuXL spectrum annotations now reflect the additional matched fragments.

…, FDR charge range, MRM RT %RSD)

Addresses three validated findings from OpenMS#9597:

* TheoreticalSpectrumGenerator::addInternalFragmentPeaks_: the internal-fragment
  loop bound `l < size - 1 - 2` dropped the C-terminal-adjacent interior dipeptide
  (off-by-one) and, being unsigned, wrapped to ~1.8e19 for peptides of length 1-2
  (effectively infinite loop / OOM). Guard with `if (size < 4) return;` and use the
  underflow-safe bound `l + 2 < size`.

* FalseDiscoveryRate::applyBasic(run_info, ids): the pooled split_charge_variants
  path computed the upper charge bound with getChargeRange().first instead of
  .second, collapsing e.g. 2..4 to only charge 2.

* MRMFeatureFilter::calculateFilterValuesPercRSD: the component-group
  retention_time_u %RSD was computed from the retention_time_l fields (copy-paste);
  use the _u fields, mirroring the component-level block.

Adds regression tests for all three (fail before the fix, pass after). The TSG fix
emits the previously-missing internal fragments, so the nine OpenNuXL reference
outputs are updated accordingly (fragment_annotation strings only; no
identification/score/localization changes).

The fourth finding (TransformationDescription::getStatistics percentile index) was
validated as a non-bug: the index expression is floating-point and, for the default
percentile set, never produces an out-of-range value.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

@timosachsenberg The following names might be missing from the AUTHORS file:

  • Timo Sachsenberg

Please consider applying the following patch:

--- AUTHORS	2026-06-17 07:28:21.242367259 +0000
+++ AUTHORS.new	2026-06-17 07:28:26.195569197 +0000
@@ -23,8 +23,8 @@
  - Chirag Dave
  - Chris Bauer
  - Chris Bielow
- - Christie Mathews
  - Christian Ehrlich
+ - Christie Mathews
  - Clemens Groepl
  - Cornelia Friedle
  - Daniel Jameson

@coderabbitai

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fcaf1409-e981-470b-a2d7-66f5f6b48800
📥 Commits

Reviewing files that changed from the base of the PR and between 8948b87 and 9a4b266.

⛔ Files ignored due to path filters: 3
  • src/tests/topp/OpenNuXL_3_output2.tsv is excluded by !**/*.tsv
  • src/tests/topp/OpenNuXL_4_output2.tsv is excluded by !**/*.tsv
  • src/tests/topp/OpenNuXL_6_output2.tsv is excluded by !**/*.tsv
📒 Files selected for processing: 9
  • CHANGELOG
  • src/openms/source/CHEMISTRY/TheoreticalSpectrumGenerator.cpp
  • src/tests/class_tests/openms/source/TheoreticalSpectrumGenerator_test.cpp
  • src/tests/topp/OpenNuXL_1_output.idXML
  • src/tests/topp/OpenNuXL_2_output.idXML
  • src/tests/topp/OpenNuXL_3_output.idXML
  • src/tests/topp/OpenNuXL_4_output.idXML
  • src/tests/topp/OpenNuXL_5_output.idXML
  • src/tests/topp/OpenNuXL_6_output.idXML

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

📝 Walkthrough

The internal-fragment generation loop now processes an additional start position. New tests cover fragments at the C-terminal boundary, and OpenNuXL expected-output annotations are updated.

Changes: Internal fragment generation

Layer / File(s) Summary
Internal-fragment boundary and regression coverage
src/openms/source/CHEMISTRY/TheoreticalSpectrumGenerator.cpp, src/tests/class_tests/openms/source/TheoreticalSpectrumGenerator_test.cpp, CHANGELOG
The loop condition processes an additional start position. Tests check internal fragments for GASP and GASPK, and an empty spectrum for GAS. The changelog records the change.
OpenNuXL expected annotations
src/tests/topp/OpenNuXL_*_output.idXML
Six expected-output fixtures contain revised fragment annotations and reported values.

Suggested reviewers: copilot

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 9a4b2

The boundary change matches the intended fragment constraints, with regression cases for the newly included fragments. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 6 files. (7 skipped: 7 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 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 describes the main change: generating the last internal fragment in TheoreticalSpectrumGenerator.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 6 files. (7 skipped: 7 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

A rabbit checks the peaks at night
New fragments hop into the light
AS and SP appear
The test records each signal clear
Six fixture fields now match the trail
The bunny stamps the changelog tale

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

Adversarial review result:

  • Cleanup required: several added test comments/section names include tracker references. Please remove tracker/issue references from source and test comments before merge.

Assuming the previous behavior was intentional until disproven, I checked the three targeted fixes against their tests: the pooled FDR charge upper bound, component-group retention-time %RSD, and internal-fragment loop boundary all look consistent with the intended corrections. I did not find a blocking issue in this pass. I did not run the tests locally.

timosachsenberg and others added 3 commits July 1, 2026 13:28
Conflicts resolved to develop's side: OpenMS#9790 (066f27a) fixed the short-
peptide underflow and the MRM %RSD on develop, and develop rewrote the
OpenNuXL references since.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL
TheoreticalSpectrumGenerator stopped the internal-fragment loop one start
position early (l + 3 < size): the internal fragment that ends next to
the C-terminal residue was never generated, and 4-mers got none. The
bound is l + 2 < size now.

- The short-peptide underflow and the MRM %RSD fix are on develop
  (OpenMS#9790); the pooled split-charge FDR fix is dropped: applyBasic(run_info,
  ids) has no caller outside pyOpenMS and that path has further problems.
- OpenNuXL annotates with internal fragments. In its 9 references only
  fragment_annotation lines change: the new fragments are added (e.g.
  VL, QL, DK-H3N1+), and at m/z 242.1496 QL replaces SSL-CO-H2O1+ (same
  mass). The other lines are kept; the test outputs match them within
  FuzzyDiff's tolerance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012GBvJZN8neGpv9RoUshwFL
@timosachsenberg timosachsenberg changed the title Fix boundary/math bugs from #9597 (TSG internal fragments, FDR charge range, MRM RT %RSD) [FIX] TheoreticalSpectrumGenerator: generate the last internal fragment Oct 15, 2026
@timosachsenberg
timosachsenberg merged commit 0dfc776 into OpenMS:develop Oct 15, 2026
13 checks passed
timosachsenberg pushed a commit that referenced this pull request Oct 16, 2026
…zation, #10587 MS1LabeledWorkflow, #10545 Bruker .d reader)

Only CHANGELOG conflicted; both sides are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
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.

3 participants