Skip to content

[FIX] FragmentIndex: replace the previous index on rebuild - #10350

Merged
timosachsenberg merged 1 commit into
developfrom
claude/gallant-dirac-qn8lxb
Sep 30, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
claude/gallant-dirac-qn8lxb

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Split out of #10335. This is the independent bug fix from that PR, without its deduplication, scoring or filtering changes.

FragmentIndex::build() only cleared protein_lengths_. generatePeptides() and the fragment merge append to fi_peptides_ and fi_fragments_. Building twice on the same object therefore kept the old peptides and fragments, and their (protein_idx, offset) coordinates were read against the new FASTA. A build that throws, such as one with an entry over 65535 residues, also left isBuild() true with the previous index.

build() now starts with clear(). ProSE's existing electron-ion rebuild in searchWithModificationAnalysis already calls clear() first, so it behaves the same as before. Every other caller builds a fresh index, so they are also unchanged.

New test [EXTRA] rebuilding replaces the previous peptide and fragment buffers:

  • building the same FASTA twice keeps 1 peptide and the same fragment count
  • rebuilding with a different FASTA reconstructs the new sequence and matches a fresh index
  • a failed build leaves the index empty and isBuild() false

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes (see note below)
  • Updated or added python bindings for changed or new classes (no signature changes)

How it was tested. There was no full local build. FragmentIndex.cpp, FragmentIndex_test.cpp, ProSEAlgorithm_test.cpp and the test framework were compiled from this branch (GCC 13.3, C++23, OpenMP). They were linked against libOpenMS.so from nightly 3.6.0-pre-nightly-2026-09-29, which was built from 55f7bdb and has an identical FragmentIndex.h.

  • FragmentIndex_test against the unmodified nightly library: the 55 existing sections pass. The new section fails with 2 peptides instead of 1 and 48 fragments instead of 16, which reproduces the bug.
  • FragmentIndex_test with this branch's FragmentIndex.cpp: all 56 sections pass.
  • ProSEAlgorithm_test with this branch's FragmentIndex.cpp: passes. LD_DEBUG=bindings confirms that libOpenMS's calls to FragmentIndex::build resolved to the patched definition.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hgr7bpkMaiCg7A1F15yLjf


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Rebuilding a fragment index now replaces its previous contents. If a rebuild fails, the index is left unbuilt rather than retaining stale data.
  • Documentation
    • Clarified the behavior of rebuilding an index and what happens when a build fails.

FragmentIndex::build() only cleared protein_lengths_. generatePeptides()
and the fragment merge append to fi_peptides_ / fi_fragments_, so building
twice on the same object kept the old peptides and fragments, and their
(protein_idx, offset) coordinates were read against the new FASTA. A
minimal probe goes from 1 to 2 peptides and 16 to 48 fragments. A build
that throws (e.g. an entry over 65535 residues) also left isBuild() true
with the previous index.

build() now starts with clear(). ProSE's existing electron-ion rebuild
already called clear() first and is unaffected.

Split out of #10335.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Hgr7bpkMaiCg7A1F15yLjf
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: f3ae3964-2879-4f14-9214-1aca54bed13c

📥 Commits

Reviewing files that changed from the base of the PR and between 5d5cbff and e598942.

📒 Files selected for processing (4)
  • CHANGELOG
  • src/openms/include/OpenMS/ANALYSIS/ID/FragmentIndex.h
  • src/openms/source/ANALYSIS/ID/FragmentIndex.cpp
  • src/tests/class_tests/openms/source/FragmentIndex_test.cpp

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


📝 Walkthrough

Walkthrough

FragmentIndex::build now clears the existing index before rebuilding. Documentation, a changelog entry, and regression tests cover successful rebuilds and failed builds.

Changes

FragmentIndex rebuild behavior

Layer / File(s) Summary
Reset and validate index rebuilds
src/openms/include/OpenMS/ANALYSIS/ID/FragmentIndex.h, src/openms/source/ANALYSIS/ID/FragmentIndex.cpp, src/tests/class_tests/openms/source/FragmentIndex_test.cpp, CHANGELOG
build clears the existing index before rebuilding. Documentation and the changelog describe this behavior. Tests check repeated builds, replacement with different input, and an invalid rebuild that leaves the index unbuilt with empty peptide and fragment buffers.

Suggested reviewers: cbielow

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to e5989

The change prevents stale peptide and fragment data from surviving rebuilds and adds regression coverage for replacement and failure behavior. It is ready to merge subject to normal build and test checks.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to e5989

Rebuilding now discards stale index data and invalidates the previous index before processing new input. The change does not introduce a new input boundary, privilege, or dependency. No introduced or worsened material security risk was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated effect is bounded to the rebuilt FragmentIndex instance and consumers of its indexed data. The inspected change introduces no new caller, credential use, authorization transition, or external input source.

Trust Boundaries and Controls

  • observed — FASTA entries remain caller-supplied input to the same library method. The existing sequence-length validation and query readiness check remain in place; clearing readiness before rebuilding prevents ordinary spectrum queries from using an index invalidated by validation failure.

Resilience and Maintainability Implications

  • inferred — Construction is not transactional: peptides and fragments are published into member buffers before completion, without a failure-cleanup path. Later exceptions can therefore leave partial buffers visible through direct getters even while readiness is false. This behavior predates the PR and is not an introduced security concern; the tested empty-buffer guarantee is bounded to early validation failure.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1… 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 The title clearly and concisely identifies the main change: replacing the previous FragmentIndex during rebuild.
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 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • 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 index anew
Old paths clear as fresh ones grew
Peptides hop to the right place
Failed builds leave an empty space
Then the bunny bounds away

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

@timosachsenberg
timosachsenberg merged commit c59a007 into develop Sep 30, 2026
14 checks passed
@timosachsenberg
timosachsenberg deleted the claude/gallant-dirac-qn8lxb branch September 30, 2026 10:29
timosachsenberg added a commit that referenced this pull request Oct 2, 2026
…10394)

A peptide that occurs in several proteins was indexed once per occurrence.
Its copies took several of the per-spectrum candidate slots
(scoring:max_candidates_per_spectrum), and the runner-up was often the same
peptide, so delta_score was 0 and the candidate-pool features counted copies.

FragmentIndex gains peptide:deduplicate (default false): after peptide
generation, exact modified peptides are collapsed to one representative
coordinate, compared on the full peptidoform string (hashes only group
candidates). SNES mother indices are unchanged. ProSE enables it by default;
its PeptideIndexing step already recovers every protein mapping and the
target/decoy label. Chunked searches additionally skip a peptide/charge/isotope
hypothesis already scored in an earlier chunk.

Split out of #10335 (0af4cf6); its index-rebuild part is in develop as #10350.
The four ProSE idXML references gain the peptide:deduplicate search-parameter
line; replaying the TOPP tests changes nothing else in them.


Claude-Session: https://claude.ai/code/session_01D1N3pC2AqJt57Q3v87bWxz

Co-authored-by: Claude Opus 5.5 <[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.

2 participants