Skip to content

ProSE best version on Timo's benchmark branch: speed patches, develop's ProSE fixes, scoring and rescoring features, round-3 speed packages (+3.6% PSMs, about 8x faster than develop) - #10403

Closed
okohlbacher wants to merge 81 commits into
OpenMS:claude/quirky-galileo-tkpwe4-prose-peak-filterfrom
okohlbacher:feature/prose-best

Conversation

@okohlbacher

@okohlbacher okohlbacher commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

This PR proposes the best ProSE version from our benchmark work, as a series on top of Timo's ProSE benchmark branch (claude/quirky-galileo-tkpwe4-prose-peak-filter, 20b6e75).

Update, 3 October: the series now also carries three round-3 speed packages (item 6): the input pipeline, protein mapping from the fragment index, and the index build. They make the 20 benchmark searches 1.42x faster than the tagged version prose-best-2026-10-03 (9bfa53b), about 8x faster than develop. The output is the same apart from one z-score value in two spectra (below). The ProSE TOPP references are regenerated (26/26 ProSE TOPP tests pass). This head is tagged prose-best2-2026-10-03. #10400, the same work against develop, does not contain the round-3 packages yet.

What the series contains (in order)

  1. Ten speed patches (byte-identical output). m/z-binned fragment index build (count, then fill); regex-free digestion; an exact parallel replica of std::sort for the peptide sort; one bucket walk for all isotope errors with skip tables and prefetch; meta-value keys resolved once; flat Da alignment for annotation; the mzML read concurrent with the index build; parallel FASTA read and index release; no database copy.
  2. develop's ProSE commits, ported onto the faster code: [FIX] ProSE: deisotoping no longer removes fragment ions that have a small peak one isotope spacing below; HyperScore Da-mode error on arm64 #10391, [FIX] ProSE: index each exact peptidoform once (peptide:deduplicate) #10394, [FEATURE] ProSE: score multiply charged fragments of spectra that are not deisotoped #10397, [FIX] ProSE: annotate the scored fragment charges when the precursor charge is unknown #10398, and [FEATURE] ProSE: raw-spectrum candidate retrieval for high-resolution spectra and local fragment evidence #10399 (added last). [FIX] ProSE: index each exact peptidoform once (peptide:deduplicate) #10394's deduplication is evaluated inside the index build: building an AASequence string per database peptide would cost about 4 s per search. With the round-2 packages switched off, the result reproduces develop f6c680f's output on all 20 files: native TSV byte for byte, idXML apart from the prototype's two search-parameter records.
  3. peaks:dense_intensity_loss 1.0 by default: the prototype quota of 20b6e75 is off, as in develop (see the note below).
  4. Round-2 packages (merge commits per package):
    • correctness: isotope_error sign; one ExpMass per spectrum in PercolatorInfile; fixed terminal modifications; bounded enumeration; per-thread preprocessing filters; precursor:isotopes removed;
    • mass-accuracy weighted HyperScore for ppm tolerances, and FDR:PSM per number of scored fragment charges;
    • Sage-like MS2 deisotoping;
    • candidate-competition features (all off by default);
    • a self-trained, cross-fitted fragment-ion model as Percolator features;
    • a parallel, byte-identical idXML writer.
  5. One documentation commit (7f606ea): the parameter description of peaks:dense_intensity_loss now gives the entrapment result pooled over three shuffles. No output changes (checked on 3 files).
  6. Round-3 speed packages (new; one merge commit per package), then the regenerated TOPP references (b95fdb0):
    • Input pipeline. mzML files are cut into chunks that are 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 TOPP tool's entry point) the spectra are read in the background, the decoys of the database are detected once, the fragment index is released after the last file, and FragmentIndex gets move operations, so the context is no longer deep-copied (about 2 GB per run). After a chunked read with 8 or more threads, the freed heap is returned (glibc).
    • Post-search tail. New parameter peptide:protein_mapping (default index): the hits are mapped to their proteins from the occurrences the fragment index already holds, instead of a PeptideIndexing pass over the whole database. The output is what PeptideIndexing writes, and a database over the lookup budget falls back to PeptideIndexing. Also: annotation results go to per-spectrum slots, the decoy marker of large databases is detected in parallel, and PeptideIndexing sorts its matches once.
    • Index build. A fix: fragments are now tested against the same bounds that select the buckets (before, a fragment exactly at the tolerance bound could be counted or not, depending on the bucket layout). Single-use searches without calibration index only the peptides the searched spectra can reach. Also: transparent 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.

Results (frozen corpus of #10364)

Issue protocol: Percolator 3.09, seeds 1/42/137, q <= 0.01. Timing: idle 64-core EPYC 7763, whole process, one search at a time.

develop f6c680f tagged version (9bfa53b) this PR (head)
accepted PSMs per file (mean of 20) 3187.7 3302.7 (+3.6%) 3302.6
Velos UPS1 entrapment FDP (nominal 1%) 0.97% 0.91% see below
doubled search space (shuffled entrapment copy of every target), combined FDP, shuffles 1/2/3 1.13 / 0.98 / 0.96% 1.09 / 1.00 / 0.99% see below
20 searches at 4 threads 560.4 s 98.3 s (5.7x); 98.8 s in the run of the next column 69.4 s (1.42x against 98.8 s; about 8x against develop)
4 searches (Velos, HF-X, Astral, timsTOF) at 1 / 16 / 64 threads 326.2 / 61.8 / 62.2 s 67.6 / 9.9 / 9.7 s; 67.9 / 9.8 / 9.7 s in the run of the next column 49.5 / 7.1 / 5.1 s
speed-up from 1 to 64 threads (4 searches) 5.2x 7.0x 9.7x
  • Output of this head against the tagged version. The native result table is identical on 20/20 files and the idXML on 18/20. In the other two (velos_5000_R2 scan 25808, lumos_tmt_5066 scan 56001), only hyperscore_zscore of that spectrum's 10 hits changes: the bucket-bound fix moves one peptide into or out of the 50 scored candidates. Percolator on these two files: +3.0 and −4.0 PSMs (retraining noise from one changed PIN row each). The Velos UPS1 entrapment of velos_5000_R2 alone moves from 70/9183 to 74/9192 PSMs over the three seeds. The other 18 files are byte-identical, so the remaining FDP figures are those of the tagged version.
  • Timing caveats. Both runs used the same node, inputs and per-file parameters, but two harnesses:
    • develop and the tagged version (560.4 s, 98.3 s) were timed with the benchmark's timing harness;
    • this head was timed with our measurement harness, in a single repetition, with the tagged version run before it on every file. That tagged arm reproduced the earlier numbers within 1% (98.8 s against 98.3 s).
    • The ratio against develop (about 8x) therefore spans the two harnesses and is not a paired measurement.
    • Peak RSS of the 20 searches is 20-36% lower than the tagged version's.
  • Larger inputs. These were measured with the input-pipeline and post-search-tail packages, before the index-build package was added:
    • 72,000 Astral spectra at 64 threads: 20.0 -> 9.9 s; going from 4 to 64 threads now gives 4.0x instead of 2.2x.
    • 24,000 Astral spectra at 4/16/64 threads: 13.5/5.9/3.8 s, against 15.9/8.6/7.5 s for the tagged version and 14.8/7.2/5.6 s for our Sage fork.
  • Per group against develop (tagged version, 3 seeds): Velos +2.6%, HF-X +3.8%, Astral +15.3%, Lumos LFQ +0.1%, Lumos CID TMT +1.7%, Exploris TMTpro +2.5%, timsTOF +0.5%. Against this branch's own head 20b6e75 (with our speed patches): +9.5% PSMs.
  • Against other engines (our runs on the same files and protocol): ANDES 3301, Sage 3146 and MSFragger 3137 accepted PSMs per file. With 20 Percolator seeds the remaining per-group gaps of the tagged version are HF-X −1.8% and Lumos LFQ −1.0% against ANDES, and Lumos CID TMT −1.0% against MSFragger. On Astral it is ahead of ANDES.

Leave-one-out tables, every package's measurements and the reviews behind them are in #10400 and in the repository okohlbacher/prose-tests (branch dev, folder round2/).

Notes for review

  • Prototype dense-spectrum quota. On the first entrapment shuffle the PSMs it adds on Astral looked about 4% false, and commit c8e6db0 switched it off on that basis. Two further shuffles did not confirm this: pooled over three shuffles its 1,893 added Astral PSMs carry about 1.3% false discoveries, near nominal and similar to changes that were kept. It stays off here because the keep rule required at most 1%. In the tagged build, switching it on gives +0.4% PSMs (Astral +2.0%, timsTOF +3.6%) and raises the doubled-database FDP from 1.09% to 1.15%, measured on one shuffle. The message of c8e6db0 still quotes the single-shuffle figure; the parameter description is corrected in 7f606ea.
  • Deisotoping default. The Sage-like rule failed its own package rule on timsTOF (−1.5% on three Percolator seeds, +0.2% on thirteen). It is on because the integration's leave-one-out kept it (+0.8%). A held-out check is pending.
  • Breaking changes:
  • Peptide sort (Timo's comment). The proposal to replace the exact std::sort replica with a total-order peptide key and Boost.Sort is not in this update.
  • Measured, not included:
    • counting b2/y2 ions in the fragment index at ppm tolerances: +2.2% PSMs on the 14 ppm files, FDP not higher, +7% time;
    • computing the Percolator ion features on 150 peaks at 0.5 Da: +2.4-3.0% on Velos and Lumos CID TMT.
    • Both need production code first.
  • Tests.
  • Held-out confirmation pending. All design choices were measured on the 20 benchmark files.

🤖 Generated with Claude Code

okohlbacher and others added 30 commits October 2, 2026 15:00
… comparison sort

What
- Fragment generation: per-thread vector objects are padded to cache lines of their own (their size
  is updated with every fragment: false sharing), peptides are handed out with schedule(dynamic)
  (they are sorted by mass, so static ranges were unbalanced), and full vectors are set aside as
  32 MB blocks.
- mergeFragmentsIntoMzBins() replaces "concatenate serially, then boost::sort::block_indirect_sort":
  a parallel histogram and a parallel scatter move the blocks straight into the final array,
  partitioned into m/z bins (bin = float bit pattern >> 14). Blocks are released as they are
  consumed, so there is no second full copy.
- sortAndBucketBinnedFragments() finishes each bin on its own in linear time: radix sort by peptide
  index, count the fragments per exact m/z value, then walk the bin in peptide order; the count of
  smaller m/z values plus the fragments of this m/z value seen so far is the rank of a fragment in
  (m/z, peptide) order, which names its bucket. Buckets cut by a bin boundary are merged at the end.
- Fragment's default constructor no longer zeroes the members, so that resize() of the final array
  costs nothing and its pages are first touched by the scattering threads.
- The previous code (comparison sort + per-bucket radix sort) stays as the path for input that is not
  binned (negative/NaN m/z, more than 8192 bins) and is what sortAndBucketFragments_() falls back to.

Why the results are identical
The index is a function of the multiset of fragments only: bucket k holds the fragments of rank
[k*bucketsize, (k+1)*bucketsize) in (m/z, peptide) order, sorted by (peptide, m/z), and
bucket_min_mz[k] is the m/z at rank k*bucketsize. Fragments equal in both fields are bitwise
identical, so neither the thread that generated a fragment nor the order inside a bin can show.
For m/z values that are neither negative nor NaN the IEEE-754 bit pattern orders like the value;
anything else takes the old path. sortAndBucketBinnedFragments() verifies that every fragment lies
in its bin and otherwise returns false, so it never depends on its caller.
Checked: byte-identical TSV and idXML on all 20 benchmark files at 4 threads and on hfx_B1 and
velos_125_R1 at 1 and 16 threads (20 repeats at 16 threads); with the old path forced; and in a
randomised differential test of both helpers against the original algorithm (20k cases: sizes
1..6e6, bucket sizes 1..65536, tie-heavy and single-bin m/z distributions, 1-8 threads), also
under ASan/UBSan.

Measured (kim, EPYC 9654, medians of 3 interleaved runs, base 20b6e75 -> this commit)
  4 threads: hfx_B1 17.80 -> 8.80 s (2.02x), velos_125_R1 25.56 -> 17.73 s (1.44x),
             eclipse_tmtpro_10855 12.25 -> 6.57 s (1.86x); peak RSS 2.81 -> 2.13, 2.61 -> 2.01,
             1.65 -> 1.39 GiB
  16 threads: hfx_B1 8.76 -> 5.74 s (1.53x), velos_125_R1 11.55 -> 9.19 s (1.26x)
  1 thread: hfx_B1 49.1 -> 21.1 s, peak RSS 3.81 -> 2.10 GiB
hfx_B1, 4 threads, 234 M fragments: generation 2.06 -> 1.1 s, merge 0.97 -> 0.45 s,
sort + bucket 7.9 -> 0.42 s.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 2172bc5ea09735b551590dfdf3f91c5aca19f1e8)
What
- Fully specific digests with a simple cleavage rule ("(?<=[..])" with an
  optional "(?!X)": Trypsin, Trypsin/P, Lys-C, Arg-C, Chymotrypsin, CNBr, ...)
  no longer go through ProteaseDigestion::digestUnmodified (boost::regex
  tokenizer plus a std::string copy per protein). A byte scan finds the
  cleavage sites and the spans are enumerated in place. The initial-Met-loss
  spans are derived from the same site list instead of a second digest of
  sequence.substr(1) and a std::set. Every other enzyme or specificity still
  uses the library digest.
- The per-thread peptide vectors are padded to one cache line each (their
  end pointers were written for every peptide and shared a line: the loop
  ran at about half speed for three of four threads).
- The per-thread reserve is estimated from the residue count (one peptide
  per two residues) instead of five peptides per protein, which removes the
  five to six reallocation copies per thread.

Why the results are identical
- The helper emits the same (start, length) spans in the same order as
  digestUnmodified + the Met-loss block: checked with a temporary self-check
  against the library for every protein of the hye/hy/human target-decoy
  FASTAs, 24 enzymes x 7 settings (missed cleavages 0-5, length limits
  including "no maximum", Met clipping on/off): 504 runs, 2.77e9 spans, no
  difference (self-check removed again).
- Static scheduling and the merge are unchanged, so the pre-sort peptide
  sequence and therefore the std::sort result are the same.
- Byte-identity gate passes on the six core files (4 threads).

Measured (kim, 4 threads, interleaved, median of 3)
- digest loop of generatePeptides: 1.50 s -> 0.15 s (hfx_B1)
- hfx_B1 17.76 s -> 16.40 s (1.08x), velos_125_R1 25.86 s -> 24.78 s (1.04x),
  eclipse_tmtpro_10855 12.31 s -> 11.47 s (1.07x); peak RSS not higher.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 7541fd29d5d2bd3801913cb3093e83b5dec0c805)
…skip tables, prefetch

What
- searchDifferentPrecursorRanges collects the candidate ranges of all isotope
  errors of a precursor charge and queryPeaks walks the fragment buckets ONCE
  for them (was: one full walk per isotope error, 4 with -2..+1).
- buildSkipTables_() (called at the end of build()) samples the peptide_idx_ of
  every 64th fragment and of the last fragment of each bucket (65 x 4 B per
  32 kB bucket, 0.8% of the index). queryPeaks finds the start of the candidate
  ranges from these samples (count + interpolation between two samples) instead
  of a 12-probe std::lower_bound over the bucket, and skips buckets whose
  sampled first/last fragment shows that they hold no candidate at all.
- Bucket visits go through a 16-deep software pipeline: the three cache lines
  around the interpolated position are prefetched when a visit is located and
  the visit is scanned 16 visits later.
- Closed search reads the few-kB count table in order instead of gathering and
  sorting the survivors.

Why the results are identical
- Bucket range per (peak, fragment charge) and the float match predicate
  (adjusted_mass >= mz - tol) && (adjusted_mass <= mz + tol) are unchanged.
- The samples only steer: the scan corrects the interpolated guess to the exact
  std::lower_bound, and a bucket is skipped only if its smallest peptide index
  is >= the end of the last range or its largest is < the start of the first.
- The ranges handed to one walk are disjoint and ascending (overlapping ones,
  i.e. very wide precursor tolerances, are walked separately as before), so
  every (peak, fragment) pair is counted into exactly the block that counted it
  before; the counts are integers, so the visiting order is irrelevant.
- Blocks are emitted in ascending isotope error and ascending peptide index
  within a block, as before.
Byte-identical TSV/idXML on the six core files at 4 threads and on hfx_B1 /
velos_125_R1 at 1 and 16 threads; also verified identical for an open search
(+-200 Da), a 1 Da and a 1000 ppm precursor tolerance (overlapping blocks).
HyperScore_test, FragmentIndex_test and ProSEAlgorithm_test pass.

Measured (kim, EPYC 9654, 8000 MS2 spectra, medians of 3 interleaved runs)
- query phase CPU: velos_125_R1 28.7 -> 3.5 s, lumos_tmt_5058 21.5 -> 2.7 s,
  hfx_B1 7.7 -> 1.2 s
- wall, 4 threads: velos_125_R1 25.84 -> 19.45 s (1.33x), lumos_tmt_5058
  22.73 -> 18.70 s (1.22x), hfx_B1 17.94 -> 16.48 s (1.09x)
- wall, 16 threads: velos_125_R1 11.93 -> 9.84 s (1.21x)
- peak RSS unchanged (velos 2.62 -> 2.61 GiB, hfx 2.85 -> 2.87 GiB)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 32c11f9dfb297a82271c0b783e9bcd197b1d410b)
What: for absolute (Da) fragment tolerance, postProcessHits_ now aligns the
theoretical and the experimental spectrum with a private copy of
SpectrumAlignment's banded dynamic programme (alignAbsoluteTolerance_) that
keeps the band in flat vectors (two score rows, one byte of traceback per
computed cell) instead of std::map<Size, std::map<Size, ...>> (two tree nodes
and several O(log n) lookups per cell, plus n1 + n2 border nodes per call).
The ppm branch and SpectrumAlignment.h are untouched.

Why identical: same row/column traversal, same left-border and off-band
rules, same expressions and comparison order for the three scores, same
traceback. Cells the reference never computes are either border cells
(i * tolerance, j * tolerance, (0,0) = 0) or absent, for which it substitutes
(i + j) * tolerance - the same value, so one formula serves both; a traceback
step onto an absent cell ends the walk as the reference's default (0,0) entry
does. Checked by running both implementations side by side (abort on first
difference): 450,119 annotated PSMs of the six 0.5 Da benchmark files
(velos_125_R1, velos_5000_R2, velos_25000_R3, lumos_tmt_5058/5059/5066) and
600,000 random spectrum pairs (empty spectra, duplicate m/z, tolerance 0..10)
- no difference; check removed afterwards. Byte-identity gate passes on the
six core files at 4 threads and on hfx_B1, velos_125_R1, lumos_tmt_5058 at 1
and 16 threads; class tests pass.

Measured (kim, 4 threads, 8,000 spectra, annotate:PSM=ALL):
annotation loop of postProcessHits_ 2.62 s -> 0.27 s wall on velos_125_R1
and 2.31 s -> 0.21 s on lumos_tmt_5058 (alignment 7.4 -> 0.18 thread-s).
End to end, paired A/B, medians of 3: velos_125_R1 27.1 -> 24.6..25.2 s
(1.08-1.10x), lumos_tmt_5058 22.9..24.1 -> 20.8 s (1.10-1.16x); ppm files
unchanged (hfx_B1 1.00x, eclipse_tmtpro_10855 0.99x). Peak RSS unchanged.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 0810558fc40fdc585dcb634fd5c6cd0488357df4)
…s built

What: the file-based ProSEAlgorithm::search() read the spectra, then the FASTA
file, then built the index. For an unchunked, multi-threaded search of an mzML
file, one helper thread (std::async) now reads the spectra while the calling
thread reads the FASTA file and builds the index (prepareContext); the search
then continues with search(spectra, ctx, ...) exactly as the in-memory wrapper
does. Single-threaded runs (one OpenMP thread, or a call from inside a parallel
region), chunked databases and non-mzML input (.d, .raw) keep the old order.
The decoy strategy is no longer resolved a second time after the search when
no protein FDR is requested (it was computed and discarded).

Why the results are identical:
- The two sides share no data: the spectra are touched by the calling thread
  only after future::get(); loading and index build read the parameters only.
- OpenMS registries: only the mzML reader registers meta value names while the
  two run side by side (FASTA reading, decoy handling and FragmentIndex::build
  register none; checked with registry probes), so the registration order, and
  with it the user-param order in the idXML, is that of reading the spectra first.
  Logging goes through the thread-local log streams.
- ions:by_activation: whether the index needs c and z+1 ions is known only once
  the spectra are read. If the spectra are already read, or the first 8 MB of
  the file name an electron-based activation (ECD/ETD/ETciD/EThcD accession),
  the build waits for the spectra. Otherwise the index is built without these
  ions and rebuilt if such spectra turn up after all (same code as the
  multi-file search), so the index searched is always the one
  prepareContext(fasta_db, electron_ions) builds.
- The OpenMP threads of the calling thread are started before the helper, as
  before (the mzML decoding was the first parallel region); this only keeps
  the threads on one NUMA node and does not affect results.

Checked: class tests pass; byte-identical TSV and idXML on the six gate files
at 4 threads and on hfx_B1 / velos_125_R1 at 1 and 16 threads; identical on a
synthetic file with ETD spectra from the start (no rebuild) and one with ETD
spectra only late in the file (rebuild path).

Measured (kim, EPYC 9654, 4 threads, interleaved A/B vs 20b6e75):
  hfx_B1               18.72 -> 17.29 s (1.08x)   5 reps
  velos_125_R1         27.77 -> 25.88 s (1.07x)
  eclipse_tmtpro_10855 12.35 -> 11.74 s (1.05x)
  bound to one NUMA node: hfx 17.76 -> 17.08 (1.04x), eclipse 12.26 -> 11.65
  (1.05x), tims_plasma_30min 13.72 -> 13.45 (1.02x). Peak RSS within +3%.
The gain is the mzML read time (0.5-0.8 s for 8,000 spectra); it grows with
the size of the spectra file.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 9f750d9651023ceff135e7f656d5d0114f816386)
…on top of opt/digest)

What
- generatePeptides() still calls std::sort on the same peptide sequence, but
  compares one 64-bit key (bit pattern of precursor_mz_ << 32 | protein_idx)
  instead of the (float, UInt32) tuple. The tuple comparator is kept as the
  fallback when peptide_min_mass_ <= 0 or fi_peptides_ held older entries.

Why the results are identical
- Every peptide generated by this call passed peptide_min_mass_ <= mz, so
  with peptide_min_mass_ > 0 each precursor_mz_ is a positive, non-NaN
  IEEE-754 float, and such floats order exactly like their bit patterns.
  The key comparison therefore returns the same bool as the tuple
  comparison for every pair; std::sort (same algorithm, same input order)
  takes the same decisions and leaves equal-key peptides in the same order.
- Class tests pass; byte-identity gate passes on the six core files at 4
  threads and on hfx_B1 / velos_125_R1 at 1 and 16 threads.

Measured (kim, 4 threads)
- sort phase, in-process timer, interleaved tuple/key runs: hfx_B1
  1.16 s -> 0.76 s, velos_125_R1 1.06 s -> 0.69 s, eclipse_tmtpro_10855
  0.78 s -> 0.53 s.
- whole-run wall vs the parent commit (4 reps): hfx_B1 1.02x, velos_125_R1
  0.99x, eclipse 0.99x, i.e. the 0.25-0.40 s is below the run-to-run noise
  and below the 3 % keep threshold on its own. Kept on a separate branch
  for that reason.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 9f9ecc84836c7c2cd3366746f9c8ad6de07819f3)
…d::sort exactly

What
- generatePeptides() and generateSNESMothers_() sort the peptides through the new
  FragmentIndex::sortPeptides_(). With libstdc++ and OpenMP it runs a faithful
  copy of libstdc++'s introsort (bits/stl_algo.h: __introsort_loop with depth
  limit 2 * floor(log2 n), median of first+1 / mid / last-1 moved to first,
  __unguarded_partition, heap sort on depth exhaustion, insertion sort of the
  ranges of <= 16 elements) and hands the right part of every partitioning
  step to an OpenMP task if it has more than 8192 peptides. Other standard
  libraries, builds without OpenMP and inputs of <= 8192 peptides keep the
  plain std::sort call. No extra memory.

Why the results are identical
- The comparator covers only (precursor_mz_, protein_idx); about 7% of the
  peptides tie and their order defines the peptide indices, so the result has
  to be the very permutation std::sort produces. It is: the same comparisons
  and swaps are made per range, only the two parts of a partitioning - which
  are disjoint, and whose processing never reads outside the own range - are
  processed concurrently. The final insertion sort over the whole range moves
  no element across the boundary of a <= 16-element range (the ranges are in
  ascending order relative to each other), so it is done per range.
- New class-test section: element-by-element comparison with std::sort for
  sizes 0..40, 1e3, 2e4 and 1e6, ten input patterns (random with many ties,
  six keys, sorted, reverse, all equal, organ pipe, sawtooth, build()-like,
  and two McIlroy quicksort-killer inputs that force the heap-sort fallback),
  at 1, 2, 4 and 16 threads, with every right part as a task and with the
  default task size. A deliberately wrong pivot candidate makes it fail.
- One-off self-check in generatePeptides() (removed again): std::sort on a copy
  vs sortPeptides_ on the peptides of the three benchmark FASTAs (7.0, 9.0 and
  9.8 million peptides, 0.49-0.67 million ties) at 1, 2, 4, 16 and 64 threads:
  no difference.
- Byte-identity gate passes on the six core files at 4 threads and on hfx_B1 /
  velos_125_R1 at 1, 16 and 64 threads; class tests pass.

Measured (kim, load 30-180, paired with the integrated build)
- The sort itself on hfx_B1 (9.8 M peptides): 1.12 s -> 0.35 s at 4 threads,
  0.61 s at 2, 0.12 s at 16, 0.11 s at 64; 1.11 s at 1 thread (unchanged).
- End to end, medians of 5, two runs at 4 threads: hfx_B1 5.87 -> 5.29 s and
  6.72 -> 5.97 s (1.11-1.13x), eclipse_tmtpro_10855 4.60 -> 4.04 s and
  5.44 -> 4.53 s (1.14-1.20x), velos_125_R1 7.96 -> 7.79 s and 8.57 -> 8.11 s
  (1.02-1.06x). At 16 threads: hfx_B1 4.98 -> 3.83 s (1.30x), velos_125_R1
  6.76 -> 5.58 s (1.21x), eclipse_tmtpro_10855 4.08 -> 3.20 s (1.27x).
  Peak RSS unchanged.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 5b57b914a4823aee946d974306d6d7dadc2e10f1)
…them by registry index

Every string-keyed setMetaValue()/getMetaValue() goes through
MetaInfoRegistry::registerName()/getIndex(), which take a process-wide OpenMP
critical section even for names that are already registered. With ~17 meta
values per PSM (annotate:PSM=ALL) the annotation threads spent most of the
post-processing loop waiting on that lock.

The keys of the annotation loop are now registered once before the loop and
the index overloads are used inside it; the scan_index sort after the loop
looks its key up once instead of twice per comparison.

Identity: MetaInfo orders a hit's values by registry index, so the names are
registered in exactly the order the loop registered them (scan_index, IM if
the first spectrum with hits has a drift time, then the per-hit names in the
order they are set), only if at least one spectrum has hits. Values, types
and the per-hit set of meta values are unchanged. Registry contents after a
search are identical to the baseline at 1 and 16 threads (Orbitrap and
timsTOF file); idXML/TSV byte-identical on the gate files at 1/4/16/64 threads.

kim, dev2 -> this, median of 5 (wall s):
  16 threads: velos_125_R1 4.71 -> 4.33, eclipse_tmtpro_10855 2.62 -> 2.38,
              lumos_tmt_5058 4.55 -> 4.15, hfx_B1 3.17 -> 3.04 (7 reps)
  64 threads: velos_125_R1 4.84 -> 4.14, lumos_tmt_5058 4.49 -> 3.91,
              hfx_B1 2.94 -> 2.71
   4 threads: velos_125_R1 7.05 -> 6.70, others unchanged

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit f4784314275fef3092263d5ff640a059f971f0d5)
…aight into their m/z bins

What
- The fragments are generated twice instead of once into per-thread blocks that a
  merge then histogrammed and scattered: the first pass only counts them per m/z
  bin and portion of the peptides, the second writes each fragment to its final
  place in fi_fragments_ / electron_fragments_ (through a 1024-fragment buffer, so
  that the scattered writes run in a loop of their own). No intermediate copy of
  the fragments, half the page faults, no emplace_back, no block bookkeeping;
  mergeFragmentsIntoMzBins is gone. The bin range comes from fragment:min_mz /
  max_mz (not below 1 Th, at most MAX_MZ_BINS bins).
- A portion writes behind the earlier portions in every bin, so the bins arrive
  in ascending peptide order and sortAndBucketBinnedFragments skips its radix sort
  by peptide index.
- The protein sequences of the peptides 8 / 16 ahead are prefetched: the peptides
  are sorted by mass, so every peptide used to start with cache misses on its
  protein (this alone halves the time of a generation pass).
- generateFragmentsForSeries_ advances the prefix and the suffix sum in one loop
  and takes the residue mass table as a parameter; peptides without variable
  modification use a table with the fixed modification deltas added instead of
  building a delta array per peptide. The delta array of the others is a
  per-thread buffer (was: one allocation per peptide).

Why the results are identical
- Every fragment m/z is computed by the same additions in the same order as
  before: prefix and suffix are independent sums; the charge is 1, so the dropped
  "* z" and "/ z" changed no value; table[aa] + delta is the sum the generator
  formed from the delta array, and a residue without fixed modification got
  + 0.0 there, which leaves its mass unchanged.
- Both passes run the same code on the same portions, so counts and writes agree.
- The index is fixed by the set of fragments alone (sortAndBucketFragments_):
  neither the order inside a bin nor the choice of bins matters; fragments outside
  the expected bins (or limits that allow none) end in the general sort path.
Checked: fi_fragments_, bucket_min_mz_, bucket_skip_ and the electron arrays have
the same checksums as before (temporary print in both builds) on hfx_B1 at 1, 4,
16 and 64 threads, velos_125_R1, lumos_tmt_5058, tims_plasma_30min, and with all
seven ion series, electron ions (ETD spectra), fragment:min_mz 0 / max_mz 100000 /
min_ion_index 0, min_mz -5, min_mz > max_mz, no modifications, variable only,
fixed and variable modification on the same residue, and SNES mothers; the search
output was identical in all of them. Byte-identity gate passes on all 20 files at
4 threads and on hfx_B1 / velos_125_R1 at 1, 16 and 64 threads; class tests pass.

Measured (kim, 4 threads, load 40-90)
- hfx_B1, fragments of build(): generate 1.05 + merge 0.45 + bucket 0.43 = 1.93 s
  -> count 0.24 + fill 0.62 + bucket 0.23 = 1.10 s (1 thread 6.4 -> 4.0 s,
  16 threads 0.58 -> 0.31 s, 64 threads 0.54 -> 0.15 s).
- End to end, interleaved A/B, medians of 7: hfx_B1 6.03 -> 5.05 s (1.19x),
  velos_125_R1 8.05 -> 7.36 s (1.09x), eclipse_tmtpro_10855 4.83 -> 4.15 s
  (1.16x); 16 threads, medians of 5: hfx_B1 4.17 -> 3.87 s, velos_125_R1
  6.08 -> 5.30 s. Peak RSS unchanged at 4 threads (2.12 -> 2.11 GiB), lower at
  16 threads (2.32 -> 2.14 GiB).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 66cb6adcabf1ece33a27f28a1f5f9495176cad21)
…ad, database copy)

What ran on one thread before and after the search, at 16 threads on hfx_B1 (kim):

- FragmentIndex::clear(): the pages of the fragment and peptide vectors (~2 GB) are
  given back with madvise(MADV_DONTNEED) by the OpenMP threads before the vectors
  are deallocated (Linux + OpenMP; elsewhere as before). 0.28 s -> 0.10 s. The
  buffers are discarded, nothing reads them afterwards.
- FASTA file: read in pieces by the OpenMP threads with FASTAFile::readNext() and
  joined in file order; pieces start at entry starts that the serial reader passes
  as well, anything unexpected falls back to FASTAFile::load(). 0.13 s -> 0.04 s.
  Same entries and same errors on 20 edge-case files and the benchmark databases
  at 2, 4, 16 and 64 threads.
- search(file, fasta): the context takes the FASTA entries over instead of copying
  them (0.03 s, and one database less to destroy); protein FDR takes the decoy
  marker from the context, which holds what resolveDecoyStrategy_() returned.
- mzMLHeadNamesElectronActivation(): one pass over the head of the file instead of
  four. 0.02 s -> 0.01 s.

Results are byte-identical (TSV and idXML): six core files at 4 threads, hfx_B1 and
velos_125_R1 at 1, 16 and 64 threads; also with PSM/protein FDR, decoys=generate,
decoys=ignore, a target-only database and chunked search. Wall time at 16 threads:
hfx_B1 3.05 -> 2.83 s, velos_125_R1 4.67 -> 4.23 s, eclipse_tmtpro_10855
2.53 -> 2.33 s; at 4 threads 4.79 -> 4.59, 6.78 -> 6.57, 3.70 -> 3.50 s. Peak RSS
unchanged or slightly lower.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 2c0b2f85bed0aefee35073e69ab30aa9adc6bda2)
…small peak one isotope spacing below; HyperScore Da-mode error on arm64 (OpenMS#10391)

* [FIX] ProSE: deisotoping keeps fragment ions that have a small peak one isotope spacing below

ProSE deisotoped high-resolution MS2 spectra with Deisotoper's default start_intensity_check=2,
which lets the second peak of an envelope exceed the first. A small peak 1.00335 Da below a
fragment ion then became the envelope's monoisotopic peak and the ion itself was removed as its
isotope. Every TMT/TMTpro-labelled fragment has such a peak (reagent isotope impurity); on the
TMTpro files of the OpenMS#10364 benchmark this removed 18-21% of the fragment peaks that match
the identified peptide, and 5-6% on Orbitrap Astral and timsTOF spectra.

ProSE now requires isotope intensities to fall from the monoisotopic peak on
(start_intensity_check=1). A class test covers the TMTpro case and that regular 1+ and 2+
envelopes are still deisotoped. The TOPP references ProSE_1/2/4 change in scores and PSM
features only (identical hits); ProSE_4's calibrated fragment tolerance tightens.

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

* [FIX] HyperScore: Da-mode fragment error uses std::abs (was truncated to 0 on aarch64)

computeWithDetail summed Da-mode fragment errors with an unqualified abs() inside
namespace OpenMS, with <cmath> included inside that namespace. Whether a global
abs(double) was visible depended on transitive includes: on x86 it came from the SSE
intrinsic headers that libstdc++'s <random> or Boost.Math pull in, on aarch64 nothing
exported it and the call bound to C's int abs(int). Every error below 1 Da became 0, so
PSMDetail::mean_error was 0 and ProSE's Da-mode fragment calibration silently kept the
configured tolerance on Linux arm64.

This is what failed TOPP_ProSE_4_out on ubuntu-24.04-arm in this PR: the deisotoping fix
adds two matched ions between the calibrated and the configured tolerance, so the ARM build
(uncalibrated, score 20.342) and the x86/macOS builds (calibrated, 16.842) now differ.
x86 and macOS results are unchanged. A HyperScore_test section checks the Da-mode mean
error; built against develop's headers for baseline x86, where the same overload is chosen,
it fails without this change (mean_error 0 instead of 0.004).

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

* [DOC] CHANGELOG: HyperScore Da-mode fragment error on arm64

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

Ported onto opt/dev6 (speed patches); conflicts resolved in: none (applied without conflicts).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…penMS#10394)

A peptide that occurs in several proteins was indexed once per occurrence.
Its copies took several of the per-spectrum candidate slots
(scoring:max_candidates_per_spectrum), and the runner-up was often the same
peptide, so delta_score was 0 and the candidate-pool features counted copies.

FragmentIndex gains peptide:deduplicate (default false): after peptide
generation, exact modified peptides are collapsed to one representative
coordinate, compared on the full peptidoform string (hashes only group
candidates). SNES mother indices are unchanged. ProSE enables it by default;
its PeptideIndexing step already recovers every protein mapping and the
target/decoy label. Chunked searches additionally skip a peptide/charge/isotope
hypothesis already scored in an earlier chunk.

Split out of OpenMS#10335 (0af4cf6); its index-rebuild part is in develop as OpenMS#10350.
The four ProSE idXML references gain the peptide:deduplicate search-parameter
line; replaying the TOPP tests changes nothing else in them.

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

Co-authored-by: Claude Opus 5.5 <[email protected]>

Ported onto opt/dev6 (speed patches); conflicts resolved in src/tests/class_tests/openms/source/FragmentIndex_test.cpp
(both new sections kept), src/openms/source/ANALYSIS/ID/FragmentIndex.cpp and
src/openms/include/OpenMS/ANALYSIS/ID/FragmentIndex.h (deduplication moved into the speed-patched index build).

FragmentIndex.cpp merged without a text conflict, but OpenMS#10394 builds an AASequence and its string for every
database peptide: 9-10 million per search on the OpenMS#10364 files, 3.7-4.1 s at 4 threads (2.6-2.7 s at 16)
in this build, whose whole search takes 3.3-5.5 s. The port keeps the definition - of all entries with the same
reconstructModifiedSequence(...).toString() the first one survives, the survivors keep their order - and
evaluates it in build()'s first (counting) fragment pass:
- The entries of a peptidoform have equal residues and bitwise equal precursor m/z (generatePeptides() adds
  the same masses in the same order), so after sortPeptides_() they lie in one run of equal precursor m/z.
  Within a run, an entry is compared with the kept ones through a 32-bit key (length, residues 2-9, active
  slots where these name the peptidoform), then by samePeptidoform_(): residues, protein-terminal context and
  slots, or the rendering class (ResidueModification::toString()) of the modification at every position.
- The first pass's portions start at runs; each compacts its kept entries in place (fresh memory would cost
  more in page faults than the comparisons), the portions are closed up in waves that never overwrite
  unmoved entries, and the second pass writes the fragments of the kept entries only.
- Configurations in which equal renderings need not share residues and precursor m/z (a modification both
  fixed and variable, or alike rendered ones of different mass or residue) use the string comparison of
  OpenMS#10394 (deduplicateByString_()).
With all four ported commits and the prototype filter off, the output equals develop's on all 20 files of
OpenMS#10364 (native TSV; idXML apart from the prototype's two search-parameter lines), and the string
comparison gives the same index as the in-pass one. Index build +40-55 ms at 4 threads (first pass and
close-up), offset by 5% fewer peptides and fragments: whole searches 1.00-1.01x of the commit before, at
4 and 16 threads. A FragmentIndex_test section checks the result against the string
definition for seven modification sets (including the fallback), Met clipping, semi-specific digestion and
1-2 variable modifications.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… not deisotoped (OpenMS#10397)

ProSE scored every candidate against singly charged fragments only. Spectra
that are not deisotoped (ion-trap CID at 0.5 Da, or fragment:deisotope=false)
keep multiply charged fragments at their own m/z, so those peaks could not
match, although candidate retrieval already considers fragment charges up to
fragment:max_charge.

New scoring:fragment_charges (auto, single, multiple). 'auto', the default,
scores charges up to min(precursor charge - 1, fragment:max_charge) when the
spectra are not deisotoped and charge 1 when they are, the same decision
preprocessing makes. High-resolution searches therefore do not change. The
precursor-calibration pass and the peak annotations use the same charges, and
the ion-count fractions divide by the number of charges scored. The resolved
choice is recorded as scoring:fragment_charges_resolved.

Split out of OpenMS#10335, which scores multiple charges together with its
calibrated binomial score; on the 20-file suite of OpenMS#10364 the multiple charges
carry the low-resolution gain with plain HyperScore, and the calibrated score
alone loses. The four ProSE idXML references gain the two search-parameter
lines; replaying the TOPP tests changes nothing else (all are high resolution).

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

Co-authored-by: Claude Opus 5.5 <[email protected]>

Ported onto opt/dev6 (speed patches); conflicts resolved in: none (applied without conflicts; the annotation
charge limit feeds the flat-storage Da alignment of 594cab4 unchanged).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…charge is unknown (OpenMS#10398)

With multiple-charge scoring (scoring:fragment_charges=multiple, or auto on
spectra that are not deisotoped), a spectrum without a precursor charge is
scored under each candidate's charge hypothesis, but its peak annotations took
the fragment-charge limit from the missing charge (0) and annotated only singly
charged fragments. Use the charge the hit reports and that was scored.

Follow-up to OpenMS#10397 (CodeRabbit review).

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

Co-authored-by: Claude <[email protected]>

Ported onto opt/dev6 (speed patches); conflicts resolved in: none (applied without conflicts).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nse_intensity_loss 1.0)

The prototype quota of 20b6e75 adds Astral identifications that do not hold in a doubled-search-space entrapment
control: on opt/q0 it adds 643 target PSMs and 13 entrapment hits over the 20 benchmark files (about 4% false among
the added PSMs, nominal 1%); Astral combined FDP 1.06% (off) vs 1.33% (on). With the default 1.0 the output equals
OpenMS develop (opt/q0 with the quota off: 20/20 files byte-identical). The option stays available.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rt:isotope_error_convention)

ProSE wrote the precursor isotope error with the sign of its search offset, the mass FragmentIndex adds to the
observed precursor (theoretical minus observed). MS-GF+, pepXML, Sage and the isotope correction of
PercolatorInfile/PercolatorAdapter use observed minus theoretical (Constants::UserParam::ISOTOPE_ERROR: "the
correction being -x times C13C12_MASSDIFF_U"), so ProSE -out_pin, -percolator_executable and PercolatorAdapter
doubled the offset in dm/absdm instead of removing it, for every PSM with a nonzero isotope error.

- New advanced parameter report:isotope_error_convention, default observed_minus_theoretical;
  theoretical_minus_observed writes the previous sign. With the default the search parameters record
  isotope_error_convention=observed_minus_theoretical, so readers can tell the sign (no record = earlier ProSE).
- precursor:isotope_error_min/max keep their meaning (the search offset); their descriptions now give the sign.
  precursor_mz_error_ppm is unchanged.

Measured on the 20 files of OpenMS#10364 (kim, harness build, vs opt/q1):
- theoretical_minus_observed: native TSV and date-blanked idXML byte-identical, 20/20 at 4 threads and 9/9 at
  1/16/64 threads (velos_125_R1, hfx_B1, lumos_tmt_5058).
- default: TSV identical 20/20; idXML identical after negating isotope_error and dropping the record, 20/20.
- Harness protocol (export.py reads the record): its input.pin differs from opt/q1's only by the negated
  isotope_error column; Percolator 3.09 (-Y -U, seeds 1/42/137) on those PINs gives byte-identical target and
  decoy results for all 20 files and all 3 seeds, so qeval is unchanged; the same holds for the 20 doubled-search-
  space PINs of eeval (e-q0-nodense, 60/60 seeds).
- TOPP path (PercolatorInfile PIN with the benchmark features): accepted PSMs +0.81% mean (12 files up, 8 down;
  Velos +0.6%, HF-X +1.4%, Astral +1.2%, CID TMT +2.2%), median dm per (isotope error, charge) cell from 2.0 to
  below 0.01 Th.

Class tests: a new ProSEAlgorithm_test section; the OpenMS#10394 deduplication section now expects the reported isotope
errors {0, -1} for the searched offsets 0..+1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…m/z; the isotope error corrects dm/absdm only

stampPinFeaturesOnHits() (used by PercolatorInfile::store and the in-process PercolatorAdapter path) subtracted the
isotope error from ExpMass and mass as well. Percolator identifies a spectrum by ScanNr and ExpMass, so the PSMs of
one spectrum at different isotope errors became different spectra and several of them could pass target-decoy
competition. Now ExpMass and mass are the spectrum's precursor m/z for all its PSMs (as the in-process Percolator
already uses for exp_masses), and dm, absdm and deltamass carry the isotope-corrected difference.

Measured on the TOPP-path PINs of the 20 files (ProSE default build of this branch, PercolatorInfile compiled from
source, Percolator 3.09 -Y -U, seeds 1/42/137), vs opt/q1's PercolatorInfile on opt/q1's idXML:
- scans with more than one ExpMass: 2328-7790 per file -> 0 in every file; accepted PSMs now equal accepted
  spectra (opt/q1: 3134.0 PSMs on 2977.8 spectra per file, Lumos LFQ 5949.8 PSMs on 5417.9 spectra).
- accepted spectra per file +3.55% (19 files up, 1 down; Velos +5.9%, HF-X +4.1%, Astral +4.2%, Lumos LFQ +1.5%,
  CID TMT +6.4%, TMTpro +2.0%, timsTOF +1.3%); reported PSMs -1.61% because the duplicate acceptances are gone.
  The result is within 1% of the harness's own PIN (3083.5 vs 3110.0 per file).

Class test: two PSMs of one spectrum, at isotope errors +1 and 0.

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

FragmentIndex keeps one N- and one C-terminal fixed mass for the whole index and applies it to every peptide
(precursor mass, fragments, reconstructed sequence). A protein-terminal fixed modification (e.g. Acetyl (Protein
N-term)) or a residue-specific terminal one (e.g. Gln->pyro-Glu (N-term Q)) therefore modified every peptide,
silently (review: on hfx_B1 a fixed Acetyl (Protein N-term) left 61 of 1764 rank-1 targets above score 15), and of
several fixed modifications on one terminus only the last was kept.

New FragmentIndex::checkFixedModifications(), called by FragmentIndex and by ProSEAlgorithm when the parameters are
set (before any input is read): it throws InvalidParameter for protein-terminal and residue-specific terminal fixed
modifications, which are searched correctly as variable modifications, and for a second fixed modification on the
same terminus. Peptide-terminal fixed modifications of any residue (TMT/TMTpro, Dimethyl, Acetyl (N-term),
Amidated (C-term)) are unchanged.

Measured: the 20 files of OpenMS#10364 (fixed CAM, TMT/TMTpro on K and the peptide N-terminus) byte-identical to
opt/q1. Class tests for each rejected case and for the accepted ones.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… within variable_max_per_peptide; at most 31 sites

generatePeptides() visited all 2^n subsets of a peptide's n variable-modification slots and filtered them by
popcount: 25 or more slots took minutes to hours per peptide, and at 32 slots `1u << n_slots` is undefined (UBSan;
on x86-64 and arm64 only the unmodified form was indexed). The loop now steps from a subset to the next one with at
most variable_max_per_peptide slots (adding the lowest set bit skips every larger subset that keeps all bits), in
the same increasing order, so the index and its peptide order are unchanged. Slot 31 is not used (bit 31 is the
SNES mother flag and reconstruction masks it), so peptides with more than 31 sites use their first 31, with one
warning per build.

Measured: the 20 files of OpenMS#10364 (at most 12 Ox(M) sites per peptide) byte-identical to opt/q1. Class test:
peptides with 3, 25, 31, 32 and 35 sites at variable_max_per_peptide 0, 1 and 2 index exactly sum_{j<=k} C(min(n,31), j)
forms with matching reconstruction and precursor mass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fault isotope range is [-2, 0]

precursor:isotopes was read by ProSE and declared by FragmentIndex but never used: precursor:isotope_error_min/max
alone select the isotope errors searched. Both declarations are removed; an ini or parameter file that sets it gets
the unknown-parameter warning.

FragmentIndex's own default [0, +2] contradicted its comment: the query matches observed mass + isotope_error *
C13C12, so [0, +2] covers precursors picked below the monoisotopic peak, not the first and second 13C peaks the
comment meant. The default is now [-2, 0]. ProSE always passes its own range (default -1..+1), so only direct
FragmentIndex users see this.

Measured: the 20 files of OpenMS#10364 byte-identical to opt/q1 (the harness skips the frozen precursor:isotopes
setting with its unknown-parameter message). Class test: the default range finds precursors picked at the first and
second 13C peak and not one below the monoisotopic peak.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
preprocessSpectra_() shared one ThresholdMower and one WindowMower between the OpenMP threads. Both write members on
every call (ThresholdMower its threshold, WindowMower's jumping window its window size and peak count): a data race
even though every thread writes the same value. The filters (with Normalizer and NLargest) are now firstprivate.

Measured: ThreadSanitizer on the loop body with the four filters compiled from source and -fsanitize=thread
(4 threads, 400 spectra; harness tsan_filters): shared objects 3 reports (ThresholdMower::filterSpectrum,
WindowMower::filterPeakSpectrumForTopNInJumpingWindow), per-thread copies 0, same peaks kept. The 20 files of
OpenMS#10364 byte-identical to opt/q1 at 4 threads, and 9/9 at 1/16/64 threads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nine of the targets

With peptide:clip_nterm_methionine and decoys=auto reusing the database's decoys, the clipped N-terminal peptides of
M-initial targets have no decoy counterpart when the decoys are reversed proteins (which end with the Met). ProSE's
generated decoys keep the initial Met; supplied ones are now checked while the database is filtered, and a warning
names the counts and the two symmetric alternatives (decoys=generate, or no clipping).

On the OpenMS#10364 databases 27379 of 27488 hy targets start with M but 599 decoys, so clipping adds 1.6% target and
0.04% decoy peptides, an FDR underestimate of about 1.5% relative (review CQ-20/QC-07). Output is unchanged: the 20
files are byte-identical to opt/q1. Class test for the warning with reversed, Met-kept and unclipped databases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…envelopes, summed intensity, charges up to the precursor charge)

Three new advanced parameters set the envelope rule of the MS2 deisotoper; their defaults follow Sage:

- fragment:deisotope_min_peaks = 2 (was 3): an ion whose M+2 peak is lost in the noise kept its M+1 peak,
  which took a place in the 20-per-100-Da window quota, and a multiply charged fragment seen with two
  isotope peaks was neither converted to charge 1 nor scored (deisotoped spectra are scored at charge 1).
- fragment:deisotope_sum_intensity = true (was false): the monoisotopic peak carries the envelope's
  summed intensity.
- fragment:deisotope_charge_cap = precursor (was charges 1-3 for every spectrum): charges are tried up to
  the precursor charge (at most 3; 1-3 when it is unknown). With two-peak envelopes, a chance peak
  1/3 Th above an ion of a 2+ precursor would otherwise make a "3+" envelope and move the ion to a
  wrong m/z.

Only deisotoped (high-resolution) searches change. min_peaks 3, sum_intensity false and charge_cap none
reproduce the previous output byte for byte (native TSV and idXML of all 20 files of OpenMS#10364).

Measured on the 20 files of OpenMS#10364 against the base (develop + the ProSE speed patches, dense-spectrum
quota off), issue protocol (Percolator 3.09 -Y -U, seeds 1/42/137, target PSMs at q <= 0.01):
- mean +1.37% per file (3110.0 -> 3152.7; 13 files up, 1 down, 6 at 0.5 Da unchanged); HF-X +2.1%,
  Orbitrap Astral +6.0%, Exploris TMTpro +1.6%, Lumos LFQ +0.5%, timsTOF -1.5% (three seeds; with 13
  Percolator seeds on the same PINs timsTOF +0.2%, HF-X +2.2%, Astral +7.5%).
- doubled search space (shuffled entrapment proteins, combined FDP): all files 1.08 -> 1.11% with 917
  more targets; two further entrapment shuffles 1.00 -> 0.99% and 0.94 -> 0.97%.
- native score TDC per precursor charge up in every group and charge (HF-X +2.5% 2+, +6.8% 3+).
- Arms that were measured and not adopted: no charge cap (mean +1.45%, but more chance "3+" envelopes),
  three peaks for charges 2-3 (HF-X +0.9% only), summing without two-peak envelopes (-0.1%), two-peak
  envelopes without summing (Astral +2.2% instead of +6.0%).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n fragments (scoring:method)

Port of the fixed-kernel scorer of 825c33b (OpenMS#10379, first commit) onto the speed-patched ProSE.
A matched fragment with mass error e (ppm) adds exp(-0.5 * (e / scoring:mass_error_sd)^2) to its
terminal ion count and its term of the intensity product; fractional factorial rewards use
max(0, lgamma(count + 1)), so exact matches score as HyperScore. Matching tolerances, candidates
and the unweighted match annotations do not change. Main search (single-file, chunked, chunk-major
multi-file) and the calibration pass use it.

New parameters scoring:method (auto, hyperscore, mass_accuracy) and scoring:mass_error_sd (7 ppm,
the ANDES constant, not fitted). Differences from 825c33b:
- 'auto' (the default) uses the weighted score for fragment tolerances in ppm up to 100 ppm and
  HyperScore otherwise: the ppm kernel would discount almost every match of a 0.5 Da search, so
  low-resolution searches stay unchanged; 'mass_accuracy' forces it and warns outside that range;
- the search parameters record scoring:method, scoring:method_resolved and scoring:mass_error_sd
  only when the weighted score is used, so HyperScore searches keep their idXML unchanged;
- the score type stays 'ln(hyperscore)' (825c33b: 'mass-accuracy hyperscore'): the weighted score is a
  log-space HyperScore, as Sage's own variant is, and downstream tools find ProSE scores by that name
  (IDPosteriorErrorProbability's PROSE model accepts only 'hyperscore' / 'ln(hyperscore)', and
  Scores lists it as a raw score), so a default-on score must keep it;
- not ported: calibration:enabled=auto and the fitted kernel of 16ff034 (HF-X -3.3%, Lumos LFQ
  -4.2% for calibration auto; the fitted kernel was neutral), and the pyOpenMS binding.

Measured on OpenMS#10364 (20 files, Percolator 3.09 -Y -U, seeds 1/42/137) against opt/q1
(q0-nodense; only the 14 ppm files change, the six 0.5 Da files are byte-identical):
- mean 3110.0 -> 3131.5 PSMs/file (+0.69%); Astral +5.54% (2322.4 -> 2451.1, all 3 files up),
  HF-X +0.08%, Lumos LFQ +0.13%, TMTpro +0.11%, timsTOF +0.18%; Velos UPS1 FDP 1.02% (unchanged);
- with the prototype dense-spectrum quota on (dense_intensity_loss 0.2, against q0): Astral +6.79%,
  14 ppm files +1.19%, no group below -0.7%;
- doubled search space (combined entrapment FDP, all 20 files) in three entrapment shuffles:
  1.08 -> 1.04%, 1.00 -> 0.96%, 0.94 -> 0.94%; Astral 1.06 -> 1.21, 0.92 -> 0.91, 0.95 -> 0.91%
  with +6.9 / +10.4 / +7.1% targets;
- native-score TDC (no Percolator, ppm files): 2970.6 -> 3081.4 PSMs/file (+3.7%), Astral +21.5%.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…es (FDR:PSM_groups)

scoring:fragment_charges (OpenMS#10397) scores fragment charges 1..min(z - 1, fragment:max_charge) of
spectra that are not deisotoped (ion-trap CID at 0.5 Da). HyperScore grows with the number of
theoretical ions, so the scores of precursors of charge 3 and above rise for targets and decoys
alike, and one pooled target-decoy competition lets their decoys set the threshold for charge 2.
On the six 0.5 Da files of OpenMS#10364 ProSE's own FDR:PSM output (no Percolator) fell by 22% (Velos)
and 38% (Lumos CID TMT) against opt/dev6.

New FDR:PSM_groups (scored_charges, pooled): 'scored_charges', the default, computes the q-values
separately for the spectra whose best hit was scored with different numbers of fragment charges
(at fragment:max_charge 2: precursor charge 2, and 3 or more). High-resolution searches score charge-1
fragments only and form one group, so their q-values do not change; a group without target or decoy
PSMs falls back to one competition. The competition itself stays OpenMS FalseDiscoveryRate, now in
ProSEAlgorithm::annotatePsmQValues(), which the three FDR:PSM sites of ProSEAlgorithm and the TOPP
tool's fallback (Percolator failed) share.

Measured on the six 0.5 Da files, opt/q1 search output (the frozen harness runs FDR:PSM 0, so its
outputs and the Percolator yields are unchanged):
- ProSE FDR:PSM 0.01 output, target PSMs/file: Velos 1468.3 (pooled) -> 2397.7 (grouped), Lumos CID
  TMT 1186.0 -> 2181.7; opt/dev6 (pooled) 1875.0 / 1913.0. The counts equal a separate TDC
  recomputation from the native TSV (FalseDiscoveryRate's D/T, ProSE's hit order) on every file.
- With (D + 1)/T and ties counted for the decoy: Velos 1455.3 -> 2347.7, CID TMT 1180.3 -> 2119.0
  (opt/dev6 pooled 1862.3 / 1861.3).
- Doubled search space, native acceptance: combined entrapment FDP Velos 1.75% (pooled) -> 0.85%
  (grouped), CID TMT 1.34% -> 1.37%, with 2075 / 1899 instead of 1232 / 1025 targets per file.
- Splitting every precursor charge also at high resolution was not taken: on the 14 ppm files it
  loses native PSMs (timsTOF -5%, Astral -3%) because the score is comparable across charges there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…colator features (annotate:self_trained_ion_priors)

Adds FragmentIonLikelihoodModel, a per-run likelihood model of fragment ion
presence, intensity rank and mass error, and trains it per file from the
run's own confident PSMs (the self-trained ion priors of OpenMS#10378, extended
with the model-free contexts of the ANDES rich-ion likelihood):

- Contexts: ion series, precursor charge, fragment charge, relative
  position (annotate:ion_prior_model basic = OpenMS#10378), plus the residues at
  the cleavage site (bond before P, bond after D/E) and whether the
  complementary singly charged ion matched (rich, default). Outcome: absent,
  or intensity rank bin (rich: x |mass error| / tolerance bin).
- Inputs: ranks among all peaks after deisotoping, before the window and
  top-N filters (annotate:ion_prior_peaks all), theoretical fragment charges
  up to min(2, z - 1) (annotate:ion_prior_max_fragment_charge).
- Cross-fitting (always): the spectra are split into two halves by scan
  parity; each half selects its training PSMs by target-decoy competition
  within the half (rank-1 targets at q <= annotate:ion_prior_train_fdr),
  learns signal from them and noise from their reversed sequences on the
  same spectra, and scores the hits of the other half. Neither a PSM's own
  spectrum nor any label of its half enters its features. Both halves need
  annotate:ion_prior_min_psms PSMs (and decoys), otherwise the features are
  0 with a warning.
- Compact evidence: PeakLists keeps per spectrum only float m/z and the
  rank bin (5 bytes per peak) from preprocessing until the annotation,
  instead of whole spectrum copies. Captured in preprocessSpectra_ and used
  after PeptideIndexing and before FDR in all three search paths (single
  file, chunked, chunk-major multi-file).
- Features written (annotate:ion_prior_features): ion_prior_llr and
  ion_prior_explained by default (ion_prior_topk_observed optional), added to
  extra_features. Native scores, candidates and every existing PIN column
  are unchanged.

With annotate:self_trained_ion_priors=false the output is byte-identical to
the previous build (native TSV and idXML, 20/20 files of OpenMS#10364).
Features are identical at 1/4/16 threads and between the single-file,
multi-file and chunk-major entry points.

Measured on the 20 files of OpenMS#10364 (Percolator 3.09 -Y -U, seeds
1/42/137, target PSMs at q <= 0.01) against the same build with the option
off (dense-spectrum quota off): +3.26% mean PSMs per file (18/20 files up;
Orbitrap Astral +15.7%, Velos CID +3.8%, Lumos CID TMT +3.1%, TMTpro
+2.2%, HF-X +1.8%, Lumos LFQ 0.0%, timsTOF -1.3%), Velos UPS1 entrapment
FDP 1.02% -> 0.89%. Doubled search space (shuffled-peptide entrapment,
three shuffles): targets +3.8/+4.0/+4.2%, combined FDP 1.06/1.02/0.92% vs
1.08/1.00/0.94%. Training 8-32 ms and annotation 50-170 ms per 8,000
spectra at 4 threads; peak lists 6-37 MiB per 8,000 spectra.

Includes class tests for the model and the ProSE integration (including a
test that the features of one half do not depend on its labels), the ProSE
tool documentation and a CHANGELOG entry. The four ProSE TOPP idXML
references need regeneration (new search parameters and per-hit values).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ved by peptide:deduplicate

SpectrumMatchesTopN gains scored_candidates_ and matched_peaks_: every candidate (peptide x isotope error x
precursor charge) of the queried precursor windows with at least one matched fragment, and the matched
(peak, fragment) pairs summed over them, before fragment:min_matched_ions and the candidate cap. queryPeaks()
takes them from its touched cells in O(touched) (the fields the header comment of SpectrumMatchesTopN still
described). They are the mean match count of Sage's Poisson feature; SNES queries leave them 0.

getRemovedOccurrences(): for every entry that peptide:deduplicate removed, the kept entry of the same
peptidoform and the removed (protein, start), ordered by kept entry and then in sortPeptides_() order. The
run-based deduplication records them in its first pass (with the position of the kept entry in its run), the
string fallback (deduplicateByString_()) while it compacts. A caller can map the indexed peptides to proteins
from them without searching the database again (plan WP9); clear() releases them.

Measured (OpenMS#10364 harness, frozen parameters; with the ProSE features of the next commit switched off):
native TSV and date-blanked idXML identical to opt/q1 on all 20 files at 4 threads and on velos_125_R1,
hfx_B1 and astral_B1 at 1 and 16 threads. Timing on ibminode06 (interleaved, 2 x ABBA): 20 files at 4 threads
91.93 -> 91.98 s (1.001x), 4 files at 1 thread 54.21 -> 54.14 s; max RSS +5-10 MB (the occurrence list,
~0.36-0.49 M entries of 12 bytes). FragmentIndex_test: the removed occurrences equal those of the string
definition for 7 modification sets x Met clipping x 1-2 variable modifications x full/semi digestion; the
prefilter totals equal the emitted candidates with a gate of 1 and no cap, and stay unchanged under a gate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… prefilter Poisson, precursor ppm, ANDES rank/error)

New PSM features for Percolator, each behind its own parameter in the annotate section. They are computed
alike for target and decoy candidates from scores, match counts and m/z values only; none changes the
candidates, their native scores or their order (native TSV identical to opt/q1 on all 20 files with every
feature on).
- annotate:per_psm_pool_features: delta_score = score minus the next lower-ranked candidate (Sage's delta_next;
  one more candidate than report:top_hits is kept for the last reported hit), hyperscore_zscore = standard score
  of the PSM's own score in its spectrum's pool. The top hit's values are those of the spectrum-level form, so
  report:top_hits=1 is unaffected.
- annotate:prefilter_poisson: prefilter_poisson_surprise = ln(1 + max(0, -log10 Poisson(k; lambda))), k = the
  candidate's prefilter matches, lambda = FragmentIndex's prefilter totals (matched pairs / candidates with a
  match); upper tail only (0 for k <= lambda).
- annotate:precursor_ppm (centered|raw|false): ln_precursor_mz_error_ppm = ln(1 + |e - offset|), e the
  isotope-corrected precursor error in ppm, offset = median e of the top-scoring 10% of the top hits (recorded
  as search parameter precursor_mz_error_ppm_offset) or 0; not in open search.
- annotate:matched_intensity_rank: matched_intensity_rank_mean (ANDES MeanMatchedIntensityRank, singly charged
  ions, rank in the preprocessed spectrum).
- annotate:top_ion_mass_errors: top7_{abs_,}fragment_error_ppm_{mean,sd} (ANDES Mean/StdevErrorTop7,
  Mean/StdevRelErrorTop7 of the 7 most intense singly charged matches).
- annotate:delta_best (arm, off): score of the top hit minus the PSM's score.
With all of them off, output is byte-identical to opt/q1 (native TSV and date-blanked idXML, 20/20 files at 4
threads, 6/6 at 1 and 16 threads); with them on it is identical at 1/4/16/64 threads. This commit switches them
all on (except delta_best) as the measured candidate set; the next commit sets the defaults by the keep rule.

Measured with this commit (issue protocol, Percolator 3.09 -Y -U, seeds 1/42/137; vs opt/q1 = 3110.0 PSMs/file,
doubled-DB FDP 1.08%, Velos UPS1 FDP 1.02%): candidate set (all but delta_best, PIN-level) 3209.8 PSMs/file
(+3.21%, 20/20 files up; Velos +6.4%, Astral +13.1%, CID TMT +2.9%, timsTOF +2.9%, TMTpro +1.4%, HF-X +1.1%,
LFQ +0.1%), doubled-DB FDP 1.11%, Velos UPS1 FDP 1.12%; with delta_best 3217.1 (+3.44%), 1.13%, 1.10%. Cost at 4
threads (ibminode06, 20 files): wall +4.0% (most of it the serial idXML writing of 8 more values per PSM), CPU
+1.5-2%. Class tests cover each feature's definition, the off switches and top_hits=1 equality.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the default since c8e6db0

c8e6db0 switched the dense-spectrum peak quota off by default but kept the references written with the quota on, so
TOPP_ProSE_1_out, _2_out, _3_multi_idXML_out, _5_chunked_out and _10_out failed on the recorded search parameter
(TOPP_ProSE_4_out passed only through its -absdiff 2.0). The quota does not change the PSMs of these small inputs: the
one line is the whole difference.

Checked on kim with the TOPP tool built from opt/q1 (src/topp/ProSE.cpp, TOPPBase from src/openms_cli, the rest of
OpenMS from the pyOpenMS nightly 3.7.0.dev20261002; FuzzyDiff/FileInfo of the conda OpenMS): before this change 21/26
ProSE TOPP tests pass (the five above fail on this line only), with it 26/26 (TOPP_ProSE_1 .. _10 without the
QPX/ParquetDiff and OpenTIMS tests).

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

04f79b7 removed precursor:isotopes. TOPPBase rejects an ini with an unknown parameter ("Unknown (or deprecated)
Parameter 'Search:precursor:isotopes' given in outdated parameter file", ILLEGAL_PARAMETERS), so every ProSE TOPP test
that reads ProSE_1/2/4/6_fdr.ini stopped before searching. The item is removed from the four inis; the descriptions of
isotope_error_min/max in ProSE_6_fdr.ini are the current ones.

5312498 adds the search parameter isotope_error_convention=observed_minus_theoretical. The four idXML references get
that line. All their isotope_error values are 0, and nothing else changes.

Observed on kim with the TOPP tool built from this branch (src/topp/ProSE.cpp, TOPPBase from src/openms_cli, the rest of
OpenMS from the pyOpenMS nightly 3.7.0.dev20261002; FuzzyDiff/FileInfo of the conda OpenMS), TOPP_ProSE_1 .. _10
without the QPX/ParquetDiff and OpenTIMS tests:
- old inis and references (as of d7426d0): 1/26 pass; every ini-based run is rejected, and TOPP_ProSE_10_out fails
  on the record line;
- inis fixed, old references: 20/26; the six idXML comparisons fail, each on the added record line only;
- with this change: 26/26. Outside the whitelisted lines (database path, run date, version) the outputs of tests 1, 2,
  4 and 10 equal the references byte for byte; test 3_multi equals test 1, test 5_chunked equals test 1 but for the
  date.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
okohlbacher and others added 3 commits October 3, 2026 20:32
…earched spectra, huge pages, parallel peptide merge, top-N filter)

Conflicts in ProSEAlgorithm.cpp resolved as on opt/best2 2567ce8715: the
background read is a std::future<PeakMap>, and the restriction callback takes
the spectra from it. The TOPP single-file path restricts its first index build
by the same wait rule as search(file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
@okohlbacher okohlbacher changed the title ProSE best version on Timo's benchmark branch: speed patches, develop's ProSE fixes, scoring and rescoring features (+3.6% PSMs, 5.7x faster than develop) ProSE best version on Timo's benchmark branch: speed patches, develop's ProSE fixes, scoring and rescoring features, round-3 speed packages (+3.6% PSMs, about 8x faster than develop) Oct 3, 2026

Copy link
Copy Markdown
Contributor

Reviewed head b95fdb0c8a14fe4475eafa38eb56ce0bfab03434. Two concurrency issues in the new mzML reader should be addressed before merging:

  1. [P2] Concurrent parse failures can corrupt memory — ProSEAlgorithm.cpp:4511–4527

    If multiple chunks encounter invalid numeric or XML fields, their OpenMS exception constructors concurrently update unsynchronized strings in GlobalExceptionHandler. Catching those exceptions happens after these writes, so the reader can crash before reaching its serial fallback. A focused reproducer using this branch's exception implementation produced both a ThreadSanitizer data race and an AddressSanitizer heap-use-after-free in GlobalExceptionHandler::set(). Please make the exception state thread-safe or thread-local before allowing concurrent parsing. Synchronizing only the catch block would be too late.

  2. [P2] Parallel loads race inside Xerces initialization — ProSEAlgorithm.cpp:4513–4516

    Every loadBuffer() calls XMLFile::parseBuffer_(), which unconditionally calls XMLPlatformUtils::Initialize(). Xerces updates a non-atomic initialization counter even after initialization, so the earlier header parse does not prevent this race. The Xerces threading documentation explicitly requires callers to synchronize initialization calls. Please centralize and synchronize initialization while keeping parsing parallel.

Validation: source review plus focused sanitizer reproduction of the exception-state race, not an end-to-end ProSE test. The full build and class suite could not be run because required dependencies were unavailable.

Copy link
Copy Markdown
Contributor

Follow-up review of b95fdb0c8a14fe4475eafa38eb56ce0bfab03434, now validated with a fresh native Debug build of the library and ProSE (GCC 13, assertions enabled, reproducers run with OMP_NUM_THREADS=2).

Four findings are reproduced below. Items 1–3 are inherited from the base branch 20b6e75825; item 4 concerns the new mass-accuracy scoring path. The inherited issues should be fixed or tracked explicitly, rather than treated as regressions introduced by this PR.

  1. [P1] Residue-specific terminal PTMs cause an abort during parallel search.

    buildModSlots_ stores Gln->pyro-Glu (N-term Q) in an ordinary residue slot. Reconstruction consequently calls setModification() instead of setNTerminalModification().

    Reproducer: search an independently generated theoretical spectrum of .(Gln->pyro-Glu)QPEPTIDER against QPEPTIDER, with no cleavage and that variable modification enabled. ProSEAlgorithm::search() terminates with SIGABRT, despite an outer exception handler. The exception is the ResidueDB.cpp:455 precondition requiring ANYWHERE specificity for residue modifications. The existing FragmentIndex_test also fails on this precondition in the new peptidoform-deduplication test.

    Please represent residue-specific terminal modifications as terminal slots while retaining their residue eligibility, and capture worker exceptions for rethrow after the parallel region.

  2. [P2] Overlapping fixed and variable modifications make indexed masses disagree with reconstructed sequences.

    Reproducer: no-cleavage ACPEPTIDER, with Carbamidomethyl (C) configured as both fixed and variable. Two indexed candidates reconstruct to AC(Carbamidomethyl)PEPTIDER, but the additional variable candidate has an indexed mass 57.0215 Da above the reconstructed sequence's getMonoWeight() + PROTON_MASS_U.

    Variant mass calculation adds the variable delta to a mass already containing the fixed modification, whereas reconstruction replaces the residue modification. Please reject incompatible overlap or skip variable modifications on sites occupied by a fixed modification. Comparing reconstructed strings alone does not check this invariant.

  3. [P2] SNES misses nonempty PTM combinations with zero total mass shift.

    Reproducer: independently generate the spectrum of AN(Deamidated)PEPTIDER.(Amidated), then query AKANPEPTIDERHILNPQSTV with nonspecific digestion, variable Deamidated (N) and Amidated (C-term), and a maximum of two variable modifications. Conventional indexing returns the correct modified candidate. SNES returns only the unmodified sequence for this case.

    The +0.984016 and −0.984016 Da shifts cancel. The zero-sigma shortcut assumes this means “no variable mods” and bypasses subset enumeration. Please retain the empty subset and enumerate valid nonempty zero-sum subsets as well.

  4. [P2] Zero fragment tolerance is accepted and then aborts parallel mass-accuracy scoring.

    Reproducer: set scoring:method=mass_accuracy, fragment:mass_tolerance=0, annotate:local_fragment_evidence=false, fragment:deisotope=false, and calibration:enabled=false. Parameter configuration succeeds. Searching theoretical PEPTIDER spectra then terminates with SIGABRT: HyperScore::computeMassAccuracy() throws InvalidParameter inside the parallel scoring loop, bypassing the caller's exception handler.

    Tolerance validation is conditional on local fragment evidence, but the new scorer independently requires a finite, positive tolerance. Validate this requirement before entering parallel processing.

Validation: all 33 TOPP_ProSE_* checks passed, including QPX/Parquet checks. Six of seven selected class-test executables passed: ProSEAlgorithm, FragmentIonLikelihoodModel, HyperScore, IdXMLFile, PeptideIndexing and PercolatorInfile. FragmentIndex failed as described above. Five independent synthetic phosphopeptide searches also recovered the correct top sequence: four positional phosphoisomers and a doubly phosphorylated peptide with methionine oxidation and fixed carbamidomethylation. These are synthetic correctness checks, not a real-data localization benchmark.

For code placement, the reusable parallel input reader belongs in the format layer, CLI-specific summary rendering belongs in TOPP, and PTM enumeration/scoring should stay in the library. This is an architectural recommendation separate from the reproduced defects.

I would address the failing Debug test and exception propagation before merging.

timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Oct 6, 2026
Extract IdXMLFile and its tests with the XMLHandler serialization helper
from okohlbacher/OpenMS b95fdb0.
Add a reproducible paired writer benchmark harness.

Native builds, class tests and timings remain blocked by missing build
dependencies and unreachable package hosts. See the benchmark README.
No benchmark speedup is claimed.
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Oct 6, 2026
Extract IdXMLFile and regression tests from OpenMS#10403 on top of the
XMLHandler helper in OpenMS#10427. Add a paired native benchmark harness
and raw measurements against develop fe7b9cc.

GCC 13 native targeted Debug validation passed IdXMLFile_test and
XMLHandler_test. At 4 threads the scaled single-run and multi-run
fixtures are 2.45x and 1.70x faster; output hashes are identical.
timosachsenberg added a commit to timosachsenberg/OpenMS that referenced this pull request Oct 6, 2026
Assign peptides to runs once, cache metadata names per worker, and
format ordered blocks in parallel. Preserve hit order and propagate
the earliest worker failure. Include regression tests and changelog.

Depends on the XMLHandler serialization helper in OpenMS#10427.
Local native IdXMLFile_test and XMLHandler_test passed.
Paired benchmark measurements are documented in the PR description.
timosachsenberg added a commit that referenced this pull request Oct 6, 2026
Assign peptides to runs once, cache metadata names per worker, and
format ordered blocks in parallel. Preserve hit order and propagate
the earliest worker failure. Include regression tests and changelog.

Depends on the XMLHandler serialization helper in #10427.
Local native IdXMLFile_test and XMLHandler_test passed.
Paired benchmark measurements are documented in the PR description.
timosachsenberg added a commit that referenced this pull request Oct 6, 2026
* [INTERNAL] Extract XMLHandler user parameter value writer

* [INTERNAL,TEST] Extract parallel idXML writer from #10403 (#10430)

Assign peptides to runs once, cache metadata names per worker, and
format ordered blocks in parallel. Preserve hit order and propagate
the earliest worker failure. Include regression tests and changelog.

Depends on the XMLHandler serialization helper in #10427.
Local native IdXMLFile_test and XMLHandler_test passed.
Paired benchmark measurements are documented in the PR description.
timosachsenberg added a commit that referenced this pull request Oct 7, 2026
)

Extract the PercolatorInfile spectrum-grouping fix from #10403. Extend regression coverage to legacy keys, signed isotope offsets, modified peptides and serialized PIN rows.
@timosachsenberg

Copy link
Copy Markdown
Contributor

just FYI (I did not double-check) but I think #10457 was missed by the agent

timosachsenberg pushed a commit that referenced this pull request Oct 8, 2026
…n 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
timosachsenberg pushed a commit that referenced this pull request Oct 8, 2026
…ifications, 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

Copy link
Copy Markdown
Contributor

For the record, since you asked where problems turned up: this series, together with #10400, is now in #10466 (develop-based; #10400's commits, a merge of develop, the round-3 packages from here, and fixes for the six review findings above). Here is where each problem was, and whether it came from this series or was already there.

Introduced by the series

  • scoring:method=mass_accuracy accepted a fragment tolerance that is not finite and positive (fragment:mass_tolerance=0). The check in updateMembers_ was conditional on annotate:local_fragment_evidence, while HyperScore::computeMassAccuracy() requires the tolerance unconditionally and threw inside the parallel scoring loop, which terminated the process. Checked at parameter time now; auto falls back to HyperScore for such a tolerance.
  • The chunked mzML reader exposed two older races rather than creating them (next section): it is the first place where XMLFile::parseBuffer_() runs on several threads at once, and where several threads can construct OpenMS exceptions at the same time.

Older bugs the series made reachable or that its own tests exposed

  • GlobalExceptionHandler kept the last exception in shared static strings written by every exception constructor. A 4-thread reproducer under ThreadSanitizer showed 15 races in set(); the catch (...) in loadMzMLChunked comes after those writes. The state is thread-local now.
  • XMLFile::parseBuffer_() and parse_() called XMLPlatformUtils::Initialize() per parse without synchronisation; Xerces requires callers to serialise it. Now behind a process-wide lock (Internal::xercesInitialize()).
  • FragmentIndex::buildModSlots_() put residue-specific terminal modifications (Gln->pyro-Glu (N-term Q)) into residue slots; reconstruction then called setModification() with a modification of N-term specificity, which fails ResidueDB::getModifiedResidue's precondition. In Release the modification was merely placed on the residue instead of the terminus. Your getProteinOccurrences test used that modification and so aborted in a Debug build.
  • A variable modification was also applied to residues that already carry the same fixed one (Carbamidomethyl (C) fixed and variable): the index held both masses, 57.02 Da above the reconstructed sequence, and the peptidoform was indexed twice. Skipped now, as ModifiedPeptideGenerator does.
  • SNES passed Σ = 0 hits through as the unmodified realization only, so a subset whose shifts cancel (Deamidated (N) with Amidated (C-term)) was never produced. Note that SNES can only retrieve such a sub-peptide with fragment:min_matched_ions 1: the mother shares just b1 and y9 with it. That is a limit of the design, not a bug.
  • The parallel scoring and calibration loops of ProSEAlgorithm had no exception capture at all, so any throw on a worker (the two above, or a modification AASequence rejects) ended the process instead of surfacing as an error. They capture and rethrow now.

Friction in the port, not bugs

The measurements in these two PRs were not repeated after the fixes. The modification fixes change what is indexed only for configurations with fixed/variable overlap or residue-specific terminal modifications, which the benchmark does not use; the ProSE TOPP references did not change.


Generated by Claude Code

@okohlbacher okohlbacher closed this Oct 8, 2026
timosachsenberg added a commit that referenced this pull request Oct 8, 2026
…10429)

Extract the PeptideIndexing optimization from #10403.
Keep thread-local merges protected, then sort the complete match vector
once after the parallel region instead of sorting after each merge.
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
timosachsenberg pushed a commit that referenced this pull request Oct 8, 2026
Brings in #10448, #10453, #10449 (ProSE -rescore), #10429, #10463, #10455 and
#10452. #10429 is the same PeptideIndexing change this branch carried from
#10403, so the files merged identically; its duplicate CHANGELOG entry is
dropped. The CHANGELOG conflict keeps both sides.

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

Copy link
Copy Markdown
Contributor Author

Thanks, Timo, for carrying both PRs into #10466 and for the record of where each problem was.

#10457: yes, we missed that.

Your record: it matches what we found.

#10400 and #10403 are closed; #10466 is the one ProSE PR to develop.


Drafted with Claude Code

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