Skip to content

[ProSE] Auto decoy mode (detect-or-generate, prefix/suffix aware) - #9634

Merged
timosachsenberg merged 2 commits into
feat/prose-default-tolerances-suffix-decoysfrom
feat/prose-decoy-auto-mode
Jun 19, 2026
Merged

timosachsenberg merged 2 commits into
feat/prose-default-tolerances-suffix-decoysfrom
feat/prose-decoy-auto-mode

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Makes ProSE's decoy handling decide-less: replaces the boolean Search:decoys (true/false) with a three-way mode.

mode target+decoy DB target-only DB
auto (default) reuse existing decoys (marker auto-detected) generate decoys
generate strip existing, regenerate from targets generate decoys
ignore strip decoys → target-only target-only

auto always ensures decoys are present for target-decoy FDR — the user typically just sets an FDR threshold and nothing else. ignore is the explicit opt-out for a pure target-only search.

How it works

A single resolveDecoyStrategy_(db) resolves decoy handling once per input database into a DecoyStrategy_ (generate / strip-existing / effective marker+position / have_decoys). Existing decoys are detected with the codebase's DecoyHelper::findDecoyString (common-marker vocabulary, prefix or suffix), falling back to a literal decoy_prefix scan for custom markers.

The strategy is threaded through every search path (in-memory, chunked, single-context, file-based, multi-file) via 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 decoy marker/position was hardcoded (decoy_prefix + prefix) for the protein-FDR and PeptideIndexing steps — wrong for external suffix/non-DECOY_ decoys.

The effective marker is also surfaced on MultiFileSearchResult so the ProSE tool's -out_merged cross-file protein-FDR recognises the right decoys.

FragmentIndex param collision

FragmentIndex declares its own (unused) boolean decoys flag {true,false}. ProSE forwards getParameters() to it, so the new enum value would trip FI's validation. ProSE now hands FI sanitised params via fragmentIndexParameters_() (overrides decoys to false; ProSE manages decoys at the DB level).

Relationship to #9632

Stacked on feat/prose-default-tolerances-suffix-decoys (#9632). This supersedes that PR's isDecoyAccession_/detectDecoyStringPosition_ helpers with the more capable DecoyHelper-based detection. Base retargets to develop once #9632 merges.

Behavior change

  • Default flips from false (no decoys, FDR silently skipped on target-only DBs) to auto (decoys ensured). Strict improvement; concatenated target+decoy DBs are unchanged (existing decoys reused, never double-generated).
  • decoys valid-strings change bool→enum (no bool compat) — the three TOPP reference inis and the DDA test commands (old valueless -Search:decoys flag) are updated.

Tests

  • ProSEAlgorithm_test: new section covering auto-reuse / auto-generate / ignore-strip / generate-strip-regenerate / custom-marker fallback.
  • All 19 TOPP_ProSE* tests pass, including the DDA FDR PSM-count floors (≥4350 / 4650 / 4400) on real Bruker data — confirming auto-mode generates decoys with equivalent FDR yields.

🤖 Generated with Claude Code

timosachsenberg and others added 2 commits June 19, 2026 12:51
…port

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]>
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]>
@timosachsenberg
timosachsenberg merged commit 84ad389 into feat/prose-default-tolerances-suffix-decoys Jun 19, 2026
1 check passed
@timosachsenberg
timosachsenberg deleted the feat/prose-decoy-auto-mode branch June 19, 2026 11:54
timosachsenberg added a commit that referenced this pull request Jun 20, 2026
…o decoy mode) (#9637)

Two recently merged PRs were missing from the 3.6.0 changelog:
- #9521: MSImagingRegion + multi-region support in MSImagingGeometry/MSImagingExperiment
- #9634: ProSE Search:decoys three-way enum (auto/generate/ignore) replacing the boolean


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

Co-authored-by: Claude <[email protected]>
timosachsenberg added a commit that referenced this pull request Jun 21, 2026
…led with FDR decoupling (#9644)

* [ProSE] New default tolerances (10/20 ppm) + suffix-aware decoy detection

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]>

* [ProSE] Auto decoy mode (detect-or-generate, prefix/suffix aware) (#9634)

* [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]>

* [ProSE] decoys=auto: keep always-generate; add discoverability + out_pin guard

Per the codex/opus design discussion: do NOT FDR-gate decoys=auto. ProSE's external/
downstream-FDR workflows (ProSE -> FalseDiscoveryRate on idXML, ProSE -> Percolator)
and deferred/sharded FDR rely on auto producing target+decoy PSMs even when no
ProSE-level FDR is requested; ProSE cannot detect that an external FDR step is coming,
and FalseDiscoveryRate on a decoy-free idXML silently assigns q=0 rather than failing.
So "generate whenever decoys are absent" is the correct, safe default.

Two small hardenings:
- INFO log when auto generates decoys with no ProSE FDR, pointing at decoys=ignore for
  a genuinely target-only search (discoverability for the ~2x index/scoring cost).
- Warn when -out_pin is requested but the run is target-only (decoys=ignore): the .pin
  would contain no decoys and external Percolator cannot estimate FDR from it. Mirrors
  the existing in-process Percolator decoy guard.
- Value-form wording in the in-process Percolator decoy warning.

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

* [ProSE] decoy-auto landing: opus+codex review fixes

Thorough opus+codex review of the #9634/#9633 reconciliation (verdict: ship-with-fixes,
no blockers). Address the agreed in-scope items:

- Empty-marker guards (both reviewers): applyCompleteSetProteinFDR early-returns with a
  warning on an empty decoy marker (hasPrefix(x,"") is always true -> would treat all
  proteins as decoys); buildDecoyAugmentedDB_ throws if asked to generate with an empty
  decoy_prefix (decoy accessions would equal their targets); the merged-path protein-FDR
  guard also skips on an empty marker.
- TOPP -out_merged alone is no longer rejected as "no output specified".
- pyOpenMS test_modification_discovery.py: decoys true/false -> generate/ignore (the old
  boolean values are invalid under the new {auto,generate,ignore} enum and would throw).
- Coverage: a suffix-marker resolveDecoyStrategy_ unit case (the prefix-OR-suffix headline
  feature was prefix-only tested) and an unconditional TOPP_ProSE_8_auto end-to-end test
  (decoys=auto previously ran only under the WITH_OPENTIMS-gated Bruker tests).

Deferred as pre-existing follow-ups (not #9634-introduced): the library
searchWithModificationAnalysis overload not finalizing protein FDR; .pin/Percolator guards
using DB-level vs PSM-level decoy labels.

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

* [ProSE] review follow-ups: tolerance-default visibility + decoy diagnostics

From the second opus+codex review of #9644 (keep the 10 ppm precursor default):
- CHANGELOG: document the default tolerance change (precursor 20->10, fragment 10->20 ppm)
  that was otherwise bundled silently; note the calibration-drift caveat.
- Fix stale member initializers precursor_mass_tolerance_lower_/upper_ {20.0} -> {10.0} so
  they match the param default (they are read in the const search() path).
- decoys=auto now logs the auto-detected decoy marker when reusing existing decoys (prefix or
  suffix), so a rare DecoyHelper misdetection is diagnosable (previously reuse logged nothing).
- decoys=generate warns when the database carries sub-threshold decoy-like accessions that are
  not stripped (would become decoys-of-decoys), pointing at -Search:decoy_prefix.

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

---------

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

1 participant