Repository navigation
[ProSE] Default 10/20 ppm tolerances + suffix-aware decoy detection - #9632
timosachsenberg wants to merge 3 commits into
Conversation
…tion Change the ProSEAlgorithm defaults to a precursor mass tolerance of 10 ppm (lower/upper) and a fragment mass tolerance of 20 ppm, matching typical high-resolution Orbitrap settings. Recognise pre-existing decoys whether the configured decoy marker is a prefix or a suffix of the protein accession (e.g. "DECOY_PROT" or "PROT_DECOY"). No extra parameter: isDecoyAccession_() tests both orientations, and detectDecoyStringPosition_() picks the right "decoy_string_position" for PeptideIndexing from the database itself. Adds test coverage for the new defaults and the prefix/suffix detection. Co-Authored-By: Claude Opus 4.8 <[email protected]>
📝 WalkthroughWalkthrough
ChangesProSEAlgorithm decoy strategy model and metadata propagation
Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp`:
- Line 127: The "decoy_prefix" parameter on line 127 lacks validation to ensure
it is non-empty when decoy generation is enabled. This causes a critical issue
where empty decoy markers result in identical decoy and target identifiers at
line 815 (where `e.identifier = decoy_prefix_ + e.identifier`), breaking the
decoy-based FDR logic. Add validation logic to enforce that the decoy_prefix
parameter must be non-empty when decoy generation is enabled, and raise an error
or throw an exception if this constraint is violated.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: af608372-ce09-4e43-aa18-192d54e3f866
📒 Files selected for processing (3)
src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.hsrc/openms/source/ANALYSIS/ID/ProSEAlgorithm.cppsrc/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp
) * [ProSE] Auto decoy mode: detect existing or generate, with suffix support Replace the boolean 'decoys' (true/false) with a three-way mode that lets the user decide less: - auto (default): ensure decoys are available for target-decoy FDR — reuse decoys already present in the database (marker auto-detected via DecoyHelper, prefix or suffix, falling back to decoy_prefix for custom markers) or generate them from the targets if none are found. - generate: always (re)build decoys from the targets; any pre-existing decoys are stripped first to avoid decoy-of-decoy entries. - ignore: search the targets only; any decoys in the database are removed. A single resolveDecoyStrategy_() resolves the decoy handling once per input database into a DecoyStrategy_ (generate / strip / effective marker+position / have_decoys). The result is threaded through every search path (in-memory, chunked, single-context, file-based, multi-file) via the SearchContext and a new searchChunked_ parameter, so PeptideIndexing and picked-protein FDR use the same decoys that were searched. This fixes prior latent bugs where the marker/position for external (non-DECOY_, or suffix) decoys was hardcoded. The effective marker is also surfaced on MultiFileSearchResult so the ProSE tool's -out_merged protein-FDR step recognises the right decoys. FragmentIndex declares its own unused boolean 'decoys' flag; ProSE now hands it FI-safe parameters (fragmentIndexParameters_) so the enum value never trips FI's validation. Supersedes the prefix/suffix helpers from the parent branch with the more capable DecoyHelper-based detection. Updates the class test (auto/generate/ ignore + custom-marker fallback), the TOPP reference inis, and the DDA test commands (the old valueless -Search:decoys flag now takes an explicit value). Co-Authored-By: Claude Opus 4.8 <[email protected]> * [ProSE] Silence DecoyHelper noise on target-only databases DecoyHelper::findDecoyString logged ERROR/WARN ("Unable to determine decoy string...") whenever fewer than 40% of proteins carried a decoy marker. For ProSE's auto/generate modes a target-only database is a normal case (decoys are then synthesised), so the message was misleading noise. Add an opt-in 'quiet' flag (default false → unchanged for all existing callers such as PeptideIndexing) that suppresses these log lines, and pass quiet=true from ProSE's resolveDecoyStrategy_, which handles the negative result itself. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp`:
- Around line 211-310: Add a new test case after the existing test cases that
specifically validates the suffix-decoy strategy path. Create a test scenario
with FASTAEntry identifiers that use decoy markers as suffixes (e.g.,
"sp|P1|A_DECOY") instead of prefixes, configure the decoy_prefix parameter
accordingly, call resolveDecoyStrategy_() and buildDecoyAugmentedDB_() with this
suffix-based database, and verify that the returned DecoyStrategy_ object has
is_prefix set to false while still correctly identifying and handling the
decoys. This ensures the suffix path in resolveDecoyStrategy_() is explicitly
tested and cannot regress undetected.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 372428e3-47ce-4c5c-8119-f2995f14de89
📒 Files selected for processing (9)
src/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.hsrc/openms/include/OpenMS/DATASTRUCTURES/FASTAContainer.hsrc/openms/source/ANALYSIS/ID/ProSEAlgorithm.cppsrc/tests/class_tests/openms/source/ProSEAlgorithm_test.cppsrc/tests/topp/CMakeLists.txtsrc/tests/topp/ProSE_1.inisrc/tests/topp/ProSE_2.inisrc/tests/topp/ProSE_4.inisrc/topp/ProSE.cpp
| START_SECTION(([EXTRA] resolveDecoyStrategy_ / buildDecoyAugmentedDB_: auto/generate/ignore)) | ||
| { | ||
| // Target+decoy database (50% decoys, conventional DECOY_ prefix). | ||
| const std::vector<FASTAFile::FASTAEntry> td_db = { | ||
| FASTAFile::FASTAEntry("sp|P1|A", "", "PEPTIDEKAAR"), | ||
| FASTAFile::FASTAEntry("sp|P2|B", "", "SAMPLERPEPTIDEK"), | ||
| FASTAFile::FASTAEntry("DECOY_sp|P1|A", "", "RAAKEDITPEP"), | ||
| FASTAFile::FASTAEntry("DECOY_sp|P2|B", "", "KEDITPEPRELPMAS") }; | ||
| // Target-only database. | ||
| const std::vector<FASTAFile::FASTAEntry> t_db = { | ||
| FASTAFile::FASTAEntry("sp|P1|A", "", "PEPTIDEKAAR"), | ||
| FASTAFile::FASTAEntry("sp|P2|B", "", "SAMPLERPEPTIDEK") }; | ||
|
|
||
| auto count_prefix = [](const std::vector<FASTAFile::FASTAEntry>& db, const std::string& pre) | ||
| { | ||
| Size n = 0; | ||
| for (const auto& e : db) if (e.identifier.rfind(pre, 0) == 0) ++n; | ||
| return n; | ||
| }; | ||
|
|
||
| // --- auto: reuse existing decoys (detected), do not generate ------------- | ||
| { | ||
| ProSEAlgorithm_test algo; | ||
| Param p = algo.getParameters(); | ||
| p.setValue("decoys", "auto"); | ||
| algo.setParameters(p); | ||
| ProSEAlgorithm_test::DecoyStrategy_ s = algo.resolveDecoyStrategy_(td_db); | ||
| TEST_EQUAL(s.generate, false) | ||
| TEST_EQUAL(s.strip_existing, false) | ||
| TEST_EQUAL(s.have_decoys, true) | ||
| TEST_STRING_EQUAL(s.decoy_string, "DECOY_") | ||
| TEST_EQUAL(s.is_prefix, true) | ||
| // DB is searched unchanged. | ||
| std::vector<FASTAFile::FASTAEntry> built = algo.buildDecoyAugmentedDB_(td_db, s); | ||
| TEST_EQUAL(built.size(), 4) | ||
| TEST_EQUAL(count_prefix(built, "DECOY_"), 2) | ||
| } | ||
|
|
||
| // --- auto: no decoys present -> generate them --------------------------- | ||
| { | ||
| ProSEAlgorithm_test algo; | ||
| Param p = algo.getParameters(); | ||
| p.setValue("decoys", "auto"); | ||
| algo.setParameters(p); | ||
| ProSEAlgorithm_test::DecoyStrategy_ s = algo.resolveDecoyStrategy_(t_db); | ||
| TEST_EQUAL(s.generate, true) | ||
| TEST_EQUAL(s.strip_existing, false) | ||
| TEST_EQUAL(s.have_decoys, true) | ||
| TEST_STRING_EQUAL(s.decoy_string, "DECOY_") | ||
| std::vector<FASTAFile::FASTAEntry> built = algo.buildDecoyAugmentedDB_(t_db, s); | ||
| TEST_EQUAL(built.size(), 4) // 2 targets + 2 generated decoys | ||
| TEST_EQUAL(count_prefix(built, "DECOY_"), 2) | ||
| } | ||
|
|
||
| // --- ignore: strip existing decoys, search targets only ----------------- | ||
| { | ||
| ProSEAlgorithm_test algo; | ||
| Param p = algo.getParameters(); | ||
| p.setValue("decoys", "ignore"); | ||
| algo.setParameters(p); | ||
| ProSEAlgorithm_test::DecoyStrategy_ s = algo.resolveDecoyStrategy_(td_db); | ||
| TEST_EQUAL(s.generate, false) | ||
| TEST_EQUAL(s.strip_existing, true) | ||
| TEST_EQUAL(s.have_decoys, false) | ||
| std::vector<FASTAFile::FASTAEntry> built = algo.buildDecoyAugmentedDB_(td_db, s); | ||
| TEST_EQUAL(built.size(), 2) // decoys removed | ||
| TEST_EQUAL(count_prefix(built, "DECOY_"), 0) | ||
| } | ||
|
|
||
| // --- generate: strip pre-existing decoys, then regenerate from targets --- | ||
| { | ||
| ProSEAlgorithm_test algo; | ||
| Param p = algo.getParameters(); | ||
| p.setValue("decoys", "generate"); | ||
| algo.setParameters(p); | ||
| ProSEAlgorithm_test::DecoyStrategy_ s = algo.resolveDecoyStrategy_(td_db); | ||
| TEST_EQUAL(s.generate, true) | ||
| TEST_EQUAL(s.strip_existing, true) | ||
| TEST_EQUAL(s.have_decoys, true) | ||
| std::vector<FASTAFile::FASTAEntry> built = algo.buildDecoyAugmentedDB_(td_db, s); | ||
| TEST_EQUAL(built.size(), 4) // 2 targets + 2 freshly generated | ||
| TEST_EQUAL(count_prefix(built, "DECOY_"), 2) | ||
| } | ||
|
|
||
| // --- custom marker outside the common vocabulary: literal fall-back ----- | ||
| { | ||
| ProSEAlgorithm_test algo; | ||
| Param p = algo.getParameters(); | ||
| p.setValue("decoys", "auto"); | ||
| p.setValue("decoy_prefix", "BOGUS_"); | ||
| algo.setParameters(p); | ||
| const std::vector<FASTAFile::FASTAEntry> custom_db = { | ||
| FASTAFile::FASTAEntry("sp|P1|A", "", "PEPTIDEKAAR"), | ||
| FASTAFile::FASTAEntry("BOGUS_sp|P1|A", "", "RAAKEDITPEP") }; | ||
| ProSEAlgorithm_test::DecoyStrategy_ s = algo.resolveDecoyStrategy_(custom_db); | ||
| TEST_EQUAL(s.generate, false) // existing decoys recognised via fall-back | ||
| TEST_EQUAL(s.have_decoys, true) | ||
| TEST_STRING_EQUAL(s.decoy_string, "BOGUS_") | ||
| TEST_EQUAL(s.is_prefix, true) | ||
| } |
There was a problem hiding this comment.
Add an explicit suffix-decoy strategy test case.
This section validates only prefix-oriented decoy markers. The suffix path (is_prefix == false) for resolveDecoyStrategy_() is not asserted, so the core suffix-aware behavior can regress undetected.
Suggested test addition
// --- custom marker outside the common vocabulary: literal fall-back -----
{
ProSEAlgorithm_test algo;
@@
TEST_STRING_EQUAL(s.decoy_string, "BOGUS_")
TEST_EQUAL(s.is_prefix, true)
}
+
+ // --- auto: reuse existing suffix decoys -------------------------------
+ {
+ ProSEAlgorithm_test algo;
+ Param p = algo.getParameters();
+ p.setValue("decoys", "auto");
+ algo.setParameters(p);
+ const std::vector<FASTAFile::FASTAEntry> suffix_db = {
+ FASTAFile::FASTAEntry("sp|P1|A", "", "PEPTIDEKAAR"),
+ FASTAFile::FASTAEntry("sp|P2|B", "", "SAMPLERPEPTIDEK"),
+ FASTAFile::FASTAEntry("sp|P1|A_DECOY", "", "RAAKEDITPEP"),
+ FASTAFile::FASTAEntry("sp|P2|B_DECOY", "", "KEDITPEPRELPMAS") };
+ ProSEAlgorithm_test::DecoyStrategy_ s = algo.resolveDecoyStrategy_(suffix_db);
+ TEST_EQUAL(s.generate, false)
+ TEST_EQUAL(s.strip_existing, false)
+ TEST_EQUAL(s.have_decoys, true)
+ TEST_EQUAL(s.is_prefix, false)
+ }Based on learnings from PR objectives, suffix-aware decoy classification is a required behavior and should be explicitly covered in tests.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp` around lines 211
- 310, Add a new test case after the existing test cases that specifically
validates the suffix-decoy strategy path. Create a test scenario with FASTAEntry
identifiers that use decoy markers as suffixes (e.g., "sp|P1|A_DECOY") instead
of prefixes, configure the decoy_prefix parameter accordingly, call
resolveDecoyStrategy_() and buildDecoyAugmentedDB_() with this suffix-based
database, and verify that the returned DecoyStrategy_ object has is_prefix set
to false while still correctly identifying and handling the decoys. This ensures
the suffix path in resolveDecoyStrategy_() is explicitly tested and cannot
regress undetected.
Summary
Two small ProSE (
ProSEAlgorithm) changes requested by the user:New default mass tolerances matching typical high-resolution Orbitrap settings:
precursor:mass_tolerance_lower/_upper: 20 → 10 ppmfragment:mass_tolerance: 10 → 20 ppmSuffix-aware decoy detection. Previously ProSE classified a protein as a decoy only when its accession started with
decoy_prefix(StringUtils::hasPrefix). Databases that tag decoys at the end (e.g.PROT_DECOY) were silently treated as targets. Now both orientations of the same marker are recognised — no new parameter:isDecoyAccession_()tests the marker as prefix or suffix.detectDecoyStringPosition_()inspects the database and passes the correctdecoy_string_position(prefix/suffix) toPeptideIndexing, instead of the previously hardcoded"prefix".The
decoy_prefixparameter description was updated to reflect that the marker is matched as either prefix or suffix.Tests
Added two sections to
ProSEAlgorithm_test.cpp:ctest -R ProSEAlgorithm_testpasses locally.🤖 Generated with Claude Code
Summary by CodeRabbit
-Search:decoys(auto|generate|ignore).-Search:decoys auto/ string-based decoy modes.