Skip to content

[FIX] DecoyGenerator: reversed decoys for unspecific cleavage (ProSE, SimpleSearchEngine) - #10686

Merged
timosachsenberg merged 1 commit into
developfrom
claude/project-thread-b0wnbu-unspecific-decoys
Oct 21, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
claude/project-thread-b0wnbu-unspecific-decoys

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Timo · project thread

Description

ProSE -Search:enzyme "unspecific cleavage" with generated decoys (-Search:decoys generate, or auto on a target-only database) fails before the search starts:

Invalid parameter: FragmentIndex: FASTA entry 'DECOY_test' has 7906261 residues, exceeding the supported maximum of 65535 ...

ProSE and SimpleSearchEngine call DecoyGenerator::reversePeptides(protein, enzyme) unless the specificity is none. That function digests the protein with the enzyme (no missed cleavages) and pseudo-reverses each peptide. With unspecific cleavage, the digest is every subsequence of the protein, not a partition of it. The "decoy" was therefore all of those subsequences concatenated: 7.9 million residues for the 363-residue test protein.

Fix: in reversePeptides, unspecific cleavage has no enzymatic termini to keep, so the whole protein is reversed (reverseProtein), as for a non-specific search. An empty protein no longer reads peptides[-1] out of bounds. no cleavage already gave the full reverse and is unchanged.

Not changed: shuffle()/shufflePeptides() digest the same way and would build the same oversized decoys with unspecific cleavage. Nothing in ProSE or SimpleSearchEngine calls them with that enzyme, so I left them alone. I can fix them the same way if wanted.

Tests:

  • DecoyGenerator_test: unspecific cleavage and no cleavage give the reversed protein, and an empty protein gives an empty sequence.
  • TOPP_ProSE_unspecific_decoys(_out): ProSE with unspecific cleavage and generated decoys on the ProSE_1 data. It must report 11 target + 11 decoy proteins and match 3/3 spectra (before this fix it exited with code 6).

Testing

Linux release build of develop @ b15249f with this change: DecoyGenerator_test, all TOPP_ProSE_* from the in-repo data, TOPP_SimpleSearchEngine_* and TOPP_DecoyDatabase_* pass (106 tests).

Checklist

  • Make sure that you are listed in the AUTHORS file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved decoy generation for unspecific and non-enzymatic cleavage by reversing complete protein sequences.
    • Preserved original sequences when digestion produces no peptides.
    • Handled empty protein sequences safely.
  • Tests

    • Added coverage for non-enzymatic cleavage, empty inputs, and generated decoy results across protein identification workflows.

…unspecific cleavage

The digest with 'unspecific cleavage' is every subsequence of the protein, not
a partition of it, so the pseudo-reversed decoy was the concatenation of all of
them (7.9 million residues for a 363-residue protein). ProSE and
SimpleSearchEngine generate decoys with reversePeptides() unless the
specificity is 'none', so '-Search:enzyme "unspecific cleavage"' with generated
decoys failed in the fragment index (more than 65535 residues per protein).
There are no enzymatic termini to keep, so the protein is reversed as a whole.
An empty protein no longer reads out of bounds.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_016TFAtgwsNjvcQbvJjBwhG1
@timosachsenberg timosachsenberg added this to the Release 3.X milestone Oct 21, 2026 — with Claude
@timosachsenberg timosachsenberg added the major critical issues that are important to fix label Oct 21, 2026 — with Claude
@timosachsenberg timosachsenberg self-assigned this Oct 21, 2026
@coderabbitai

coderabbitai Bot commented Oct 21, 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: c427de16-5e26-47fc-8e38-db5d9b52fb0c
📥 Commits

Reviewing files that changed from the base of the PR and between 78a9b06 and fc68f56.

📒 Files selected for processing: 4
  • src/openms/include/OpenMS/CHEMISTRY/DecoyGenerator.h
  • src/openms/source/CHEMISTRY/DecoyGenerator.cpp
  • src/tests/class_tests/openms/source/DecoyGenerator_test.cpp
  • src/tests/topp/CMakeLists.txt

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

reversePeptides now reverses the full protein for unspecific cleavage and returns the input when digestion produces no peptides. Unit and ProSE integration tests cover these cases and generated decoys.

Changes: Decoy reversal

Layer / File(s) Summary
Whole-protein reversal behavior
src/openms/include/OpenMS/CHEMISTRY/DecoyGenerator.h, src/openms/source/CHEMISTRY/DecoyGenerator.cpp
The documentation describes whole-protein reversal when no enzymatic termini are specified. The implementation reverses the full protein for unspecific cleavage and returns the input if digestion produces no peptides.
Reversal and decoy-generation tests
src/tests/class_tests/openms/source/DecoyGenerator_test.cpp, src/tests/topp/CMakeLists.txt
Unit tests cover non-enzymatic cleavage modes and empty input. The ProSE integration test checks target and decoy counts, matched spectra, and a minimum PSM count.

Priority: ➖ Normal

Change: Bug fix

Merge Risk: ⚪ Minimal · up to fc68f

No actionable merge-blocking risk remains in the supported workflows covered by this PR.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. (1 skipped: 1… 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 identifies the main change: fixing reversed decoys for unspecific cleavage in DecoyGenerator. It also names the affected tools, ProSE and SimpleSearchEngine.
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 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ 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
  • 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

A rabbit checks the sequence line,
Then turns the protein end to end.
For empty strands, it leaves them still,
While test runs count each decoy friend.
Three spectra match; the paws applaud.

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

@timosachsenberg
timosachsenberg merged commit 46f8b47 into develop Oct 21, 2026
14 of 15 checks passed
@timosachsenberg
timosachsenberg deleted the claude/project-thread-b0wnbu-unspecific-decoys branch October 21, 2026 09:16
timosachsenberg added a commit that referenced this pull request Oct 22, 2026
…ein for unspecific cleavage (#10694)

* [FIX] DecoyGenerator::shuffle/shufflePeptides: shuffle the whole protein for unspecific cleavage

Same bug as reversePeptides() (#10686): the digest with 'unspecific cleavage'
is every subsequence of the protein, not a partition of it, so the shuffled
decoy was the concatenation of all of them (455 residues for a 13-residue
protein, millions for a typical protein). There are no enzymatic termini to
keep, so the whole protein is now shuffled as one sequence, as with
'no cleavage'. OpenNuXL's decoy loop, which digests before calling
shufflePeptides(), gets the same guard. An empty protein no longer crashes
shufflePeptides().

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Qb4EiqfmWjGemyt5GPnEyU

* Address review: empty protein guard, one OpenNuXL decoy entry per shuffle

- shufflePeptides(): return an empty protein before building the shuffle unit,
  so 'unspecific cleavage' on an empty protein no longer divides by zero in
  SequenceIdentity_().
- OpenNuXL with 'unspecific cleavage' and NuXL:decoy_factor > 1: each shuffled
  protein is its own decoy entry (DECOY_<id>, DECOY_<id>_2, ...) instead of
  being concatenated, which made decoys longer than the target and gave
  peptides across the junctions.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Qb4EiqfmWjGemyt5GPnEyU

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

major critical issues that are important to fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants