Skip to content

[API] ProSE: merged multi-file evaluation in ProSEAlgorithm - #10602

Merged
timosachsenberg merged 10 commits into
claude/prose-percolator-in-libraryfrom
claude/prose-merged-in-library
Oct 17, 2026
Merged

timosachsenberg merged 10 commits into
claude/prose-percolator-in-libraryfrom
claude/prose-merged-in-library

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Why

A browser app built on the OpenMS WebAssembly module and the native ProSE tool should pool the results of several files with the same code. The pooling, cross-file protein inference and picked-protein FDR of -out_merged lived in src/topp/ProSE.cpp, so a library caller would have had to copy them. This moves them into ProSEAlgorithm, the same way #10578 moved the Percolator rescoring, and adds two small hooks the app needs (per-file progress, the NCE a rescoring used).

Stacked on #10578

Base is claude/prose-percolator-in-library (#10578), not develop; this PR needs its Search:rescore and the per-run Percolator outcome. After #10578 is merged, this PR has to be retargeted to develop (and rebased if #10578 is squash-merged).

What changed

  • ProSEAlgorithm::mergeFileResults() and ProSEAlgorithm::MergedResult: pools the PSMs of a multi-file searchWithModificationAnalysis() result, infers proteins across files and, with FDR:protein and decoys, applies the picked-protein FDR and removes the decoys. The ProSE tool now calls it and keeps only the -test basename rewrite and the idXML writing. Percolator having rescored only some files is now an Exception::InvalidValue; the tool maps it to INCOMPATIBLE_INPUT_DATA with the previous message. The tool's output does not change.
  • Fix: id_merge_index of the pooled PSMs is the input position of their file also after a failed file. IDMergerAlgorithm numbers only the runs it pools, so after a failed file the PSMs of later files named the wrong file. The pooling of the multi-file aggregate and of mergeFileResults() is one helper, poolSearchedFiles_().
  • The multi-file search reports one Searching <file> (i of n)... progress step per input file, with the steps of the file's search nested below it. The step is balanced on every way out of the loop (end, failed search, exception). Consumers should identify it by its label: the depth is only reliable with one thread, and chunk-major searches (database:chunk_size) emit no per-file step.
  • PeptDeepRescoring::annotate() stores the NCE each run's predictions used as the double run meta value peptdeep_nce, so a consumer can predict spectra at the same energy. Runs without PSMs get none.

Verification

  • Characterization test first (TOPP_ProSE_13_merged*, before the refactor): a -out_merged run on two input files (two copies of one mzML) with the default Percolator rescoring and protein FDR, checked with a FileInfo summary (47 proteins +/-1, 1790 PSMs +/-6, one run) and structure checks (protein scores are q-values, the run is the Percolator run, no decoy PSM or protein left). I also compared the full merged idXML of the unrefactored and the refactored tool locally: identical apart from the run date.
  • New class tests in ProSEAlgorithm_test (mergeFileResults(): pooling with protein FDR, files that share a basename, rescored-only-some, a failed file, no decoys; progress events: one thread, default threads, a failed search, a file that throws) and PeptDeepRescoring_test (peptdeep_nce).
  • ctest -R "ProSE|PeptDeep": 80 of 80 pass (class tests and all TOPP_ProSE_* tests), Linux release build.

Notes

  • The TOPP_ProSE_13 tolerances are calibrated like Test 6 (libm last-ULP differences can flip a target/decoy near-tie) but have not run on macOS/Windows CI yet. If CI there reports a difference, it needs to be investigated before the tolerances are widened.
  • ProgressLogger's step depth is a static that is not thread-safe (pre-existing; the background mzML reader shares it), hence the label-based progress contract rather than a depth-based one.
  • CHANGELOG entries are in the OpenMS Library section next to those of [API,PARAM,TEST] ProSE: Percolator rescoring in ProSEAlgorithm, on by default #10578.

🤖 Generated with Claude Code

timosachsenberg and others added 10 commits October 16, 2026 16:04
…-out_merged)

Pins the pooled output of two inputs with the default Percolator rescoring
(cross-file protein inference, then the picked-protein FDR at 5 % with the
decoys removed), generated with the unchanged tool, so that moving the
pooling into the library cannot change it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a golden idXML

The 6.7 MB reference idXML of the pooled -out_merged output was compared
line by line, which is not portable: Test 6 documents that libm last-ULP
differences flip a target/decoy near-tie, and Test 12 that the Percolator
SVM scores differ by about 1 % between runs on Windows. Remove it and
compare a small FileInfo summary with calibrated tolerances instead (47
proteins +/-1, 1790 PSMs +/-6, one run), as Test 6 and Test 7 do, plus
structural checks: the protein scores are q-values (protein FDR applied),
the run is the Percolator run, and no decoy PSM or decoy protein is left.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ile evaluation of the ProSE tool

The pooling, cross-file protein inference and optional picked-protein FDR of
the ProSE tool's -out_merged move into the library, so that other callers
(the ProSE web app) share the code with the tool. The result is the new
ProSEAlgorithm::MergedResult. The behaviour is unchanged: the merged output
of TOPP_ProSE_13_merged is identical apart from the run date.

The check that Percolator rescored only some of the files becomes an
Exception::InvalidValue; the tool maps it to INCOMPATIBLE_INPUT_DATA and
other exceptions to CANNOT_WRITE_OUTPUT_FILE, with the previous messages.
The tool keeps the -test basename rewrite and the idXML writing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…position, also after a failed file

IDMergerAlgorithm numbers only the runs it pools, but the pooled run lists
all input files, so after a failed file the PSMs of the later files named
the wrong file (inputs a, b, c with a failed: b's PSMs got index 0 = a).
The pooling of the multi-file search's aggregate and of mergeFileResults()
is now one helper, poolSearchedFiles_(), which maps the merger's numbers
to the input positions. Without a failed file nothing changes (the merged
output of TOPP_ProSE_13_merged is identical apart from the run date).

The class test copy of the spectra file is removed first, so a file left
over by a failed run does not make File::copy() fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The multi-file search with one fragment index now reports "Searching <file
name> (i of n)..." as a depth-0 progress step per input file, so that a
progress display (the ProSE web app) can tell which file is searched. The
steps of the search of the file (index build, filtering, scoring, ...) nest
one level below it. The step ends with the file on every way out of the
loop iteration: the end, the continue of a failed search, and an exception.

The index build that overlaps with reading the first file (multi-threaded)
moves into the loop, inside the step of the first file, instead of being a
stray depth-0 step before it. The chunk-major search (database:chunk_size)
searches all files chunk by chunk and reports its steps as before.

The class test records the progress events: one thread (the depths are only
reliable then: the background mzML reader shares the static step depth of
the ProgressLogger), the default threads, a failed search (empty database)
and a file that throws.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…deep_nce'

annotate() now stores the normalised collision energy each run's predictions
used (the scanned one, or 'nce' when set) on that run's ProteinIdentification
as the double meta value 'peptdeep_nce', so a consumer of the result can
predict spectra at the energy the search used. Runs without PSMs are not
annotated and get none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st check, runs of the files kept

Fixes of the final review of the merged multi-file evaluation:

- mergeFileResults() gets 'bool remove_decoys = true'. The default keeps the
  behaviour of the ProSE tool's -out_merged exactly. With false the picked-protein
  FDR keeps the decoy proteins in the run (FalseDiscoveryRate's
  add_decoy_proteins; the q-values of the targets are the same), the filter at
  FDR:protein applies to them as to the targets, and the decoy PSMs and the decoy
  proteins that pass are kept; only the peptide evidences of removed proteins
  are stripped and the indistinguishable/protein groups updated, so the result
  can still be stored as idXML. protein_fdr_applied still means "FDR applied".
- It throws Exception::IllegalArgument unless in_spectra_files has one entry per
  file of the search (checked before anything is moved).
- Without a pooled aggregate (build_pooled_aggregate false, or a single-file
  search) it moves only the PSMs out of per_file and copies the runs, so
  per_file[i].protein_ids (search parameters, meta values such as peptdeep_nce,
  run paths) survive the merge.
- ProSE: the InvalidValue catch covers only the merge (an InvalidValue of the
  store is a write failure, CANNOT_WRITE_OUTPUT_FILE) and appends e.what().
- Docs: the "balanced" progress guarantee is scoped to the per-file step (the
  nested steps are not exception-safe); "input position" means for inputs with
  distinct paths.
- Tests: new sections for remove_decoys false (decoy PSMs and proteins kept,
  q-values, no dangling references, idXML store and load), the input-list check,
  and a single-file merge (fallback path, the run of the file kept); the progress
  test takes depths relative to the first event of a search, since threaded
  searches before it can leave ProgressLogger's static depth off zero; a wrong
  comment on the failed-file test is corrected.

The merged output of TOPP_ProSE_13_merged is unchanged (FuzzyDiff against the
local golden, ratio 1, absdiff 0: identical but for the run date).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…_nce' run meta value

The name of the run meta value annotate() stores the NCE in was a .cpp-local
constant, so consumers had to hard-code the literal. It is now the public
static constexpr PeptDeepRescoring::NCE_META_VALUE ("peptdeep_nce"), used by
annotate() and documented; the class test pins its value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es, NCE_META_VALUE

The mergeFileResults() entry claimed that the output of the ProSE tool does not
change. Only -out_merged is unchanged (but for the id_merge_index fix in runs
where a file failed): with peptdeep:enable the per-file idXML runs carry
'peptdeep_nce', and the command-line progress of a multi-file search nests under
"Searching <file> (i of n)...". Also: remove_decoys, "input position" qualified
for inputs with distinct paths, and the public PeptDeepRescoring::NCE_META_VALUE.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@timosachsenberg
timosachsenberg marked this pull request as ready for review October 16, 2026 21:21
@timosachsenberg
timosachsenberg merged commit a1d390f into claude/prose-percolator-in-library Oct 17, 2026
2 checks passed
@timosachsenberg
timosachsenberg deleted the claude/prose-merged-in-library branch October 17, 2026 10:58
timosachsenberg pushed a commit that referenced this pull request Oct 20, 2026
…sm-prose-webapp

Brings in develop (with #10578 + #10602 as squash 2ef8693 and #10644 as
8528cf2) through the updated #10564 branch. This branch had carried a
pre-squash version of #10578/#10602 (claude/prose-merged-in-library) and a
cherry-pick of #10644.

Resolution: every library path is develop's version plus only the library
commits of this branch that develop does not have (ProSEAlgorithm::
pinEnzymeName() and modMatchTolerance() public, ML::PEPTDEEP_DEFAULT_BATCH_SIZE,
the joined reader thread, peptdeep:batch_size 128 in WebAssembly, the
PeptDeepRescoring NCE fix, ONNXPredictorBase without the memory pattern, the
ONNX environment changes for WebAssembly threads).
- ProSEAlgorithm.h, ProSEAlgorithm_test.cpp, src/tests/topp/CMakeLists.txt
  (conflicts) and ProSEAlgorithm.cpp (auto-merged, but with
  rescoreWithPercolator(), applyDeferredPsmFDR() and applyPsmFDR_() twice,
  since the squash moved them): develop's version with those commits on top.
- src/tests/topp/ProSE_13_prepare.cmake: removed; develop's Test 13 copies
  its inputs with add_test(... -E copy) instead.
- CHANGELOG: develop's text with this branch's entries.
- #10644 (7abcb28): identical to develop's, no difference left.

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.

1 participant