Skip to content

[FIX] ProSE: apply protein FDR for single-file runs; never per-file in multi-file - #9633

Merged
timosachsenberg merged 11 commits into
OpenMS:developfrom
timosachsenberg:fix/prose-protein-fdr-single-file
Jun 21, 2026
Merged

timosachsenberg merged 11 commits into
OpenMS:developfrom
timosachsenberg:fix/prose-protein-fdr-single-file

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Picked-protein FDR is statistically valid only on a complete protein set, because FDR does not compose across runs (filtering each run at α% and pooling does not yield α% combined FDR — false positives accumulate). ProSE applied protein FDR only to the merged (-out_merged) output, so -Search:FDR:protein was silently ignored for:

  • single-file runs, and
  • the per-file outputs (-out_idxml/-out_qpx/-out_parquet) of multi-file runs.

Fix

  • Single input file → a single file is a complete experiment, so run protein inference (BasicProteinInferenceAlgorithm) + picked-protein FDR + cleanup on it. Warn if no decoy proteins were identified.
  • Multiple files without -out_merged → do not filter per file (would not control the combined FDR); warn loudly and strip the now-purposeless decoys from per-file outputs.
  • Multiple files with -out_merged → unchanged (already correct).
  • Per-file protein FDR in a multi-file run is deliberately never done.

Also fixes a latent protein-group consistency bug in all three picked-protein-FDR paths (ProSE single-file & merged blocks, ProSEAlgorithm::search file overload): after filterHitsByScore removes protein hits, the BPIA-created indistinguishable-protein / protein groups (and peptide evidence) dangled to removed decoy proteins, so idXML storage failed. Added IDFilter::updateProteinGroups + removeDanglingProteinReferences.

Tests

  • ProSEAlgorithm_test — pins the statistical contract: single-file search applies protein FDR (decoys removed) and the result stores + reloads as valid idXML; in-memory search(spectra, db) applies PSM FDR only (decoys survive). This is what caught the dangling-reference bug.
  • TOPP_ProSE_6_fdr — single-file protein-FDR application on the DatabaseSuitability spectra (49-protein DB, decoys generated): identified decoy proteins are removed, 47 targets are reported with protein q-values, and the output stores as valid idXML.

Note

The TOPP_ProSE_6_fdr reference (ProSE_6_fdr_out.idXML, ~2.2 MB / 895 PSMs) is large because it reuses realistic spectra from the existing DatabaseSuitability test data (6.2 MB input). Happy to trim to a spectra subset if preferred.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DUERCXwWLaTofz6K5aomjy

Summary by CodeRabbit

  • New Features

    • Increased the default fragment:mass_tolerance value (10.0 → 20.0).
  • Bug Fixes

    • Improved FDR behavior by retaining decoys during PSM-level filtering and deferring decoy removal to the protein-level finalization step.
    • Ensured IDXML integrity after protein filtering by aligning indistinguishable proteins and protein groups and removing dangling protein references.
  • Documentation

    • Clarified decoy reporting rules and the scope of protein-level FDR (single-file vs merged outputs).
  • Tests

    • Expanded protein-FDR and merged-output regression coverage, including deterministic IDXML/TSV diffing and store/load validation.

…file in multi-file

Picked-protein FDR is statistically valid only on a COMPLETE protein set (FDR does not compose across runs). ProSE applied it only to the merged (-out_merged) output, silently ignoring FDR:protein for single-file and per-file outputs.

- Single input file: run protein inference (BasicProteinInferenceAlgorithm) + picked-protein FDR + group/decoy cleanup (a single file is a complete experiment); warn if no decoy proteins were identified. - Multiple files without -out_merged: do NOT filter per file (would not control the combined FDR); warn loudly and strip now-purposeless decoys from per-file outputs. - Multiple files with -out_merged: unchanged.

Fix protein-group consistency after picked-protein FDR in all three paths (ProSE single-file and merged blocks, ProSEAlgorithm::search file overload): IDFilter::updateProteinGroups + removeDanglingProteinReferences, without which idXML storage fails on references to removed decoy proteins.

Tests: ProSEAlgorithm_test pins the contract (single-file applies protein FDR -> decoys removed, result stores+reloads as valid idXML; in-memory search applies PSM FDR only -> decoys survive). TOPP_ProSE_6_fdr exercises single-file protein-FDR application on DatabaseSuitability spectra (decoys generated, identified decoys removed, valid idXML).

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

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

PSM-level FDR filtering is updated across all ProSEAlgorithm search paths to retain decoys (add_decoy_peptides=true), deferring decoy/empty/unreferenced-protein removal to a new conditional protein-level FDR finalization block in ProSE.cpp. Single-file runs with detected decoys now apply picked-protein FDR and synchronize protein group consistency; merged output cleanup is similarly conditioned on user_protein_fdr > 0. IDXML consistency is maintained by updating indistinguishable proteins, protein groups, and removing dangling references. New unit and integration tests validate file-path and in-memory overload contracts and IDXML persistence. Fragment mass tolerance default is increased from 10.0 to 20.0.

Changes

ProSE Protein-Level FDR Filtering and Decoy Deferral

Layer / File(s) Summary
PSM-level FDR decoy retention and parameter defaults
src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp, src/topp/ProSE.cpp
Updates FDR:PSM parameter documentation to specify decoy retention and reiterates -decoys requirement. Modifies chunked, non-chunked in-memory, and multi-file chunk search paths to set add_decoy_peptides=true and remove prior conditional decoy cleanup. Updates ProSE.cpp comment describing PSM FDR as decoy-retaining with removal deferred to protein-level FDR finalization. Increases fragment:mass_tolerance default from 10.0 to 20.0.
Single-file protein-level FDR finalization and IDXML consistency
src/topp/ProSE.cpp, src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp
Adds conditional user_protein_fdr > 0 block in ProSE.cpp running picked-protein inference, applying picked-protein protein FDR, filtering proteins, removing decoy/empty/unreferenced/dangling entries, and synchronizing indistinguishable proteins and protein groups; warns and skips without decoys or for multi-file runs lacking -out_merged. Adds IDXML maintenance in ProSEAlgorithm.cpp after protein-hit filtering to synchronize protein groups and remove dangling references. Updates Doxygen documentation for decoy-reporting scope tied to protein-level FDR.
Merged output cleanup and metadata
src/topp/ProSE.cpp
Adds DateTime.h include and sets merged protein identification timestamp. Conditions merged idXML cleanup (decoy/empty/unreferenced/dangling removal and IDFilter::updateProteinGroups for indistinguishable proteins and protein groups) on user_protein_fdr > 0.
Synthetic data builder for FDR unit tests
src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp
Adds FileHandler and standard-library headers. Introduces buildSyntheticProteinFDRData helper populating a 10-protein FASTA database, digesting with Trypsin, applying fixed Carbamidomethyl(C), and generating deterministic synthetic MS2 PeakMap with theoretical spectra and shifted precursor m/z values using seeded RNG.
Unit tests for file-path and in-memory search overloads
src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp
Tests file-path single-file with FDR:protein > 0 (decoy protein removal and idXML round-trip), file-path with FDR:protein == 0 (decoy protein retention and PSM evidence persistence), and in-memory overloads (protein FDR not applied, decoy PSMs survive PSM-level FDR filtering).
CTest integration tests for single-file and merged workflows
src/tests/topp/CMakeLists.txt
Adds TOPP_ProSE_6 (single-file protein-FDR run with FuzzyDiff idXML comparison) and TOPP_ProSE_7 (multi-file merge with FileInfo TSV generation and golden TSV diffing) with dependency wiring through the pipeline.

Sequence Diagram(s)

sequenceDiagram
    rect rgba(100, 149, 237, 0.5)
        Note over ProSE,FDREstimator: PSM-level FDR (all search paths)
    end
    ProSE->>ProSEAlgorithm: search(spectra/files, fasta_db, params)
    ProSEAlgorithm->>FDREstimator: FDR:PSM filtering (add_decoy_peptides=true)
    FDREstimator-->>ProSEAlgorithm: Annotated PSMs with decoys retained

    rect rgba(144, 238, 144, 0.5)
        Note over ProSE,IDFilter: Protein-level FDR (file-path only, user_protein_fdr > 0)
    end
    ProSEAlgorithm-->>ProSE: Identifications with decoys
    ProSE->>BasicProteinInference: Infer proteins from target+decoy PSMs
    BasicProteinInference-->>ProSE: Protein groups
    ProSE->>PickedProteinFDR: applyPickedProteinFDR
    PickedProteinFDR-->>ProSE: FDR-scored proteins
    ProSE->>IDFilter: Remove decoys/empty/unreferenced
    IDFilter-->>ProSE: Cleaned protein hits
    ProSE->>IDFilter: updateProteinGroups
    IDFilter-->>ProSE: Synchronized indistinguishable and groups
    ProSE->>IDFilter: removeDanglingProteinReferences
    IDFilter-->>ProSE: Final consistent idXML
Loading

Possibly Related PRs

  • OpenMS/OpenMS#9558: Adds unit tests for IDFilter::removeDanglingProteinReferences on ConsensusMap overloads — directly related to the dangling-reference cleanup step this PR now calls during protein-level FDR finalization.

Poem

🐇 Hippity-hoppity, decoys stay near,
Till protein FDR says "time to disappear!"
PSM filters now wave them right through,
While protein groups stay synchronized and true.
The rabbit ensures each dangling ref is gone,
Consistent idXML carries the search along! 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% 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 The title accurately and specifically describes the core change: applying protein FDR to single-file runs while preventing per-file application in multi-file scenarios.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 27-28: Remove the unused include statement `#include`
<OpenMS/IONMOBILITY/IMTypes.h> from the includes section of the test file. This
header is not referenced anywhere in the test file, whereas the IDFilter.h
include remains necessary and should be kept since it is used for the
filterHitsByScore, removeDecoyHits, and removeEmptyIdentifications functions.
🪄 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: dd2c893e-1aff-4f9a-bd42-8282230ec21d

📥 Commits

Reviewing files that changed from the base of the PR and between 147205a and c4f5093.

📒 Files selected for processing (6)
  • src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp
  • src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/ProSE_6_fdr.ini
  • src/tests/topp/ProSE_6_fdr_out.idXML
  • src/topp/ProSE.cpp

Comment on lines 27 to 28
#include <OpenMS/PROCESSING/ID/IDFilter.h>
#include <OpenMS/IONMOBILITY/IMTypes.h>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if IDFilter or IMTypes symbols are used directly in the test file
rg -n 'IDFilter|IMTypes' src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp

Repository: OpenMS/OpenMS

Length of output: 291


Remove the unused IMTypes.h include.

IDFilter.h is necessary (used at lines 835-837 for IDFilter::filterHitsByScore, IDFilter::removeDecoyHits, and IDFilter::removeEmptyIdentifications), but IMTypes.h is not referenced anywhere in the test file and should be removed from line 28.

🤖 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 27
- 28, Remove the unused include statement `#include`
<OpenMS/IONMOBILITY/IMTypes.h> from the includes section of the test file. This
header is not referenced anywhere in the test file, whereas the IDFilter.h
include remains necessary and should be kept since it is used for the
filterHitsByScore, removeDecoyHits, and removeEmptyIdentifications functions.

@jpfeuffer

jpfeuffer commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Question: Is there still a way to do FDR later?

E.g. have e.g. 1000 files on one compute node, 1000 files on another, run searching on each node without FDR.
Read all parquets at once and do global FDR?

Decoy removal is now a protein-FDR finalization step. PSM-level FDR
annotates + filters but never strips decoys (add_decoy_peptides=true on
FalseDiscoveryRate, which otherwise drops them at its default). Decoys are
removed only when protein FDR finalizes a complete result: a single-file
run, or the -out_merged aggregate. With FDR:protein=0 decoys are retained
in every output, so a sharded search (one file per node, protein FDR off)
preserves target+decoy evidence for a later global/merged FDR.

- ProSEAlgorithm: decouple PSM-FDR from decoy removal at all 3 PSM-FDR
  sites; keep the file-based single-file picked-protein-FDR strip.
- ProSE TOPP: per-file outputs retain decoys; single-file FDR:protein>0
  finalizes (strips); multi-file FDR:protein>0 without -out_merged warns
  and leaves per-file intermediates intact; merged strips only when
  FDR:protein>0.
- Docs: @note block + FDR:PSM/FDR:protein tooltips describe the contract.
- Tests: unit tests pin decoy retention (in-memory + file-based PSM-only);
  new check_decoys.cmake helper + TOPP cases cover every tool branch
  (single finalize/intermediate, multi+merged, multi-no-merged). Whitelist
  the build-varying InferenceEngineVersion in ProSE_6_fdr_out (the
  identification content is unchanged).

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (2)
src/tests/topp/CMakeLists.txt (1)

3246-3251: ⚡ Quick win

Cover both per-file outputs in multi-file decoy assertions.

TOPP_ProSE_8_* and TOPP_ProSE_9_* validate decoy behavior on only *_a.tmp.idXML. Since both per-file outputs are produced, this can miss asymmetric regressions in the second output path.

Suggested patch
 add_test(NAME "TOPP_ProSE_8_perfile_decoys_present" COMMAND ${CMAKE_COMMAND} -P
   ${CMAKE_CURRENT_SOURCE_DIR}/check_decoys.cmake ${TESTS_TEMP_DIR}/ProSE_8_a.tmp.idXML present)
 set_tests_properties("TOPP_ProSE_8_perfile_decoys_present" PROPERTIES DEPENDS "TOPP_ProSE_8_merged")
+add_test(NAME "TOPP_ProSE_8_perfile_decoys_present_b" COMMAND ${CMAKE_COMMAND} -P
+  ${CMAKE_CURRENT_SOURCE_DIR}/check_decoys.cmake ${TESTS_TEMP_DIR}/ProSE_8_b.tmp.idXML present)
+set_tests_properties("TOPP_ProSE_8_perfile_decoys_present_b" PROPERTIES DEPENDS "TOPP_ProSE_8_merged")
 add_test(NAME "TOPP_ProSE_8_merged_decoys_absent" COMMAND ${CMAKE_COMMAND} -P
   ${CMAKE_CURRENT_SOURCE_DIR}/check_decoys.cmake ${TESTS_TEMP_DIR}/ProSE_8_merged.tmp.idXML absent)
 set_tests_properties("TOPP_ProSE_8_merged_decoys_absent" PROPERTIES DEPENDS "TOPP_ProSE_8_merged")
@@
 add_test(NAME "TOPP_ProSE_9_perfile_decoys_present" COMMAND ${CMAKE_COMMAND} -P
   ${CMAKE_CURRENT_SOURCE_DIR}/check_decoys.cmake ${TESTS_TEMP_DIR}/ProSE_9_a.tmp.idXML present)
 set_tests_properties("TOPP_ProSE_9_perfile_decoys_present" PROPERTIES DEPENDS "TOPP_ProSE_9_multi_no_merged")
+add_test(NAME "TOPP_ProSE_9_perfile_decoys_present_b" COMMAND ${CMAKE_COMMAND} -P
+  ${CMAKE_CURRENT_SOURCE_DIR}/check_decoys.cmake ${TESTS_TEMP_DIR}/ProSE_9_b.tmp.idXML present)
+set_tests_properties("TOPP_ProSE_9_perfile_decoys_present_b" PROPERTIES DEPENDS "TOPP_ProSE_9_multi_no_merged")

Also applies to: 3262-3264

🤖 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/topp/CMakeLists.txt` around lines 3246 - 3251, The current test
assertions for TOPP_ProSE_8 only validate decoy behavior on the first per-file
output (_a.tmp.idXML) and the merged output, but since both per-file outputs are
generated, add additional test assertions to also validate the second per-file
output (_b.tmp.idXML) with the same decoy expectations. This will catch
asymmetric regressions in the second output. Apply the same fix to the
TOPP_ProSE_9 tests mentioned in the comment (lines 3262-3264) to ensure
consistent test coverage across both ProSE test cases.
src/topp/ProSE.cpp (1)

483-491: ⚡ Quick win

Use \n instead of endl in the new warning.

This warning is on a changed line and endl forces a flush. Prefer a newline literal with OPENMS_LOG_WARN.

Suggested change
                           << "outputs (-out_idxml/-out_qpx/-out_parquet) retain target+decoy "
                           << "evidence as intermediates. Use -out_merged to obtain protein FDR "
                           << "over the aggregated set, or pool the per-file outputs and apply "
-                          << "FDR downstream (e.g. IDMerger -> ProteinInference -> FalseDiscoveryRate)." << endl;
+                          << "FDR downstream (e.g. IDMerger -> ProteinInference -> FalseDiscoveryRate).\n";

As per coding guidelines, “Avoid std::endl for performance; prefer \n.”

🤖 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/topp/ProSE.cpp` around lines 483 - 491, The OPENMS_LOG_WARN statement
about FDR protein filtering currently ends with endl, which forces a buffer
flush and has performance implications. Replace the endl at the end of the
OPENMS_LOG_WARN chain with a newline literal \n to align with coding guidelines
that prefer \n over endl for better performance.

Source: Coding guidelines

🤖 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 176: The description string for the "FDR:PSM" default value setting
contains misleading wording that suggests decoys are never removed by FDR
filtering. Revise the description to clarify that while add_decoy_peptides keeps
decoys eligible for the result set, the subsequent IDFilter::filterHitsByScore
call still applies the FDR:PSM threshold to filter decoy PSMs by q-value.
Replace the phrase "never removes decoys" with language that accurately reflects
that decoys are subject to FDR filtering by q-value, but are not removed through
a dedicated decoy-specific stripping step. Apply this same clarification to all
occurrences of this description at lines 1298-1301, 1571-1574, and 1999-2002 to
maintain consistency across the codebase.
- Around line 2003-2013: The code currently silently skips PSM FDR filtering
when has_decoys is false, without notifying the user. Add a warning message that
triggers when fdr_psm_ is greater than 0.0 but has_decoys is false, alerting
users that FDR filtering was requested but could not be applied due to missing
decoys. This warning should be added in an else clause or as a separate
condition after the existing if (fdr_psm_ > 0.0 && has_decoys) block to maintain
consistency with other search paths in the codebase.

In `@src/topp/ProSE.cpp`:
- Line 66: The documentation note in ProSE.cpp currently states that PSM-level
FDR "never removes decoys," but this is inaccurate since the PSM FDR filtering
applies IDFilter::filterHitsByScore() which can remove decoy PSMs through
q-value thresholding. Rephrase the relevant section to say "no decoy-specific
stripping" instead of "never removes decoys" to accurately reflect that decoys
are removed through the q-value threshold filtering, not through explicit
decoy-only logic. Apply this same wording change at lines 386-387 where the same
inaccurate phrasing appears.
- Around line 770-779: The `removeDecoyHits` function is being called on
`merged_peptides` but not on `merged_protein_ids`, which allows decoy protein
accessions to persist in the output. Add a call to
`IDFilter::removeDecoyHits(merged_protein_ids)` immediately after or alongside
the existing `IDFilter::removeDecoyHits(merged_peptides)` call to ensure decoy
proteins are also removed during the merged finalization process, consistent
with the codebase patterns in IDFilter.cpp.

---

Nitpick comments:
In `@src/tests/topp/CMakeLists.txt`:
- Around line 3246-3251: The current test assertions for TOPP_ProSE_8 only
validate decoy behavior on the first per-file output (_a.tmp.idXML) and the
merged output, but since both per-file outputs are generated, add additional
test assertions to also validate the second per-file output (_b.tmp.idXML) with
the same decoy expectations. This will catch asymmetric regressions in the
second output. Apply the same fix to the TOPP_ProSE_9 tests mentioned in the
comment (lines 3262-3264) to ensure consistent test coverage across both ProSE
test cases.

In `@src/topp/ProSE.cpp`:
- Around line 483-491: The OPENMS_LOG_WARN statement about FDR protein filtering
currently ends with endl, which forces a buffer flush and has performance
implications. Replace the endl at the end of the OPENMS_LOG_WARN chain with a
newline literal \n to align with coding guidelines that prefer \n over endl for
better performance.
🪄 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: 197c7fe0-bd22-422c-947f-3bca87b3a3b4

📥 Commits

Reviewing files that changed from the base of the PR and between c4f5093 and 19b78f0.

📒 Files selected for processing (5)
  • src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp
  • src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp
  • src/tests/topp/CMakeLists.txt
  • src/tests/topp/check_decoys.cmake
  • src/topp/ProSE.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tests/class_tests/openms/source/ProSEAlgorithm_test.cpp

Comment on lines 2003 to 2013
bool has_decoys = std::any_of(full_db.begin(), full_db.end(),
[this](const FASTAFile::FASTAEntry& e) { return StringUtils::hasPrefix(e.identifier, decoy_prefix_); });
if (fdr_psm_ > 0.0 && has_decoys)
{
FalseDiscoveryRate fdr;
Param fdr_params = fdr.getParameters();
fdr_params.setValue("add_decoy_peptides", "true"); // retain decoys: PSM FDR annotates, never strips
fdr.setParameters(fdr_params);
fdr.apply(result.peptide_ids);
IDFilter::filterHitsByScore(result.peptide_ids, fdr_psm_);
if (fdr_protein_ == 0.0)
{
IDFilter::removeDecoyHits(result.peptide_ids);
IDFilter::removeEmptyIdentifications(result.peptide_ids);
IDFilter::removeUnreferencedProteins(result.protein_ids, result.peptide_ids);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Warn when chunk-major PSM FDR is requested without decoys.

This branch silently skips FDR:PSM when has_decoys is false, unlike the other search paths. Add the same warning here so chunked multi-file users do not mistake unfiltered output for PSM-FDR-filtered output.

Suggested warning path
         if (fdr_psm_ > 0.0 && has_decoys)
         {
           FalseDiscoveryRate fdr;
           Param fdr_params = fdr.getParameters();
           fdr_params.setValue("add_decoy_peptides", "true"); // retain decoys: PSM FDR annotates, never strips
           fdr.setParameters(fdr_params);
           fdr.apply(result.peptide_ids);
           IDFilter::filterHitsByScore(result.peptide_ids, fdr_psm_);
         }
+        else if (fdr_psm_ > 0.0 && !has_decoys)
+        {
+          OPENMS_LOG_WARN << "FDR:PSM is set but no decoys found (decoy_prefix='" << decoy_prefix_
+                          << "'). Provide a FASTA with decoy proteins or enable '-decoys'. Skipping FDR filtering.\n";
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
bool has_decoys = std::any_of(full_db.begin(), full_db.end(),
[this](const FASTAFile::FASTAEntry& e) { return StringUtils::hasPrefix(e.identifier, decoy_prefix_); });
if (fdr_psm_ > 0.0 && has_decoys)
{
FalseDiscoveryRate fdr;
Param fdr_params = fdr.getParameters();
fdr_params.setValue("add_decoy_peptides", "true"); // retain decoys: PSM FDR annotates, never strips
fdr.setParameters(fdr_params);
fdr.apply(result.peptide_ids);
IDFilter::filterHitsByScore(result.peptide_ids, fdr_psm_);
if (fdr_protein_ == 0.0)
{
IDFilter::removeDecoyHits(result.peptide_ids);
IDFilter::removeEmptyIdentifications(result.peptide_ids);
IDFilter::removeUnreferencedProteins(result.protein_ids, result.peptide_ids);
}
}
bool has_decoys = std::any_of(full_db.begin(), full_db.end(),
[this](const FASTAFile::FASTAEntry& e) { return StringUtils::hasPrefix(e.identifier, decoy_prefix_); });
if (fdr_psm_ > 0.0 && has_decoys)
{
FalseDiscoveryRate fdr;
Param fdr_params = fdr.getParameters();
fdr_params.setValue("add_decoy_peptides", "true"); // retain decoys: PSM FDR annotates, never strips
fdr.setParameters(fdr_params);
fdr.apply(result.peptide_ids);
IDFilter::filterHitsByScore(result.peptide_ids, fdr_psm_);
}
else if (fdr_psm_ > 0.0 && !has_decoys)
{
OPENMS_LOG_WARN << "FDR:PSM is set but no decoys found (decoy_prefix='" << decoy_prefix_
<< "'). Provide a FASTA with decoy proteins or enable '-decoys'. Skipping FDR filtering.\n";
}
🤖 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/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp` around lines 2003 - 2013,
The code currently silently skips PSM FDR filtering when has_decoys is false,
without notifying the user. Add a warning message that triggers when fdr_psm_ is
greater than 0.0 but has_decoys is false, alerting users that FDR filtering was
requested but could not be applied due to missing decoys. This warning should be
added in an else clause or as a separate condition after the existing if
(fdr_psm_ > 0.0 && has_decoys) block to maintain consistency with other search
paths in the codebase.

Comment thread src/topp/ProSE.cpp Resolved
Comment thread src/topp/ProSE.cpp Resolved
…ry merged test

Drop check_decoys.cmake and the TOPP_ProSE_6/7/8/9 decoy presence/absence
greps. The decoy-reporting contract (PSM-FDR retains decoys, protein-FDR
strips) is already pinned directly and precisely by ProSEAlgorithm_test
(in-memory + file-based PSM-only retention), so the TOPP-level greps were
redundant and the custom cmake helper unnecessary.

Add one TOPP_ProSE_7_merged test for the tool-only multi-file -out_merged
path (IDMerger + BasicProteinInferenceAlgorithm + picked-protein FDR on the
pooled set), which no test previously exercised. It diffs a small FileInfo
-out_tsv summary (protein/peptide/spectrum counts) against a committed
reference instead of a large golden idXML; env-dependent file-name/database/
version lines are whitelisted. Verified separately that the merged path with
FDR:protein=0 stores and reloads valid idXML with decoys retained.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/topp/CMakeLists.txt`:
- Around line 3234-3238: The whitelist in the add_test call for
"TOPP_ProSE_7_merged_info_out" is incomplete and missing version-related fields
that are expected to vary across tool/build versions. Update the whitelist
parameter in the add_test command to include version-related text fields (such
as "version") alongside the existing "file name", "database", and "search
engine" entries to prevent test failures caused by version differences.
🪄 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: 1c8974f9-f676-4fcb-8ed0-84bf894c8509

📥 Commits

Reviewing files that changed from the base of the PR and between 19b78f0 and 0763ff4.

⛔ Files ignored due to path filters (1)
  • src/tests/topp/ProSE_7_merged_info.tsv is excluded by !**/*.tsv
📒 Files selected for processing (1)
  • src/tests/topp/CMakeLists.txt

Comment thread src/tests/topp/CMakeLists.txt Resolved
timosachsenberg and others added 6 commits June 19, 2026 15:49
IDMergerAlgorithm carries over search engine/parameters from the input runs
but does not set a date on the merged ProteinIdentification, so -out_merged
output had date="0000-00-00T00:00:00" and failed strict idXML XSD validation
(it still loaded in OpenMS). Set DateTime::now() on the merged run, matching
the single-file path in ProSEAlgorithm.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Precursor tolerance was already 20 ppm (lower+upper); align the default
fragment mass tolerance to 20 ppm as well. No test impact: all ProSE TOPP
tests and the unit test set fragment tolerance explicitly (ini / command
line / per-section), so none rely on the default.

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

The previous comments/param description said PSM FDR "never removes decoys",
which is imprecise: filterHitsByScore drops decoy PSMs above the q-value
threshold exactly like targets. What PSM FDR does NOT do is a decoy-specific
stripping step (removeDecoyHits). Reword the FDR:PSM description, the three
PSM-FDR block comments, the inline add_decoy_peptides comments, and the ProSE
@note so they state that target and decoy PSMs are filtered alike by q-value
and that categorical decoy removal happens only at protein-FDR finalization.
Comment/string-only; no behavior change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
ProSE retained a hardcoded NLargest(400) MS2 peaks regardless of fragment
resolution. On low-resolution data (e.g. 0.5 Da ion-trap CID) the wide match
window then admits many spurious low-intensity fragment matches, which inflate
HyperScore's count-sensitive factorial term for targets AND decoys alike,
collapsing the target/decoy score margin so correct top hits fail FDR.

Expose peak retention and default to a resolution-aware 'auto':
- peaks:keep_n (0 = auto): high-res keeps 400; low-res uses
  clamp(round(400*sqrt(0.02/eff_tol_da)), 60, 400) (~80 at 0.5 Da). Gated on
  the existing deisotoper/low-res threshold so high-res behavior — and all
  existing tests — is unchanged.
- peaks:window_top (WindowMower peaks-per-100 Da, default 20).

Benchmark (C. elegans PXD004561, 0.5 Da fragment; ProSE vs MSFragger, both via
OpenMS FalseDiscoveryRate @1% PSM FDR): ProSE 13,932 -> 26,020 target PSMs
(51% -> 95% of MSFragger's 27,452, exceeding MSFragger's raw hyperscore 25,252)
at 99.1% peptide agreement on shared spectra. Diagnosed with a candidate
partition: 83% of ProSE's misses were already its own #1 peptide, just below
the 1% FDR threshold for lack of target/decoy separation.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-fdr-single-file

Bring resolution-aware MS2 peak retention (peaks:keep_n auto, ~80 peaks at
0.5 Da low-res vs 400 high-res) into the protein-FDR / 20 ppm tolerance branch.
The single-file protein-FDR finalization (BasicProteinInferenceAlgorithm ->
applyPickedProteinFDR -> filterHitsByScore -> removeDecoyHits + indistinguishable-
group / protein-group / dangling-reference cleanup) existed as two byte-identical
copies: the file-based ProSEAlgorithm::search() overload (library API, unit-tested)
and the ProSE TOPP tool's single-file path (production, golden-tested via
TOPP_ProSE_6_fdr). Two copies of the same IDFilter sequence + ordering can silently
drift.

Extract it into one public static helper
ProSEAlgorithm::applyCompleteSetProteinFDR(protein_ids, peptide_ids, decoy_prefix,
protein_fdr); both call sites delegate to it. Each site keeps its own gating
(DB-based vs identified-hit decoy detection + warn path), which legitimately differs.

Behavior-preserving: ProSEAlgorithm unit test (25 sections) and the TOPP goldens
TOPP_ProSE_6_fdr (single-file, bit-identical idXML) and TOPP_ProSE_7_merged pass
unchanged. Addresses tag-team review finding #1 (duplicated single-file FDR logic).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
timosachsenberg and others added 2 commits June 20, 2026 10:59
Add TOPP_ProSE_6_fdr_chunked: the same realistic single-file protein-FDR search
as TOPP_ProSE_6_fdr but with -Search:database:chunk_size 20, diffed against the
SAME golden (ProSE_6_fdr_out.idXML). The fragment index is built per chunk and
hits accumulate across chunks before a single post-processing + picked-protein
FDR pass, so the chunked result must be byte-identical to the non-chunked one.
Closes the chunked + FDR:protein coverage gap (issue OpenMS#9640, gap 1). chunk_size
is not serialized into the output, so no extra whitelist is needed.

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

TOPP_ProSE_6_fdr exact-idXML-diffed an FDR-thresholded realistic search against a
Linux-generated golden, which fails on macOS/Windows (pre-existing: both were
already red on this branch). HyperScore uses libm lgamma/log1p, whose last ULP
differs across platforms, flipping ~1 target/decoy near-tie at the q=0.05 cut and
cascading every scan_index.

Investigation (issue OpenMS#9640): the FDR boundary is NOT the sensitive step (clean
q-value gap, immune to score perturbation up to 1e-11) and matching has a 4-ion
margin over min_matched_ions=5; the only non-determinism is the best-hit
target-vs-decoy pick on the 1 spectrum matching both -> bounded to <=2 scans / <=1
protein.

Replace the exact diff with FileInfo-count checks at calibrated tolerance:
 - info_proteins (absdiff 1): protein count = 47 targets +/-1. A decoy-removal
   regression leaks 2 decoys -> 49 -> caught (validated: 49 fails, 46 passes).
 - info_psms (absdiff 3): matched-spectra / peptide counts ~895 +/-3; catches
   gross scoring/ID loss while tolerating the borderline-match jitter.
The exact decoy-free + valid-idXML contract stays pinned cross-platform by
ProSEAlgorithm_test.

TOPP_ProSE_6_fdr_chunked now diffs the chunked output against the SAME-RUN
non-chunked output (not a committed golden): chunking is deterministic per
platform (TOPP_ProSE_5_chunked proves bit-identical), so it pins chunked ==
non-chunked immune to the cross-platform FP noise.

Removes the obsolete 18k-line golden ProSE_6_fdr_out.idXML.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@timosachsenberg
timosachsenberg merged commit e9f36a2 into OpenMS:develop Jun 21, 2026
38 checks passed
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]>
timosachsenberg added a commit that referenced this pull request Jun 22, 2026
- ProSE (#9633, #9644): fix entry for protein-level FDR now applied for
  single-file runs; was previously silently skipped unless -out_merged was
  used in multi-file mode
- pyOpenMS (#9629): fix entry for 6 docutils ERROR-level warnings in
  nanobind binding docstrings resolved


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

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants