Skip to content

fix(FragmentIndex): truncate SNES mothers to unambiguous spans on X/B/Z (#9192) - #9224

Merged
timosachsenberg merged 10 commits into
developfrom
fix/snes-xbz-truncate
Apr 27, 2026
Merged

timosachsenberg merged 10 commits into
developfrom
fix/snes-xbz-truncate

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Closes ProSE SNES: follow-ups from #9191 review — fixed-term-mod specificity + X/B/Z truncation #9192 item 2. Item 1 (PROTEIN_N/C_TERM fixed-mod specificity) is tracked separately.
  • Previously, when a SNES mother peptide's proposed window overlapped an X/B/Z residue, the whole mother was dropped — losing valid shorter realizations anchored at the same terminus.
  • Now `FragmentIndex::generateSNESMothers_` splits each protein containing X/B/Z into contiguous unambiguous spans and runs the existing Single-N / Single-C sweeps within each span. Proteins without X/B/Z take the same single-span fast path as before. The `emitMother` lambda no longer carries an X/B/Z check — span boundaries are now structural.

Test plan

  • New unit tests in `FragmentIndex_test.cpp` (added in TDD order, then made to pass):
    • Single-N: `peptide_max_size=12` on `ACDEFGHIXKLMNPQSTVWY` (X at pos 8) → asserts a Single-N mother at `start=0, length=8` exists, plus an invariant that no mother spans the X.
    • Single-C: same setup → asserts a Single-C mother at `start=9, length=11` exists, with the same no-spans-X invariant mirrored.
  • Existing X/B/Z rejection test (`peptide_min=peptide_max=8`, no truncation possible) still passes.
  • Full `FragmentIndex_test` suite passes.
  • Broader regression suite (`ctest -R "FragmentIndex|PeptideDataBaseSearch|ProSE"`, 29 tests including the three TOPP_ProSE_DDA end-to-end runs) passes.
  • Mother count on a real SwissProt human FASTA (no X/B/Z) is byte-identical between this branch and develop (22,544,734 mothers each), confirming hot-path parity.
  • On a 0.1%-X/B/Z stress FASTA (same SwissProt with X/B/Z injected), this branch emits ~155k additional mothers (the truncated prefixes/suffixes that develop drops entirely).

Notes for reviewers

  • Spec: `docs/superpowers/specs/2026-04-27-snes-xbz-truncate-design.md`
  • Plan: `docs/superpowers/plans/2026-04-27-snes-xbz-truncate.md`
  • The counter `skipped_peptides` now counts "spans shorter than peptide:min_size" instead of "per-mother X/B/Z rejections". The log message was updated accordingly. No callers depend on the value.
  • Build-time wall-clock benchmark (8-thread, 20K-protein human SwissProt + 0.1% X/B/Z stress FASTA) shows the same dirty:clean ratio (~1.06×) on both branches; absolute numbers were noisy due to a parallel build on the test host. Hot-path parity is established by the identical mother count on the no-X/B/Z FASTA.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved peptide generation algorithm to retain more valid mother peptides when ambiguous amino acids overlap; previously discarded peptides are now intelligently truncated to valid spans
  • Documentation

    • Added implementation plan and detailed design specification documenting the new truncation-based approach
  • Tests

    • Added regression tests verifying correct handling of ambiguous residues in various peptide generation scenarios

timosachsenberg and others added 8 commits April 27, 2026 08:29
Approach C: keep protein-level fast path for the no-ambiguous-residue case;
on proteins containing X/B/Z, split into contiguous unambiguous spans and
sweep Single-N / Single-C mothers per span.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Spell out shared test parameter block (mirrors existing test 2419) and use
isSingleCMother(mod_bitmask_) for mother classification — is_single_c is not
a direct field on Peptide.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… item 2)

Three tasks: failing tests, span-split sweep implementation, regression
verification. Tracks the spec at 2026-04-27-snes-xbz-truncate-design.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Add two failing tests asserting that Single-N / Single-C mother peptides
whose proposed window spans an X/B/Z residue still emit a truncated mother
covering the unambiguous prefix or suffix at the same anchor. Currently the
whole mother is dropped — see issue #9192 item 2.
…n test

Code-review follow-up: the Single-N section asserts
`start > 8u || end <= 8u` for every kept mother. With max_size=12, an
off-by-one bug in the upcoming Single-C span-truncation fix could emit
a mother starting at position 8 (spanning the X) and the Single-C test
would still pass on its existence check alone. Mirror the invariant.
Previously, when a SNES mother peptide's proposed window overlapped an
X/B/Z residue, the whole mother was dropped — losing valid shorter
realizations anchored at the same terminus that did not span the
ambiguous residue.

Now generateSNESMothers_ splits each protein containing X/B/Z into
contiguous unambiguous spans and runs the Single-N / Single-C sweeps
within each span, with the length cap enforced per-span. Proteins
without X/B/Z take the same single-span fast path as before. The
emitMother lambda no longer carries an X/B/Z check — span boundaries
are now structural.

Closes #9192 (item 2; item 1 tracked separately).
Code-review follow-up to the SNES X/B/Z truncation fix. After the
refactor:

- The skipped_peptides counter now counts only spans shorter than
  peptide:min_size; X/B/Z overlap no longer rejects mothers, it
  truncates them. Update the log line accordingly.
- The if/else dispatch was framed as fast vs slow path, but both
  branches call find_first_of("XBZ") exactly once unconditionally —
  the split is organizational, not a perf optimization. Reword.
- Annotate the two distinct break exits in the span-walk loop.

No behavior change.
End-of-branch review nits:
- emitMother comment still referenced "fast path" / "slow path" labels
  that were removed from the dispatch block in the previous commit.
  Reword to describe the actual mechanism (dispatch via sweepSpan vs
  span-split walk) so the comment has a referent in surrounding code.
- Test comment "must still be emitted" implied the truncated mother
  was already emitted before the fix. Switch to "must now be emitted"
  to make the post-fix expectation explicit.

No behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2bf99e66-d976-4eab-908d-91647cd32def

📥 Commits

Reviewing files that changed from the base of the PR and between b9c67c9 and 46c66b6.

📒 Files selected for processing (4)
  • docs/superpowers/plans/2026-04-27-snes-xbz-truncate.md
  • docs/superpowers/specs/2026-04-27-snes-xbz-truncate-design.md
  • src/openms/source/ANALYSIS/ID/FragmentIndex.cpp
  • src/tests/class_tests/openms/source/FragmentIndex_test.cpp

📝 Walkthrough

Walkthrough

This PR implements span-based truncation for SNES mother peptide generation when X/B/Z ambiguous residues are encountered, replacing per-mother rejection with splitting into contiguous unambiguous regions. The implementation includes design specifications, core algorithm refactoring, and regression test coverage.

Changes

Cohort / File(s) Summary
Documentation
docs/superpowers/plans/2026-04-27-snes-xbz-truncate.md, docs/superpowers/specs/2026-04-27-snes-xbz-truncate-design.md
Plan and design specifications for span-based SNES mother truncation at X/B/Z boundaries, including test strategy and edge case handling.
Core Implementation
src/openms/source/ANALYSIS/ID/FragmentIndex.cpp
Refactored generateSNESMothers_ to remove per-mother X/B/Z rejection checks and replace with sweepSpan routine that emits Single-N/Single-C mothers within unambiguous spans; introduces fast/slow paths for proteins with/without ambiguous residues.
Regression Tests
src/tests/class_tests/openms/source/FragmentIndex_test.cpp
Two new FragmentIndex_test sections asserting truncated Single-N and Single-C mothers are correctly emitted when proposed windows overlap X/B/Z residues, with no mothers spanning the ambiguous position.

Possibly related PRs

Poem

🐰 A mother once whole, now split with care,
Where X marks ambiguity in the air,
We truncate and sweep each unbroken span,
No peptides lost—span by span, plan by plan!
Small mothers thrive where shadows once lay,
Hop on, dear SNES, brighten the way! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title accurately describes the main change: truncating SNES mothers to unambiguous spans when X/B/Z are encountered, directly addressing issue #9192 item 2.
Linked Issues check ✅ Passed The PR fully addresses item 2 of issue #9192 (truncate SNES mothers at X/B/Z), implementing span-based truncation with comprehensive test coverage. Item 1 (fixed-term-mod specificity) is explicitly deferred and not included in scope.
Out of Scope Changes check ✅ Passed All changes are directly scoped to item 2 of #9192: spec/plan documentation, test cases for X/B/Z truncation, and refactored SNES mother generation logic. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/snes-xbz-truncate

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 and usage tips.

timosachsenberg and others added 2 commits April 27, 2026 15:03
These are working planning artifacts and shouldn't live in the repo.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@timosachsenberg
timosachsenberg merged commit acf5a12 into develop Apr 27, 2026
42 checks passed
@timosachsenberg
timosachsenberg deleted the fix/snes-xbz-truncate branch April 27, 2026 15:08
timosachsenberg pushed a commit that referenced this pull request Apr 28, 2026
Add missing entries for:
- #9221: pyOpenMS standalone/cibuildwheel Arrow 24.x CMake fix
- #9218: PercolatorAdapter in-process Percolator rescoring backend
- #9224: ProSE/FragmentIndex SNES X/B/Z mother truncation fix
- #9223: OpenSwathWorkflow macOS arm64 duplicate TLS symbol fix

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
timosachsenberg added a commit that referenced this pull request Apr 28, 2026
Add missing CHANGELOG entries for 4 recent code PRs that were not yet
documented:

- #9218: feat(Percolator) in-process backend — new OpenMS::Percolator
  class (vendored Percolator 3.08 + TRON solver) and PercolatorAdapter
  -use_subprocess flag; entries added under OpenMS Library Added and
  TOPP tools PercolatorAdapter sections.

- #9221: fix(cmake) Arrow 24.x in pyOpenMS standalone build — the
  cibuildwheel CMakeLists.txt version pin now dropped like #9196;
  entry added under Dependencies.

- #9223: fix(openswath) duplicate TLS init symbol on macOS arm64/clang —
  g_picker_pool_shared moved from inline thread_local in header to a
  single .cpp definition; entry added under OpenSwathWorkflow.

- #9224: fix(FragmentIndex) SNES mothers truncated at X/B/Z residues —
  proteins with ambiguous residues split into unambiguous spans for SNES
  indexing; entry added under ProSE.

Co-authored-by: GitHub Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: timosachsenberg <[email protected]>
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.

ProSE SNES: follow-ups from #9191 review — fixed-term-mod specificity + X/B/Z truncation

1 participant