Skip to content

ProSE: 5.7x faster than develop and +3.6% PSMs, FDR control preserved (speed patches, scoring and rescoring features) - #10400

Closed
okohlbacher wants to merge 3 commits into
OpenMS:developfrom
okohlbacher:feature/prose-speed-quality
Closed

okohlbacher wants to merge 3 commits into
OpenMS:developfrom
okohlbacher:feature/prose-speed-quality

Conversation

@okohlbacher

@okohlbacher okohlbacher commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Draft. Speed, correctness, scoring and rescoring-feature changes to ProSE, measured on the frozen benchmark of #10364. Two commits:

  1. [PERF] IdXMLFile: parallel, byte-identical idXML writer: library only (IdXMLFile, XMLHandler and the IdXMLFile class test). It can be reviewed and merged on its own.
  2. [FEATURE] ProSE: faster search and higher identification rates: everything else. The commit message lists every change.

Summary

Against develop (f6c680f), at unchanged FDR:

develop f6c680f this PR
accepted PSMs per file (Percolator, q <= 0.01, mean of 20 files) 3187.7 3302.7 (+3.6%)
Velos UPS1 natural entrapment FDP (nominal 1%) 0.97% 0.91%
doubled search space, combined FDP over all files (shuffle 1) 1.13% 1.09%
  • Speed: 20 searches at 4 threads take 98 s instead of 560 s on develop (5.7x), on an idle 64-core node; 6.4x at 64 threads. Most of it comes from ten speed patches with byte-identical output; the parallel idXML writer saves another 12% at 4 threads and 26% on one file at 16. See "Timing".
  • Identifications: +3.6% accepted PSMs per file over develop and +9.5% over the speed-only build. Every instrument group gains. Astral gains most (+15% over develop); Lumos LFQ (+0.1%) and timsTOF (+0.5%) gain least.

What changes, and why

Speed (output byte-identical). Ten patches. The output was checked against the code before them: native TSV and idXML on all 20 files at 4 threads, and on 6 files at 1, 16 and 64 threads.

  • The fragment index bins fragments by m/z instead of sorting them all. It counts the fragments first, then writes them straight into their bins.
  • Digestion no longer uses regular expressions.
  • The peptide sort runs on several threads and reproduces std::sort exactly.
  • One bucket walk covers all precursor isotope errors, with skip tables and prefetching.
  • PSM meta-value keys are resolved once.
  • Peak annotation in Da uses flat storage.
  • The mzML is read while the fragment index is built.
  • The FASTA is read in parallel, the index is released in parallel, and the database is no longer copied.

Develop's ProSE changes (#10391, #10394, #10397, #10398, #10399) are carried into the faster code, and the output is identical to develop's on all 20 files:

Parallel idXML writer (commit 1).

  • IdXMLFile::store formats PeptideIdentifications in parallel (at most 16 threads) and writes them in input order, so the file does not change.
  • XMLHandler::writeUserParamValue_() holds the formatting of one meta value, shared with writeUserParam_().
  • Hits with NaN scores are sorted as before, so the result does not depend on the standard library.
  • Exceptions are raised outside the parallel section; the first one in input order is reported.
  • Checked byte-identical on the 20 searches at 1/4/8/16/64 threads, on an idXML round trip of 323 files, and on synthetic files with 1-1000 runs.

Correctness.

  • isotope_error is now observed minus theoretical, the sign that MS-GF+, pepXML, Sage, PercolatorInfile and PercolatorAdapter use. With the old sign, -out_pin and PercolatorAdapter doubled the isotope offset in dm/absdm instead of removing it.
  • PercolatorInfile keeps one ExpMass per spectrum, so PSMs of one spectrum at different isotope errors no longer enter target-decoy competition as different spectra. Together, the sign and ExpMass fixes give TOPP-path users (-out_pin, PercolatorAdapter) +3.55% accepted spectra per file.
  • precursor:isotopes, which was never used, is removed. FragmentIndex's default isotope range is now [-2, 0].
  • Fixed terminal modifications that cannot be restricted are rejected, and a variable whole-terminus modification is no longer added on top of a fixed one.
  • Variable-modification enumeration is bounded.
  • The preprocessing filters are now per thread (this was a data race).
  • A warning is logged for clipped decoys that lack the targets' initial Met.

Scoring.

  • scoring:method=auto (default) uses a mass-accuracy-weighted HyperScore for ppm tolerances. Each matched ion counts with a Gaussian weight of its mass error (scoring:mass_error_sd, 7 ppm). Da searches keep HyperScore unchanged.
  • FDR:PSM_groups=scored_charges (default): ProSE's own FDR:PSM competes PSMs scored with different numbers of fragment charges separately. Since [FEATURE] ProSE: score multiply charged fragments of spectra that are not deisotoped #10397 they have different score scales at low resolution.

Deisotoping. MS2 deisotoping for high-resolution fragments uses a Sage-like envelope rule:

  • two isotope peaks make an envelope;
  • charges go up to the precursor charge, at most 3;
  • the monoisotopic peak carries the summed intensity.

Three parameters restore the earlier rule. Low-resolution searches do not change.

Rescoring features. annotate:self_trained_ion_priors (default on) adds a per-run fragment-ion model, the new class FragmentIonLikelihoodModel:

  • It covers presence, intensity rank and mass error per ion series, charge, position, cleavage-site residues and complementary-ion presence.
  • It learns from the run's own confident target PSMs, with their reversed sequences on the same spectra as the noise model.
  • It is cross-fitted by scan parity, so no PSM is scored by a model that saw its spectrum or its label.
  • It adds the Percolator features ion_prior_llr and ion_prior_explained. Native scores and candidates do not change.

Not included.

  • The prototype dense-spectrum peak quota of the benchmark branch (20b6e75) is not part of develop and is not included; its author did not propose it for merging. All its code, parameters, tests and search-parameter records are removed.
  • Five optional candidate-competition features were evaluated (run-centred precursor ppm, top-7 fragment errors, per-PSM delta/z, Poisson prefilter surprise, delta_best). Per-PSM delta/z, Poisson surprise and delta_best raised the doubled-database FDP beyond the keep rule; run-centred precursor ppm and top-7 fragment errors added +0.02% to the stack measured without [FEATURE] ProSE: raw-spectrum candidate retrieval for high-resolution spectra and local fragment evidence #10399. All five are left out.

Evidence

Protocol.

  • Data: the frozen 20-file DDA corpus of [BENCHMARK] Reproducible ProSE / ANDES / Sage suite: 20 measurements across six instrument models #10364, 8,000 MS2 spectra per file, all public PXD data. There are seven groups: Velos CID ion trap, HF-X, Astral, Lumos HCD LFQ, Lumos CID TMT, Exploris TMTpro and timsTOF HT.
  • Search: the frozen per-file parameters of the issue.
  • Rescoring: ProSE idXML, then PercolatorInfile with ProSE's extra_features, then Percolator 3.09 (-Y -U) with seeds 1/42/137. Target PSMs at q <= 0.01, averaged over seeds and then over files.
  • Every component had a keep rule written before its numbers were seen.

Yields per instrument group (mean accepted PSMs per file):

group speed-only build¹ develop f6c680f this PR vs develop vs speed-only
Velos CID (0.5 Da) 2600 2940.0 3017.8 +2.6% +16.1%
HF-X 4388 4445.6 4612.6 +3.8% +5.1%
Astral 2375 2655.3 3062.3 +15.3% +29.0%
Lumos HCD LFQ 5488 5552.6 5557.9 +0.1% +1.3%
Lumos CID TMT (0.5 Da) 2327 2414.9 2456.3 +1.7% +5.5%
Exploris TMTpro 2229 2548.9 2613.2 +2.5% +17.2%
timsTOF HT 1036 1041.2 1046.3 +0.5% +1.0%
mean per file 3014.8 3187.7 3302.7 +3.6% +9.5%
Velos UPS1 entrapment FDP 0.88% 0.97% 0.91%

¹ The speed-only build is the ten speed patches on the benchmark branch 20b6e75: develop before #10391-#10399, plus the prototype dense quota at its default. Its output is identical to that branch's.

For context, the issue's table has Sage 0.14.7 at 3136 and ANDES at 3301 PSMs per file on the same protocol.

Doubled-search-space entrapment control. Every target protein gets a shuffled-peptide entrapment copy, which keeps cleavage sites and unmodified peptide masses, plus reversed decoys of both. FDP is the combined estimator (Wen et al. 2025) at a nominal 1%.

entrapment shuffle base² this PR targets vs base
1 1.08% 1.09% +6.7%
2 1.00% 1.00% +6.6%
3 0.94% 0.99% +7.1%

² The base is develop before #10399 (3343ab2 behaviour), the reference of every component's keep rule. Develop f6c680f gives 1.13% on shuffle 1.

Pooled over the three shuffles, the PSMs this PR adds carry about 1.4% FDP. On Astral, the FDP of this PR stays at 1.08-1.12% over the three shuffles. Group-level FDPs rest on about 5-100 entrapment PSMs (timsTOF fewest, about 10); differences below about 0.3 points are noise.

Leave-one-out. Each row compares the full stack with the same stack minus one component, both measured without #10399. #10399 was then added on top.

component mean PSMs/file from it groups files up/down doubled-DB FDP with / without it Velos UPS1 FDP with / without it kept
self-trained ion model +2.03% Astral +5.8, Velos +4.1, timsTOF +3.1, CID TMT +2.0, HF-X +1.3, TMTpro +1.1, LFQ +0.1 19/1 1.08 / 1.10% 0.90 / 1.07% yes
Sage-like deisotoping +0.77% HF-X +1.8, Astral +1.8, TMTpro +1.0, timsTOF +0.2, LFQ +0.2, 0.5 Da files 0 13/1 1.08 / 1.11% 0.90 / 0.90% yes
candidate-competition features +0.02% Astral +0.9, CID TMT -1.1 9/11 1.08 / 1.06% 0.90 / 0.89% no (rule: >= +0.3%)
#10399 (develop) added on top +1.46% Astral +8.6, HF-X +1.2, timsTOF -2.0 13/7 1.09 / 1.06% 0.91 / 0.89% (in develop)

Two components were measured as packages against the base rather than in the leave-one-out:

  • Mass-accuracy scoring: +0.69% (Astral +5.5%; 0.5 Da files byte-identical). Doubled-DB FDP 1.08/1.00/0.94% -> 1.04/0.96/0.94% over the three shuffles.
  • Correctness bundle: with report:isotope_error_convention=theoretical_minus_observed, its output is byte-identical to the base.

Exactness of this branch. All 20 files at 4 threads were compared with the build that produced the numbers above. The native TSV and idXML are identical, apart from the two removed prototype search-parameter lines.

Tests.

  • Class tests pass: HyperScore, FragmentIndex, ProSEAlgorithm, IdXMLFile, FragmentIonLikelihoodModel and PercolatorInfile.
  • The ProSE TOPP tests TOPP_ProSE_1 .. _10 pass, 26/26 (without the QPX/ParquetDiff and OpenTIMS variants).
  • ProSE_{1,2,4,10}_out.idXML are regenerated. Each top hit's peptide, charge and order are unchanged; scores and annotations change through the new deisotoping rule (all four) and, for test 10 (10 ppm), the mass-accuracy score and the ion-model features.
  • With the earlier deisotoping rule, HyperScore and the ion model switched off, the outputs differ from develop's references only by the four recorded search parameters (isotope_error_convention and the three fragment:deisotope_*).
  • ProSE_{1,2,4,6_fdr}.ini no longer set precursor:isotopes.
  • These tests ran in a harness that compiles the changed library sources, the ProSE and PercolatorAdapter tools and the class tests against an OpenMS 3.7 nightly library. A full CI build has not run yet.

Timing

Idle 64-core node (AMD EPYC 7763, 128 hardware threads), whole process including reading the inputs and writing the results, the benchmark's own timing harness, one search at a time. This PR is the frozen build that produced the numbers above (identical output).

develop f6c680f this PR speed-up
20 searches at 4 threads, wall time 560.4 s 98.3 s 5.7x
CPU time 29.3 min 6.5 min 4.5x
peak RSS, median / max over the 20 files 2.40 / 2.85 GiB 1.91 / 2.40 GiB

Four files (Velos, HF-X, Astral, timsTOF), sum of wall times:

threads develop this PR speed-up
1 326.2 s 67.6 s 4.8x
4 120.6 s 20.7 s 5.8x
16 61.8 s 9.9 s 6.2x
64 62.2 s 9.7 s 6.4x
128 86.8 s 10.9 s 8.0x
  • At 4 threads every file is a single run, except a second run of the four scaling files (median used). The other thread counts are single runs.
  • For comparison, on the same node and protocol the speed-only build takes 95.7 s for the 20 searches (four files: 57.7 s at 1 thread and 11.6 s at 64 threads), and our optimised Sage fork 220 s (Sage master 618 s).
  • Where the remaining time goes against the speed-only build: the parallel idXML writer saves 12% at 4 threads. [FEATURE] ProSE: raw-spectrum candidate retrieval for high-resolution spectra and local fragment evidence #10399's raw-spectrum retrieval costs time on dense high-resolution spectra: astral_B1 4.1 -> 6.6 s on a shared node; fragment:query_spectrum=processed restores the speed at -1.3% PSMs. The ion model costs 3-6%.

Round-1 history of the speed patches (same node and harness, the benchmark branch before -> after): 20 searches at 4 threads 429 s -> 96 s (4.5x; per file 4.1-5.0x); four files at 1/4/16/64 threads 250.9/91.0/44.2/39.1 s -> 57.7/19.9/11.1/11.6 s.

Caveats

  • Design choices were made on these 20 files. Each component was kept or dropped by a rule written before its measurements, with one deviation: the Sage-like deisotoping default failed its own package rule on timsTOF (-1.5% on three Percolator seeds, +0.2% on thirteen) and is on because the integration's leave-one-out rule kept it. A held-out confirmation (other spectra of the same runs, other datasets) is still pending. This applies in particular to:
    • FDR:PSM_groups=scored_charges. ProSE's own FDR:PSM output at 0.5 Da runs above nominal in every arm, the speed-only build included.
    • The deisotoping rule on held-out timsTOF data, and the OpenTIMS-gated TOPP_FalseDiscoveryRate_ProSEDDA*_psm_count floors, which were not run here.
  • timsTOF is the weakest group. [FEATURE] ProSE: raw-spectrum candidate retrieval for high-resolution spectra and local fragment evidence #10399 costs -2.0% there in this stack (tims_plasma_50min -2.8%). The PR is +0.5% over develop on timsTOF.
  • Breaking change for consumers of the isotope_error meta value. The sign changes. The search parameters record isotope_error_convention=observed_minus_theoretical. report:isotope_error_convention=theoretical_minus_observed restores the old sign, and PercolatorAdapter warns about ProSE input without the record.
  • Breaking change for ini files. precursor:isotopes is removed, so ini files that set it are rejected. Remove the item or run INIUpdater.
  • Name overlap with [FEATURE] ProSE: self-trained per-run fragment ion priors as Percolator features #10378. The new parameter annotate:self_trained_ion_priors has the same name as Timo Sachsenberg's open [FEATURE] ProSE: self-trained per-run fragment ion priors as Percolator features #10378 but different semantics: cross-fitted, richer contexts, two features. The search parameters record which model wrote a file. The names should be settled before either PR is merged.
  • TOPP references are regenerated as described above. A full OpenMS CI build is pending.

Credits

🤖 Generated with Claude Code

okohlbacher and others added 2 commits October 3, 2026 04:50
IdXMLFile::store formats the PeptideIdentifications in parallel and writes
them in input order (omp ordered), so the file is byte-identical to the one
the serial writer produces.

- XMLHandler::writeUserParamValue_() writes one meta value as UserParam;
  writeUserParam_() and the parallel writer share it, so there is no second
  copy of the formatting code.
- The PeptideIdentifications are assigned to their runs in one hash pass;
  each run is cut into blocks of 16, formatted by at most 16 threads (and at
  most one per block). PeptideIdentifications of no run are warned about
  from the same pass.
- If a hit score is NaN, a copy of the hits is sorted with the call of
  PeptideIdentification::sort(), as before, so the order does not depend on
  the standard library; otherwise an index sort is used.
- Exceptions of the parallel section (ElementNotFound for an unknown protein
  reference, ConversionError for an EMPTY meta value) are constructed one at
  a time inside a critical section and rethrown after it; the first error in
  input order is reported.

Checked: byte-identical output for the 20 ProSE searches of the OpenMS#10364
benchmark at 1, 4, 8, 16 and 64 threads, an idXML load/store round trip of
323 files at 1/4/16/64 threads, and synthetic 300k-PSM files with 1 to 1000
runs. ProSE wall time (store included): 20 searches at 4 threads -11.8%,
one search at 16 threads -26%; no regression at 1 thread, peak memory
unchanged. New IdXMLFile_test sections cover input order, PeptideIdentifications
of no run, NaN scores and exceptions from the parallel section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Speed, correctness, scoring and rescoring-feature changes to ProSE, measured
on the frozen 20-file DDA corpus of OpenMS#10364 (issue protocol: Percolator
3.09, 3 seeds, target PSMs at q <= 0.01). Against develop f6c680f:
+3.6% PSMs per file (3187.7 -> 3302.7), Velos UPS1 entrapment FDP 0.97% ->
0.91%, doubled-search-space FDP 1.13% -> 1.09%.

Speed (output byte-identical: all 20 files at 4 threads, six at 1, 16 and
64 threads; together about 4.5x faster at 4 threads):
- FragmentIndex::build bins fragments by m/z instead of a global sort, and
  counts the fragments first, then writes them straight into their bins.
- Regex-free digestion in FragmentIndex::generatePeptides.
- A multi-threaded peptide sort that reproduces std::sort exactly.
- One bucket walk for all precursor isotope errors, with skip tables and
  prefetching.
- postProcessHits_: PSM meta value keys resolved once and set by registry
  index; flat-storage Da alignment for the peak annotation.
- search(file, fasta) reads the mzML while the fragment index is built;
  parallel FASTA reading and index release; no copy of the database.
- Develop's ProSE changes (OpenMS#10391, OpenMS#10394, OpenMS#10397, OpenMS#10398, OpenMS#10399) run inside
  the faster code: peptide:deduplicate is evaluated within the index build
  (same definition, no AASequence string per database peptide), and the
  local fragment evidence of OpenMS#10399 reuses the annotation spectrum and
  merges the sorted alternative assignments. Output identical to develop.

Correctness:
- isotope_error is reported as observed minus theoretical (13C spacings),
  as in MS-GF+, pepXML and Sage and as PercolatorInfile expects; the search
  parameters record isotope_error_convention. The new
  report:isotope_error_convention=theoretical_minus_observed restores the
  previous sign. PercolatorAdapter warns about ProSE input without the
  record.
- PercolatorInfile keeps ExpMass/mass at the observed precursor m/z for all
  PSMs of a spectrum and removes the isotope error from dm/absdm/deltamass
  only, so PSMs of one spectrum at different isotope errors no longer enter
  target-decoy competition as different spectra.
- BREAKING: precursor:isotopes is removed (it was never used; the searched
  range is precursor:isotope_error_min/max). Inis that set it are rejected.
  FragmentIndex's default isotope range is [-2, 0].
- FragmentIndex rejects fixed terminal modifications it cannot restrict and
  does not add a variable whole-terminus modification on top of a fixed
  one; variable modification enumeration is bounded.
- The MS2 preprocessing filters are per thread (data race); warnings for
  decoys without the targets' initial Met under clipping.

Scoring:
- scoring:method (auto, hyperscore, mass_accuracy): a HyperScore whose ion
  counts and intensity product weight each match by a Gaussian of its mass
  error (scoring:mass_error_sd, 7 ppm). 'auto' uses it for ppm tolerances,
  HyperScore otherwise.
- FDR:PSM_groups (scored_charges, pooled): ProSE's own FDR:PSM competes PSMs
  scored with different numbers of fragment charges separately.

Spectrum preprocessing:
- MS2 deisotoping uses a Sage-like envelope rule: two isotope peaks make an
  envelope, charges up to the precursor charge (at most 3), the
  monoisotopic peak carries the summed intensity
  (fragment:deisotope_min_peaks / _charge_cap / _sum_intensity; 3 / none /
  false restores the earlier rule).

Rescoring features:
- annotate:self_trained_ion_priors (default on): a per-run fragment ion
  model (new class FragmentIonLikelihoodModel) learned from the run's own
  confident target PSMs against their reversed sequences, cross-fitted by
  scan parity, so no PSM is scored by a model that saw its spectrum or its
  label. Adds the Percolator features ion_prior_llr and ion_prior_explained;
  native scores and candidates are unchanged.

Tests: new and extended class tests (FragmentIndex, HyperScore,
ProSEAlgorithm, PercolatorInfile, FragmentIonLikelihoodModel). The TOPP
references ProSE_{1,2,4,10}_out.idXML are regenerated: with the earlier
deisotoping rule, HyperScore and the ion priors off, the new outputs differ
from develop's references only by the four recorded search parameters.
ProSE_{1,2,4,6_fdr}.ini no longer set precursor:isotopes.

Credits: the mass-accuracy HyperScore ports the opt-in scorer of Timo
Sachsenberg's OpenMS#10379 (825c33b); the self-trained ion model builds on the
design of his self-trained per-run fragment ion priors (OpenMS#10378, same
parameter name, different model); the speed patches started from his ProSE
branch, and develop's ProSE commits above are his.

Not included: the prototype dense-spectrum peak quota of Timo's benchmark
branch (20b6e75), which is not part of develop and which its author did
not propose for merging.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@okohlbacher okohlbacher changed the title ProSE: ~4.5x faster search (speed patches) and +3.6% PSMs over develop at unchanged FDR (scoring and rescoring features) ProSE: 5.7x faster than develop and +3.6% PSMs, FDR control preserved (speed patches, scoring and rescoring features) Oct 2, 2026
okohlbacher added a commit to okohlbacher/OpenMS that referenced this pull request Oct 3, 2026
ProSE_{1,2,4,10}_out.idXML gain the records of OpenMS#10399 (search parameters
fragment:query_spectrum, fragment:query_spectrum_resolved,
annotate:local_fragment_evidence; PeptideHit features chance_match_surprise
and mass_competition_evidence) and, in ProSE_10_out, those of the
self-trained ion model (annotate:self_trained_ion_priors and its settings,
ion_prior:* run records, ion_prior_llr and ion_prior_explained features).
extra_features lists the new features. No hit, score or rank changes; the
run date and database lines are whitelisted and kept.

The new references equal those of OpenMS#10400 (6cf934d, inspected there)
apart from the two parameter records of this branch's prototype
(peaks:dense_window_top, peaks:dense_intensity_loss). 26/26 ProSE TOPP
tests pass with the ProSE TOPP tool built from this branch (TOPP_ProSE_1 ..
_10 without QPX/ParquetDiff and OpenTIMS; 20/26 before, the six idXML
comparisons).

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

timosachsenberg commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

This branch is carried on in #10466: your three commits, a merge of current develop, the round-3 packages from #10403, and fixes for the six review findings on #10403. Where the problems were, and which of them came from the new code, is written up in this comment on #10403.

Specific to this PR: it merged develop with a single conflict (PercolatorInfile_test.cpp, both sides kept), its idXML writer and ExpMass fix had already landed on develop as #10427 and #10428 byte for byte, and it was frozen before the tagged version of #10403, so the removed-occurrence recording in the deduplication that the round-3 protein mapping needs had to come from there. The ten conflict hunks of the round-3 delta were all in the places where this PR removed the prototype dense-spectrum quota and the candidate-competition features.


Generated by Claude Code

@okohlbacher okohlbacher closed this Oct 8, 2026
timosachsenberg pushed a commit that referenced this pull request Oct 8, 2026
…de:deduplicate (from #10403)

The deduplication test of #10403's tagged version also compares
getRemovedOccurrences() with the entries the deduplication removed; the
port took the recording code from that version but the test section from
#10400, which predates it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ
okohlbacher added a commit that referenced this pull request Oct 9, 2026
…ader too

Every thread of scoreSpectraAgainstIndex_() incremented count_spectra with
'#pragma omp atomic', and the master thread read it without synchronisation
for setProgress(). An atomic update does not order a plain read on another
thread, so this is a data race; ThreadSanitizer reports it ("Read of size 8
by main thread" in setProgress(count_spectra) after an "atomic write" by a
worker). The value only feeds the progress display. The counter is a
std::atomic<Size> now (fetch_add, the master shows its own result); no
'omp atomic read', which MSVC's OpenMP 2.0 lacks.

The same idiom is in SimpleSearchEngineAlgorithm and IDBoostGraph (not
changed here).

Evidence (no class test: the race needs ThreadSanitizer): a probe that
searches 839 spectra on 8 threads, linked against a TSan build of
e910aea, reported the race; against a TSan build with this change it does
not. ProSEAlgorithm_test and TOPP_ProSE_* pass.

Review of #10466 (finding F3; pre-existing, from #10400).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
timosachsenberg added a commit that referenced this pull request Oct 9, 2026
…ackages and review fixes (supersedes #10400 and #10403) (#10466)

* [PERF] IdXMLFile: parallel, byte-identical idXML writer

IdXMLFile::store formats the PeptideIdentifications in parallel and writes
them in input order (omp ordered), so the file is byte-identical to the one
the serial writer produces.

- XMLHandler::writeUserParamValue_() writes one meta value as UserParam;
  writeUserParam_() and the parallel writer share it, so there is no second
  copy of the formatting code.
- The PeptideIdentifications are assigned to their runs in one hash pass;
  each run is cut into blocks of 16, formatted by at most 16 threads (and at
  most one per block). PeptideIdentifications of no run are warned about
  from the same pass.
- If a hit score is NaN, a copy of the hits is sorted with the call of
  PeptideIdentification::sort(), as before, so the order does not depend on
  the standard library; otherwise an index sort is used.
- Exceptions of the parallel section (ElementNotFound for an unknown protein
  reference, ConversionError for an EMPTY meta value) are constructed one at
  a time inside a critical section and rethrown after it; the first error in
  input order is reported.

Checked: byte-identical output for the 20 ProSE searches of the OpenMS#10364
benchmark at 1, 4, 8, 16 and 64 threads, an idXML load/store round trip of
323 files at 1/4/16/64 threads, and synthetic 300k-PSM files with 1 to 1000
runs. ProSE wall time (store included): 20 searches at 4 threads -11.8%,
one search at 16 threads -26%; no regression at 1 thread, peak memory
unchanged. New IdXMLFile_test sections cover input order, PeptideIdentifications
of no run, NaN scores and exceptions from the parallel section.

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

* [FEATURE] ProSE: faster search and higher identification rates

Speed, correctness, scoring and rescoring-feature changes to ProSE, measured
on the frozen 20-file DDA corpus of OpenMS#10364 (issue protocol: Percolator
3.09, 3 seeds, target PSMs at q <= 0.01). Against develop f6c680f:
+3.6% PSMs per file (3187.7 -> 3302.7), Velos UPS1 entrapment FDP 0.97% ->
0.91%, doubled-search-space FDP 1.13% -> 1.09%.

Speed (output byte-identical: all 20 files at 4 threads, six at 1, 16 and
64 threads; together about 4.5x faster at 4 threads):
- FragmentIndex::build bins fragments by m/z instead of a global sort, and
  counts the fragments first, then writes them straight into their bins.
- Regex-free digestion in FragmentIndex::generatePeptides.
- A multi-threaded peptide sort that reproduces std::sort exactly.
- One bucket walk for all precursor isotope errors, with skip tables and
  prefetching.
- postProcessHits_: PSM meta value keys resolved once and set by registry
  index; flat-storage Da alignment for the peak annotation.
- search(file, fasta) reads the mzML while the fragment index is built;
  parallel FASTA reading and index release; no copy of the database.
- Develop's ProSE changes (#10391, #10394, #10397, #10398, #10399) run inside
  the faster code: peptide:deduplicate is evaluated within the index build
  (same definition, no AASequence string per database peptide), and the
  local fragment evidence of #10399 reuses the annotation spectrum and
  merges the sorted alternative assignments. Output identical to develop.

Correctness:
- isotope_error is reported as observed minus theoretical (13C spacings),
  as in MS-GF+, pepXML and Sage and as PercolatorInfile expects; the search
  parameters record isotope_error_convention. The new
  report:isotope_error_convention=theoretical_minus_observed restores the
  previous sign. PercolatorAdapter warns about ProSE input without the
  record.
- PercolatorInfile keeps ExpMass/mass at the observed precursor m/z for all
  PSMs of a spectrum and removes the isotope error from dm/absdm/deltamass
  only, so PSMs of one spectrum at different isotope errors no longer enter
  target-decoy competition as different spectra.
- BREAKING: precursor:isotopes is removed (it was never used; the searched
  range is precursor:isotope_error_min/max). Inis that set it are rejected.
  FragmentIndex's default isotope range is [-2, 0].
- FragmentIndex rejects fixed terminal modifications it cannot restrict and
  does not add a variable whole-terminus modification on top of a fixed
  one; variable modification enumeration is bounded.
- The MS2 preprocessing filters are per thread (data race); warnings for
  decoys without the targets' initial Met under clipping.

Scoring:
- scoring:method (auto, hyperscore, mass_accuracy): a HyperScore whose ion
  counts and intensity product weight each match by a Gaussian of its mass
  error (scoring:mass_error_sd, 7 ppm). 'auto' uses it for ppm tolerances,
  HyperScore otherwise.
- FDR:PSM_groups (scored_charges, pooled): ProSE's own FDR:PSM competes PSMs
  scored with different numbers of fragment charges separately.

Spectrum preprocessing:
- MS2 deisotoping uses a Sage-like envelope rule: two isotope peaks make an
  envelope, charges up to the precursor charge (at most 3), the
  monoisotopic peak carries the summed intensity
  (fragment:deisotope_min_peaks / _charge_cap / _sum_intensity; 3 / none /
  false restores the earlier rule).

Rescoring features:
- annotate:self_trained_ion_priors (default on): a per-run fragment ion
  model (new class FragmentIonLikelihoodModel) learned from the run's own
  confident target PSMs against their reversed sequences, cross-fitted by
  scan parity, so no PSM is scored by a model that saw its spectrum or its
  label. Adds the Percolator features ion_prior_llr and ion_prior_explained;
  native scores and candidates are unchanged.

Tests: new and extended class tests (FragmentIndex, HyperScore,
ProSEAlgorithm, PercolatorInfile, FragmentIonLikelihoodModel). The TOPP
references ProSE_{1,2,4,10}_out.idXML are regenerated: with the earlier
deisotoping rule, HyperScore and the ion priors off, the new outputs differ
from develop's references only by the four recorded search parameters.
ProSE_{1,2,4,6_fdr}.ini no longer set precursor:isotopes.

Credits: the mass-accuracy HyperScore ports the opt-in scorer of Timo
Sachsenberg's #10379 (825c33b); the self-trained ion model builds on the
design of his self-trained per-run fragment ion priors (#10378, same
parameter name, different model); the speed patches started from his ProSE
branch, and develop's ProSE commits above are his.

Not included: the prototype dense-spectrum peak quota of Timo's benchmark
branch (20b6e75), which is not part of develop and which its author did
not propose for merging.

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

* [FEATURE] ProSE: round-3 speed packages from #10403 (input pipeline, protein mapping from the index, index build)

Applies the delta 9bfa53b..b95fdb0 of #10403 (feature/prose-best)
onto the develop-based branch of #10400:
- mzML files are cut into chunks parsed in parallel, the reader gets the caller's
  thread budget (at most 16) and decodes in batches of 1000; in the multi-file
  search the spectra are read in the background, the decoys are detected once,
  the fragment index is released after the last file and moved instead of copied.
- peptide:protein_mapping (default index): hits are mapped to their proteins from
  the occurrences the fragment index holds; PeptideIndexing is the fallback.
  Annotation results go to per-spectrum slots; PeptideIndexing sorts its matches once.
- Index build: fragments are tested against the bounds that select the buckets;
  single-use searches index only the peptides the searched spectra can reach;
  huge pages for the fragment array, a parallel merge of the per-thread peptide
  vectors, and an index-based top-N filter for low-resolution spectra.
- Regenerated ProSE_{1,2,4,10}_out.idXML of #10403.

Conflicts came from the prototype dense-spectrum quota and the candidate-competition
features, which #10400 removed and #10403 keeps switched off: the quota parameters,
the dense arguments of filterLocalPeaks_/preprocessSpectra_, AnnotatedHit_::prefilter_matches
and the prefilter-totals test are left out; filterTopNInJumpingWindows replaces the
WindowMower as in #10403. The CHANGELOG entries of the PR that duplicate #10427 and
#10428 are dropped.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ

* [FIX] Thread-safe exception state and serialised Xerces initialisation for parallel XML parsing

Review findings on #10403 (parallel chunked mzML reader):

- GlobalExceptionHandler recorded the last exception in shared static strings
  that every exception constructor writes. Exceptions constructed on several
  threads at once (e.g. chunks of a parallel mzML read that fail to parse)
  raced on them; ThreadSanitizer reported 15 data races in set() for a
  4-thread reproducer, none after the change. The fields are thread-local now
  and terminate() reports the entry of the thread it runs on. getInstance()
  uses a function-local static instead of a check-then-new on a pointer.
- Xerces requires callers to serialise XMLPlatformUtils::Initialize() and
  Terminate() (its counter is a plain integer). Internal::xercesInitialize()
  and xercesTerminate() in CONCEPT/Init take a process-wide lock; XMLFile,
  ImzMLFile and MzIdentMLDOMHandler call them. Parsing stays parallel.
- GlobalExceptionHandler_test is built again (it used the private
  constructor) and runs the concurrent-throw pattern.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ

* [FIX] FragmentIndex: terminal slots for residue-specific terminal modifications, no variable modification on a fixed one, zero-sum SNES subsets; ProSE: validate the mass-accuracy tolerance, rethrow worker exceptions

Review findings on #10403 (items 1-4 of the Debug-build review):

- buildModSlots_() stored a residue-specific terminal modification such as
  Gln->pyro-Glu (N-term Q) in a residue slot, so reconstructModifiedSequence()
  called setModification() on it and ResidueDB's precondition (term
  specificity ANYWHERE) aborted the parallel search. Such a modification is an
  NTERM_SLOT/CTERM_SLOT now and is set as the terminal modification; the mass
  shifts the same fragments either way. It is not applied where a fixed
  terminal modification sits.
- A variable modification is no longer applied to a residue that carries a
  fixed one (as in ModifiedPeptideGenerator): with Carbamidomethyl (C) fixed
  and variable, the index held both masses (+57.02 Da) while the
  reconstructed sequence kept one, and the peptidoform was indexed twice.
- SNES: a Σ = 0 hit passed through as the unmodified realization only, so a
  nonempty subset whose shifts cancel (Deamidated (N) with Amidated (C-term))
  was never produced. Such hits are expanded into the zero-sum subsets too
  when the configured shifts allow one (nonemptyZeroSigmaSubsetExists_()).
- ProSE: scoring:method=mass_accuracy with a fragment tolerance that is not
  finite and positive is rejected in updateMembers_(); 'auto' resolves to
  HyperScore then. HyperScore::computeMassAccuracy() threw this inside the
  parallel scoring loop and terminated the process.
- ProSE: the parallel scoring and calibration loops capture the first
  exception of a worker thread and rethrow it after the loop.

Tests: FragmentIndex_test checks the indexed mass of every entry against its
reconstructed sequence over configurations with fixed/variable overlap and
residue-specific terminal modifications, finds .(Gln->pyro-Glu)QPEPTIDER, and
finds AN(Deamidated)PEPTIDER.(Amidated) in SNES and conventional mode;
ProSEAlgorithm_test checks the tolerance validation. All failed on the
previous code (the pyro-Glu case with the ResidueDB precondition in Debug).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ

* [FIX] ProSE: no 'omp atomic write' in the chunked mzML reader (MSVC's OpenMP 2.0 rejects it)

build-wheels-windows on #10466 failed with C7660 at the two
'#pragma omp atomic write' sites of loadMzMLChunked(), a construct MSVC
accepts only with -openmp:llvm. A named critical section sets the flag
instead, as the parallel FASTA reader next to it does.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ

* [FIX,BUILD] IdXMLFile: compile without an OpenMP runtime

Ported from #10457 (commit 4b93cb5), which
is open against develop: without an OpenMP runtime the compiler still parses the
num_threads clause of the parallel pragma in IdXMLFile::store, so team_size must be
declared unconditionally. No-op once develop carries it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ

* [TEST] FragmentIndex: check the removed occurrences recorded by peptide:deduplicate (from #10403)

The deduplication test of #10403's tagged version also compares
getRemovedOccurrences() with the entries the deduplication removed; the
port took the recording code from that version but the test section from
#10400, which predates it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ

* [FIX] IdXMLFile: report stream failures of the parallel block writer

IdXMLFile::store could return successfully after writing a truncated
idXML:

- Each block of the parallel writer is formatted into a std::ostringstream
  without an exception mask. A std::bad_alloc while the stringbuf grows
  only sets badbit; str() then returns the partial text, and the block was
  written as if complete.
- The state of the file stream was never checked, neither after the
  ordered block writes nor after close(), so disk-full and I/O errors went
  unnoticed (develop's serial writer had the same gap).

Changes:
- New protected static IdXMLFile::formatBlock_() formats a block with
  badbit | failbit exceptions on the block stream; libstdc++ then rethrows
  the original std::bad_alloc, which the existing per-block exception_ptr
  carries to the caller. The text written on success is unchanged.
- The ordered section checks the file stream after each block write and
  stops the remaining blocks on failure; the exception is constructed
  after the parallel region.
- After close(), a failed stream throws Exception::UnableToCreateFile.
- store() never removes its output, and every failure is raised. An
  OpenMS exception keeps its type and gets a note that names the file and
  says that a partial file may remain (without the note if there is no
  memory for it); any other exception (e.g. std::bad_alloc) is raised
  unchanged, since wrapping it would need memory.

Tests (IdXMLFile_test): formatBlock_ with throwing and failing stream
buffers; store() into an idXML symlinked to /dev/full at 1 and 4 threads;
a throwing block and protein section for a new and an existing file (also
with a second hard link); a fault-injection sweep over every allocation of
store() on the calling thread; a change of the working directory, a file
renamed into place, an unsearchable parent directory and a read-only
file; a throwing close(). The fault-injection sections replace the global
operator new and run on Linux only (skipped with a message elsewhere or
with OPENMS_TEST_NO_FAULT_INJECTION).

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

* [TEST] FragmentIndex: fragments on tolerance-window and bucket bounds

aed31fa makes the index build test the fragments against the same float
bounds of a peak's tolerance window that select the fragment buckets; the
two tests rounded differently, so whether a fragment on or next to a bound
was counted depended on the bucket layout. That fix came without a test.
Two class test sections, written with their expectations before they were
first run:

- query() on hand-placed fragments: the two peaks named in the fix
  (511.830292 and 1024.05737 Th, 0.5 Da) with fragments on, and one ulp
  inside and outside of, both window bounds. The float bounds and the
  expected peptide indices were derived by hand (bit patterns in the test).
  The section checks every bucket layout of these 12 fragments (bucket
  sizes 1 to 12), so fragments also sit on bucket boundaries. Without the
  fix, the fragment at hi = 512.330322 (512.330322 - 0.5 = 511.830322 >
  511.830292) was missed, and 1023.55731, one ulp below lo = 1023.55737, was
  accepted whenever its bucket was visited.
- query() and querySpectrum() on a built index with 4096-fragment buckets:
  for peaks whose window starts or ends exactly on the smallest m/z of a
  bucket, and peaks up to 3 ulps off them, the matched fragments and the
  per-candidate counts must equal a brute-force count over all fragments of
  lo <= m/z <= hi.

The SNES byte scan and candidate collection changed by the same fix are
not covered by a boundary-specific test here.

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

* [TEST] ProSEAlgorithm: ion-prior gate crossing; correct the cross-fit doc

The documentation of the self-trained ion priors claimed that "neither a
PSM's own spectrum nor its label, nor any label of its fold, enters its
features" (ProSEAlgorithm.h, annotateIonPriors_, and the ProSE TOPP page).
That is not strictly true: training is enabled by a run-level gate that
requires annotate:ion_prior_min_psms training PSMs in BOTH halves, and the
training counts depend on the labels. At the boundary a single label flip,
in either half, switches both halves between their cross-fitted features
and all zeros, so a label of a half does reach that half's own features
through the gate. The gate is label-symmetric (targets and decoys alike),
so no code change is needed; only the wording overclaimed, and the
existing label-flip test never crossed the gate.

Changes (documentation and test only; no output changes):
- ProSEAlgorithm.h: the model that scores a PSM never saw its spectrum or
  label, nor any other label of its fold; the run-level gate is the one
  place where a fold's labels reach its own features, one label decides at
  the boundary, and the gate is label-symmetric but not formally
  independent of the labels.
- ProSE.cpp (TOPP doc page only): the same correction.
- ProSEAlgorithm_test: in "[EXTRA] self-trained ion priors are
  cross-fitted", a new block sets annotate:ion_prior_min_psms to the
  training count of the smaller half (trained; features equal those of the
  lower minimum), then flips the label of that half's best target. It
  asserts ion_prior:trained == "false", the half's training count below the
  minimum, the all-zero fallback on every hit (complete feature columns,
  all 0), and that features changed in both halves.

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

* [FIX] FragmentIndex: a residue-specific terminal variable modification applies next to a fixed modification of the residue

buildModSlots_() skipped every variable modification of a residue that
carries a fixed one, also the residue-specific terminal ones, which sit on
the terminus and not on the residue. With Carbamidomethyl (C) fixed and
Ammonia-loss (N-term C) variable (N-terminal pyro-carbamidomethyl cysteine)
.(Ammonia-loss)C(Carbamidomethyl)PEPTIDEK was therefore never indexed,
conventionally or with SNES, while ModifiedPeptideGenerator generates it.
The fixed modification of a residue now excludes only the variable residue
modifications (ANYWHERE) of that residue.

As in ModifiedPeptideGenerator, Pyro-carbamidomethyl (N-term C), which
Unimod defines on unmodified cysteine, is now also applied next to a fixed
Carbamidomethyl (C); Ammonia-loss (N-term C) is the modification for that
configuration.

Test: FragmentIndex_test compares the index for CPEPTIDEK and CCTESLVNR
with ModifiedPeptideGenerator and searches the spectrum of
.(Ammonia-loss)C(Carbamidomethyl)PEPTIDEK with and without SNES. On
e910aea the two N-terminal forms were missing from the index and the
spectrum got no hit in either mode.

Review of #10466 (finding F1).

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

* [FIX] ProSE: fragment:mass_tolerance must be finite and positive for every scoring method

updateMembers_() rejected a fragment tolerance that is zero, negative, NaN
or infinite only for scoring:method=mass_accuracy and with local fragment
evidence. With 'auto' or 'hyperscore' and local fragment evidence off it was
accepted, and 'auto' fell back to HyperScore. HyperScore and the fragment
index match within the same tolerance, so such a search ended with exit code
0 and no hits (0, -5, NaN ppm; 0 Da) or with inflated scores (inf) on the
TOPP_ProSE_1 inputs. The tolerance is now checked once, for every method,
where it is read.

Test: the ProSEAlgorithm_test section of 74f8ed9 asserted the 'auto'
fallback; it now expects InvalidParameter for {mass_accuracy, auto,
hyperscore} x {ppm, Da} x {0, -1, inf, NaN} x local fragment evidence
{off, on}. On e910aea, 16 of these 48 cells were accepted.

Review of #10466 (finding F6).

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

* [FIX] FragmentIndex: SNES expands a hit into the modification subsets within variable_max_per_peptide only

querySpectrumSNES_() expanded every Sigma hit by visiting all 2^n_slots
bitmasks of the realized peptide and skipping those with more than
modifications:variable_max_per_peptide slots afterwards. Since 74f8ed9
every Sigma = 0 hit is expanded too as soon as the variable modifications
contain a cancelling pair (e.g. Deamidated (N) with Amidated (C-term)), so
the unmodified candidates of long peptides with many modification sites paid
for it as well. The loop now steps with nextSubsetWithin(), which the
conventional enumeration already uses: the same subsets in the same
(increasing) order, so the output does not change.

Test: FragmentIndex_test queries a peptide with 31 slots (29 x Oxidation (M),
Deamidated (N), Amidated (C-term); at most 2 per peptide) in SNES mode and
finds the unmodified and the zero-sum form. The query took 9.49 s on
e910aea (Release build) and takes 0.16 ms now; the test requires < 5 s.

Review of #10466 (finding F5).

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

* [FIX] FragmentIndex, ProSE: report every variable modification that a fixed one excludes

74f8ed9 stopped applying a variable modification where a fixed one sits
on the same residue (Carbamidomethyl (C) fixed and variable, Glutathione (C)
with Carbamidomethyl (C) fixed) and a residue-specific terminal variable
modification where a fixed one sits on the terminus (Gln->pyro-Glu
(N-term Q) with TMT6plex (N-term) fixed). Neither was reported:
shadowedVariableTerminalModifications() still returned only the terminal
modifications without a residue preference, and its documentation said that
the residue-specific ones are searched as before.

- shadowedVariableTerminalModifications() also returns the residue-specific
  terminal modifications that a fixed terminal one excludes.
- New shadowedVariableResidueModifications(): the variable residue
  modifications that a fixed modification of the same residue excludes.
- ProSEAlgorithm::updateMembers_() warns about both. For a modification
  that is fixed as well, the advice is to remove it from
  modifications:fixed; "specify it as a variable one as well" was circular
  there.
- The description of modifications:variable (ProSE, FragmentIndex) names
  both rules.

Tests: FragmentIndex_test (helper expectations with Gln->pyro-Glu, the index
agrees with both helpers) and ProSEAlgorithm_test (the warnings). On
e910aea the helper expectations and 5 warning checks failed.

Review of #10466 (finding F9).

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

* [FIX] ProSE: restore the calibrated tolerances and end the progress display when a search throws

search() and searchChunked_() narrow the precursor tolerances of the
instance (and the parameters of the search context's FragmentIndex) after
the calibration pass, and restored them only on their return paths. Since
74f8ed9 a worker exception of the scoring or calibration loop reaches the
caller; after it (or any other exception after the calibration pass) the
instance kept the calibrated window, e.g. [-14, +1e-06] ppm instead of the
configured [-20, +30] in the test below, for the next search of a caller
that catches it. The progress display started for the loop was not ended
either (ProgressLogger's recursion depth is process-wide).

The restore now also runs when an exception leaves these functions (a
small scope-exit helper; the return paths are unchanged), the scoring loop
ends its progress display before rethrowing, and search() ends the
calibration progress display when the calibration loop rethrows.

Test: ProSEAlgorithm_test throws from the progress display when the scoring
of the main search starts (one search context, and database chunks), then
checks the tolerances and that the instance searches as a fresh one; and
counts the started and ended progress displays after a worker exception of
the scoring and of the calibration loop. On e910aea the tolerances stayed
calibrated in both paths and one progress display was not ended.

Review of #10466 (finding F7).

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

* [FIX] ProSE: no exception leaves preprocessSpectra_(), the calibration hit list or the chunked mzML reader

An exception that leaves an OpenMP structured block calls std::terminate().
74f8ed9 catches the worker exceptions of the scoring and calibration
loops; three places next to them still let one escape:

- preprocessSpectra_() had no exception handling, and its filters were
  copied per thread on entry to the region (firstprivate). The copies are
  now made before the loop, and the loop captures the first exception and
  rethrows it after the region, like the scoring loop.
- The calibration loop pushed its hits inside an omp critical section; a
  reallocation there threw out of the critical section (GCC terminates even
  though the loop body catches outside it). The hit list now reserves one
  entry per spectrum of the subset, so the push never reallocates.
- loadMzMLChunked() caught exceptions of the chunk parser only. Opening
  the file and resizing the block and chunk buffers (up to about 9 MB per
  thread) now happen inside the try of each iteration, so a failure makes
  the caller read the file with MzMLFile::load(), as intended.

Only allocation failures were found to reach these places with the earlier
fixes of this PR. Other parallel regions of ProSE (protein mapping,
post-processing) and of OpenMS (e.g. PeptideIndexing) still terminate on
std::bad_alloc.

Test: ProSEAlgorithm_test starts itself as a child process that fails every
allocation of preprocessSpectra_() on the calling thread once, one after
the other (a replacement of the global operator new; Linux only). On
e910aea the child terminated at allocation 59; now all 163 failures
reach the caller as std::bad_alloc.

Review of #10466 (finding F4).

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

* [FIX] XMLValidator: initialise Xerces under the lock of Internal::xercesInitialize()

9ce130e serialises XMLPlatformUtils::Initialize() for the parsers, but
XMLValidator::isValid() (reached via XMLFile::isValid(), MzMLFile::isValid()
and others) still called it directly. Its unlocked increment of Xerces'
initialisation counter races with a parse on another thread. The count
cannot drop to zero in practice (the static xerces_init holds one
reference), so this is a formal data race rather than a crash, but it keeps
the serialisation incomplete.

Evidence (no class test: Xerces is not instrumented for TSan): a probe that
validates on one thread while ParamXMLFile::load() runs on another, under
valgrind --tool=helgrind, reported data races on Xerces' gInitFlag in
XMLPlatformUtils::Initialize() and none after this change.
XMLValidator_test and XMLFile_test pass.

Review of #10466 (finding F2).

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

* [FIX] GlobalExceptionHandler: terminate() reports the exception that was not caught

Since 9ce130e the handler records the last exception per thread, and
terminate() printed the entry of the thread that terminates. Since
74f8ed9 the parallel loops of ProSE carry a worker thread's exception
to the calling thread with std::exception_ptr and rethrow it there; if a
caller does not catch it, terminate() printed that thread's last entry,
i.e. no entry or an older exception, instead of the worker's.

terminate() now reports the uncaught exception itself (an OpenMS exception
carries type, file, line, function and message) and falls back to the last
entry of the thread otherwise.

Test: GlobalExceptionHandler_test starts itself as a child process (Linux)
in which an exception constructed on a worker thread is rethrown uncaught on
the main thread, and checks the report on its standard output. On
e910aea it held "FATAL: uncaught exception!" and no exception.

Review of #10466 (finding F10).

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

* [FIX] FragmentIndex: SNES tolerates the float rounding of a large Sigma

querySpectrumSNES_() stores the Sigma of a hit as float and matched the
subsets of the realized peptide to it within 1e-4 Da. Above 2048 Da the
float rounding alone reaches 1.2e-4 Da, so a subset could fail to match its
own Sigma: e.g. two Hex(5)HexNAc(4) (N) glycans (Sigma = 3245.163 Da, stored
1.1e-4 Da off) were never realized by SNES, while the conventional index
finds the peptidoform. In Unimod, 9629 of the 52252 pairs of shifts above
1000 Da that sum to 2048 Da or more lose 1e-4 Da or more this way.

The match now allows half an ulp of the stored value (|Sigma| * 2^-24) on
top of the 1e-4 Da. The comment that gave 1e-6 Da as the tolerance is
corrected.

Test: FragmentIndex_test searches AN(Hex(5)HexNAc(4))GTPEPN(Hex(5)HexNAc(4))-
ESIDER with and without SNES; on e910aea SNES did not find it.

Review of #10466 (finding F8, second part; pre-existing SNES
code).

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

* [FIX] ProSE: the scoring loop's progress counter is atomic for its reader too

Every thread of scoreSpectraAgainstIndex_() incremented count_spectra with
'#pragma omp atomic', and the master thread read it without synchronisation
for setProgress(). An atomic update does not order a plain read on another
thread, so this is a data race; ThreadSanitizer reports it ("Read of size 8
by main thread" in setProgress(count_spectra) after an "atomic write" by a
worker). The value only feeds the progress display. The counter is a
std::atomic<Size> now (fetch_add, the master shows its own result); no
'omp atomic read', which MSVC's OpenMP 2.0 lacks.

The same idiom is in SimpleSearchEngineAlgorithm and IDBoostGraph (not
changed here).

Evidence (no class test: the race needs ThreadSanitizer): a probe that
searches 839 spectra on 8 threads, linked against a TSan build of
e910aea, reported the race; against a TSan build with this change it does
not. ProSEAlgorithm_test and TOPP_ProSE_* pass.

Review of #10466 (finding F3; pre-existing, from #10400).

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

* [FIX] ProSE: no unused-parameter warning without OpenMP

readerThreads() reads its parameter 'background' only in the _OPENMP
branch, so builds without an OpenMP runtime (MT_ENABLE_OPENMP=OFF, or
Clang with the -fopenmp-simd fallback) warned "unused parameter
'background'". It is marked [[maybe_unused]].

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

* [TEST] FragmentIndex: residue-specific terminal modifications on peptide and protein termini

Nine fixtures compare the index with an AASequence oracle: the peptidoforms
(as reconstructed sequences, which must parse back), their precursor m/z
and their b/y fragment m/z. They cover Gln->pyro-Glu (N-term Q) alone, on
a peptide without N-terminal Q, competing with Acetyl (N-term) for the
N-terminus, next to Deamidated (Q) on the same residue, and excluded by a
fixed TMT6plex (N-term); Ammonia-loss (N-term C) next to a fixed
Carbamidomethyl (C); and Dehydrated (Protein C-term Q) with and without a
fixed Amidated (C-term). Protein-terminal residue preferences get a slot
only at the protein terminus, and SNES realizes Gln->pyro-Glu on the
N-terminus.

Without the fix for residue-specific terminal modifications on a residue
with a fixed modification, the Ammonia-loss (N-term C) fixture gets one
peptidoform instead of two; the other fixtures guard the terminal slots
introduced in 74f8ed9.

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

* [DOC] CHANGELOG: ProSE entries without timing and yield figures; entries for the fixes

- Remove the timing and yield figures from the ProSE entries (PERF of the
  search, the deisotoping envelope rule, protein mapping); measurements
  are reported separately.
- Add the entry for the fragment bound fix of aed31fa (the fragments
  are tested against the bounds that select the buckets).
- Update the FragmentIndex and ProSE entries for the fixes of this PR: a
  residue-specific terminal variable modification applies next to a fixed
  modification of the residue; fragment:mass_tolerance must be finite and
  positive for every scoring method (local fragment evidence no longer is
  the only check); the preprocessing loop rethrows worker exceptions too;
  the warning names every variable modification that a fixed one excludes.

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

* [DOC] ProSE: no timing figures on the tool page

The notes on several input files and on threads keep their advice (one call
for all files, OMP_WAIT_POLICY=passive on shared machines, no thread binding)
but no longer quote measurements from one machine and one benchmark (0.7x,
less than half the CPU time, 15-18% slower). As in the CHANGELOG, which
dropped its timing and yield figures in c013052.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ

* [CI] Windows: download the custom NSIS from raw.githubusercontent.com (port of #10472)

Same change as 8582fa4 on #10472, carried here so the Windows
build-and-test job of this PR can build while
https://github.com/OpenMS/NSIS/raw/main/NSIS.tar.gz returns GitHub's 504
error page. It becomes a no-op when develop carries #10472.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ

---------

Co-authored-by: Oliver <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Julianus Pfeuffer <[email protected]>
@okohlbacher
okohlbacher deleted the feature/prose-speed-quality branch October 9, 2026 18:00
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