Skip to content

[EXPERIMENT] WebAssembly: ProSE bindings for the ProSE app - #10604

Merged
timosachsenberg merged 142 commits into
claude/wasm-prose-webappfrom
claude/wasm-prose-app-bindings
Oct 20, 2026
Merged

timosachsenberg merged 142 commits into
claude/wasm-prose-webappfrom
claude/wasm-prose-app-bindings

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Part B of the ProSE app work. These are the WebAssembly bindings the browser app (timosachsenberg/prose-web, branch prose-app) needs to search several files and browse their results. It is stacked on #10575, the WebAssembly ProSE web app.

What it adds

  • searchFiles(files, database, options) → ProSEResultSet
    • It runs one search over several mzML files, which are pooled into one FDR, with per-file progress steps.
    • Options: rescore, keepSpectra and removeDecoys.
    • The search parameter rescore now drives Percolator for the existing search() too, so the binding's own Percolator copy is gone.
  • ProSEResultSet.tables()
    • PSM, peptide and protein tables as typed columns.
    • For peptides: OpenMS and ProForma strings and modification arrays.
    • For proteins: coverage positions, q-values and indistinguishable groups.
    • All Percolator .pin features, stamped by the public PercolatorInfile::stampPinFeaturesOnHits.
  • ProSEResultSet.spectra()
    • The raw MS2 peaks of the identified spectra, kept with the results.
    • They are read again after the search, with a progress step "Reading the spectra of the PSMs...".
  • annotatePeaks(mz, intensity, peptide, charge, options)
    • Annotates fragment ions on stored peak arrays.
    • It shares its internals with annotateSpectrum.
  • predictMS2(peptide, charge, nce, instrument, modelPath?) (ONNX builds only)
    • Returns PeptDeep b/y intensities for a mirror plot.
    • A proline-effect test pins the orientation.
  • New public library API: ProSEAlgorithm::pinEnzymeName(). It is the enzyme name used for the .pin features, made public instead of being copied.
  • WasmFS fix (src/openms_wasm/wasmfs_node.js). It works around emscripten#27825:
    • Cause: when a host file fails to open, the Node backend uses the errno as a descriptor, so a later close closed a Node worker's epoll descriptor.
    • Symptom: an uv__io_poll abort at exit, in about 1 of 4 threaded test runs.
    • Effect: the abort rate went from 7/25 to 0/25. The close errors also come back with the correct sign now.
  • Docs and demo: a README subsection "Several files and the ProSE app", a CHANGELOG entry, and the demo now shows a single rescore control.

Tests

Full JS suite, Node 24.19, Emscripten 6.0.12:

Build Tests Pass Fail Skipped
wasm32-emscripten-mt-onnx (threads + ONNX) 79 74 0 5
wasm32-emscripten-release (single-threaded) 79 65 0 14

The skips are the loader-package tests, plus the ONNX-only and thread-only tests in the builds that lack those features. The multi-file results match the TOPP test ProSE_13_merged (#10602).

Added after the whole-branch review

  • Inputs larger than the 4 GB heap (file by file). searchFiles(files, db, { provideFile, releaseFile }) searches one file at a time: each file's spectra are collected right after its search and the file is released.
    • It gives the same results as the all-files-present search.
    • New bindings allocateFile(path, size, capacity?), writeFileChunk() and readFileChunk() read and write files in bounded chunks (several GB/s). Their errors are clean: files of 2 GiB or more are rejected before anything is allocated.
    • A capacity lets successive files reuse one block, so the heap stays flat with files of increasing size.
    • 12 × 733 MB (8.8 GB) completes at about 3.1 GB of heap.
    • An OPFS backend was measured first and rejected: its searches were 2.6× slower.
  • [FIX] ProSEAlgorithm: the thread that reads the next spectrum file is joined, not detached.
    • Under Emscripten pthreads, a detached thread only returns its Worker when the main thread's event loop runs, so searchFiles of 7 or more files hung at 4 threads.
    • Nothing changes natively (74/74 ProSE tests).
    • develop does not have WebAssembly, so the fix stays in this stack.
  • PeptDeep memory. PeptDeep previously kept about 1 GB of heap per rescored file.
    • Cause: ONNX Runtime has no CPU arena on 32-bit, its memory pattern allocated an 8–25 MB block per run, and mimalloc never reuses such blocks.
    • Fixes: the memory pattern is off; the NCE selection predicts each sampled peptide once; peptdeep:batch_size defaults to 128 in WebAssembly (ML::PEPTDEEP_DEFAULT_BATCH_SIZE).
    • Results are bit-identical. The two native-relevant commits are also proposed for develop in [FIX] PeptDeep rescoring: no ONNX memory pattern; NCE selection predicts each sampled peptide once #10641, where they halve native PeptDeep time on a 733 MB file.
  • FS.writeFile/FS.write/FS.read throw ENOMEM instead of overwriting memory from address 0 when the heap cannot hold their buffer.
  • Other fixes:
    • spectra().collisionEnergy reads MS:1000045 (msconvert, ThermoRawFileParser).
    • With FDR:PSM 0 and no Percolator, PSM q-values are annotated.
    • predictMS2 validates charge 1–6 and NCE 10–60.
    • search() passes Percolator's warning on.
    • summary() gained the search statistics.
    • New public ProSEAlgorithm::modMatchTolerance().
  • README. It documents what is not guarded, gives the heap growth for many small files (it grows with the thread count: use fewer threads for searches of many files), and says that a non-Error exception from the module is fatal.

Tests:

Build Node tests Pass Fail Skipped Chromium runner
mt-onnx 91 86 0 5 7/7
release 91 76 0 15 6/6

Known follow-ups (not in this PR)

  • Library bug, found while reading spectra: since d49ba5f, PeakFileOptions::setSkipChromatograms(true) makes MzMLHandler return every spectrum empty (MzMLHandler.cpp:160). It is not used here.
  • Heap growth: heap use grows by about 30 MB per file and search with threads, for search() as well. The app restarts its worker before each search.

🤖 Generated with Claude Code

claude and others added 30 commits June 4, 2026 10:11
Replace the placeholder identity correction matrices (added in #9003 as a
stopgap while values were unverified) with the measured isotope correction
matrices for TMT 32-plex and 35-plex.

- TMTThirtyTwoPlex/ThirtyFivePlexQuantitationMethod: set the default
  correction_matrix to the Thermo-sourced values and read it back in
  getIsotopeCorrectionMatrix() (same pattern as TMT 16-/18-plex) instead of
  forcing an identity matrix.
- Values come from the Thermo TMTpro deuterated reagent set Certificate of
  Analysis (product A40000817). The non-deuterated channels are byte-identical
  to OpenMS' existing TMT 16-/18-plex datasheet matrices (verified); the
  deuterated channels are lot-specific and should be replaced with the values
  from the user's reagent-lot CoA.
- Update IsobaricAnalyzer documentation and the TMT32/35 + IsobaricQuantifier
  unit tests to assert the real (non-identity) correction matrix.

Original matrix values contributed by @FreezB11 in #7969.

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

https://claude.ai/code/session_01CwxxuL4okxsZTH6aCaUoCS
- TMT32/35: the channel-topology comment still described the old all-NA
  identity default; update it to reflect the CoA-derived defaults.
- TMT32/35 unit tests: assert that a user-supplied all-NA correction_matrix
  is honored and falls back to the identity matrix.

https://claude.ai/code/session_01CwxxuL4okxsZTH6aCaUoCS
…ed + deuterated parameters

The TMTpro 32-/35-plex correction matrices were entered as one flat 32x14 /
35x14 table, which is hard to maintain and easy to misalign. The reagents
actually ship on two separate Thermo Certificate-of-Analysis sheets, so split
the parameter to mirror them:

- correction_matrix: non-deuterated channels, 8 columns (identical layout to
  the TMT 16-/18-plex matrix), pasteable straight from the TMTpro 16-/18-plex CoA.
- correction_matrix_deuterated: deuterated channels, 14 columns (adds the six
  2H offsets), from the deuterated reagent CoA.

getIsotopeCorrectionMatrix() merges them via a new shared base-class helper,
IsobaricQuantitationMethod::stringListToIsotopeCorrectionMatrixSplit_(), which
expands each 8-column non-deuterated row into the 14-column layout (NA in the
six 2H positions) and interleaves both inputs in channel order before building
the matrix. The resulting TMT32 matrix is bit-for-bit identical to before.

For TMT35, align the 134C non-deuterated row to the TMT 18-plex values
(0.14/5.81/0.31); it was the only one of the 18 non-deuterated rows that did
not match the TMTpro datasheet, contradicting the documented intent that the
non-deuterated channels are identical to TMT 16-/18-plex. These are example
lot values (Thermo ships per-lot factors on the CoA), so users should replace
them regardless.

Tests: switch the all-NA identity fallback to the two-parameter form and add
assertions exercising a deuterated channel's 14-column row.

https://claude.ai/code/session_01CwxxuL4okxsZTH6aCaUoCS
… params

The TMT32 all-NA identity check still set the pre-refactor single 32x14
correction_matrix, which the new split parser rejects (it expects 16
non-deuterated 8-column rows in correction_matrix plus 16 deuterated
14-column rows in correction_matrix_deuterated). Switch it to the
two-parameter form, matching the TMT32/35 unit tests. The identity
expectation is unchanged; only the input parameter shape is corrected.

Fixes the IsobaricQuantifier_test failure across all CI platforms.

https://claude.ai/code/session_01CwxxuL4okxsZTH6aCaUoCS
…gex-free filter parsing

Trailer values are looked up via a per-file label->index map instead of linear
string scans; numbers are parsed with std::from_chars instead of locale-imbued
istringstreams; scan filters are parsed without a per-scan std::regex (#10522).

Co-authored-by: Copilot App <[email protected]>
…leHandler pushdown

- Per-scan conversion moved into the reusable Internal::ThermoRawScanReader
  (header()/convert()), for later streaming and random-access readers.
- ThermoRawFile::Options: scan number, RT, MS level and precursor m/z
  selection, metadata_only and skip_chromatograms. Unselected scans are not
  decoded; selected MSn scans keep the precursors (incl. the intensity
  estimate from the parent scan) of a full load.
- TIC built from scan headers; trailer JSON only with preserve_trailers;
  no per-scan sort or final sortSpectra when acquisition order holds.
- Instrument configuration ids are independent of the scan selection.
- FileHandler::loadExperiment passes PeakFileOptions (MS levels, RT/precursor
  ranges, metadata-only, fill-data, skip-chromatograms) to the reader and does
  not compute the SHA-1. FileConverter computes it only with -raw_checksum.
- Tests, pyOpenMS bindings, docs and CHANGELOG.

Part of #10522

Co-authored-by: Copilot App <[email protected]>
…d scan API

Scan headers come from the fixed-layout ScanHeader with trailer text paired
with the per-file trailer layout instead of a JSON document per scan. Header
and peaks of a scan that will be converted are read in one call, peaks
arrive m/z-sorted (no per-spectrum sort), SHA-1 is computed by an explicit
call only when requested, and the preserved trailer JSON is built without a
JSON DOM. Output is unchanged.

The bridge is pinned to the v1.0.0 branch commit (FetchContent, vcpkg
overlay, CI asset script) until the v1.0.0 tag is released.

Part of #10522

Co-authored-by: Copilot App <[email protected]>
With more than one OpenMP thread, up to three worker threads read the
following scans (header, trailer text and, when needed, peaks) on their own
bridge accessors in chunks while the calling thread parses precursors and
converts in acquisition order. A bounded window limits the buffered scans;
worker errors are rethrown in order. Output does not depend on the thread
count (verified by parity dumps and a class test).

HeLa (97k scans) FileHandler load: 4.1 s -> 2.3 s.

Part of #10522

Co-authored-by: Copilot App <[email protected]>
Source-compatible: inline ScanHeader trailer lookups, static Catch2 in shared
builds, and noise triplets that are complete or empty. Scans without a centroid
stream (ion trap) therefore no longer get a noise m/z array without
intensities when noise_data is set; documented in the CHANGELOG.

Part of #10522

Co-authored-by: Copilot App <[email protected]>
The v1.0.0 tag points at the merge of OpenMS/openms-thermo-bridge#13, whose tree
equals the previously pinned e6f0f97. FetchContent, the vcpkg overlay port and
fetch_thermo_assets.sh move to it.

Part of #10522

Co-authored-by: Copilot App <[email protected]>
…assets

The v1.0.0 release publishes linux-x64, osx-arm64 and win-x64 zips; linux-arm64
keeps building the managed assemblies with the .NET SDK, as for v0.3.1.

Part of #10522

Co-authored-by: Copilot App <[email protected]>
…aged zip

The v1.0.0 release now also publishes a linux-arm64 zip (built natively on an
arm64 runner, OpenMS/openms-thermo-bridge#15), so all four platforms download
and verify the same pre-built managed assemblies.

Part of #10522

Co-authored-by: Copilot App <[email protected]>
Cover all three noise arrays in RAW and mzML round trips, preserve double precision and independent grids under peak filtering, and exercise FileConverter include_noise. Clarify the existing opt-in export and distinguish vendor noise from calculated reporter S/N.

Co-authored-by: Copilot App <[email protected]>
[FEATURE] ThermoRawFile: faster reading, scan selection and PeakFileOptions pushdown (bridge 1.0.0)
…ot stored (#10548)

An empty 'spectra_data' (or 'spectra_data_raw') list names no files and could not be told from a
missing one: getPrimaryMSRunPath() returns no files for both, and no code checks whether the meta value
exists. The Parquet formats wrote both as an empty list and read an empty list back, so converting a
run without files (e.g. featureXML -> consensusparquet -> consensusXML) added one.

- setPrimaryMSRunPath() with an empty list removes the meta value (it stored an empty list and warned);
  addPrimaryMSRunPath() with an empty list changes nothing.
- removeEmptyPrimaryMSRunPaths() removes empty lists; idXML, featureXML, consensusXML and the Parquet
  formats call it when they load a protein run, so files with an empty list stay readable.
- pyOpenMS binds removeEmptyPrimaryMSRunPaths().
- Expected outputs: 17 files lose the empty 'spectra_data' line (18 lines; nothing else changes, each
  test passes FuzzyDiff against its expected file with only that line removed). Inputs with an empty list
  are unchanged.


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

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

abort_() is called by all threads of the OpenMP seed extension in run_() and
updated the member maps aborts_ (and, in debug mode, abort_reasons_ and the
log) without a lock. Two threads inserting a new abort reason at the same time
could corrupt the map, which crashed FeatureFinderAlgorithmPicked_test on
macOS CI. The body of abort_() is now a named critical section, like the other
shared state of the loop.


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

Co-authored-by: Claude <[email protected]>
…ges (#10560)

* CI: install rclone and ccache on Windows from GitHub releases with SHA256 check

The Chocolatey community feed returned a 504 for rclone.portable and failed
the whole Windows job. Fetch pinned release zips with curl retries instead and
verify them against a recorded SHA256. rsync stays on choco (pinned 6.2.7,
no upstream release zip).

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

* CI: convert the Windows tool cache path before putting it on PATH

RUNNER_TOOL_CACHE is C:\hostedtoolcache\windows; bash cannot use that in PATH,
so rclone was not found right after its install.

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

* CI: install rclone and ccache from OpenMS/chocolatey-packages

As suggested in review: instead of a separate download script, take the
two tools from the OpenMS/chocolatey-packages repository, which
deps-windows.sh already builds for doxygen. Its packages download the
same pinned GitHub releases and check their SHA256, so the community
feed is no longer involved. Drops tools/ci/install-windows-tools.sh;
Chocolatey's shims put rclone and ccache on PATH as before.

Needs the ccache and rclone packages on chocolatey-packages' trunk.

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

---------

Co-authored-by: Claude <[email protected]>
ThermoRawFile::transform() streams a .raw file scan by scan into an
IMSDataConsumer, honouring the Options selection (scan/RT/MS level/precursor
ranges, metadata_only, skip_chromatograms). A header pass gives the exact
expected size and all instrument configurations; spectra follow in
acquisition order, then PDA spectra and chromatograms. Parent MS1 data for
the precursor intensity estimate is kept in a small bounded cache.

FileHandler::transformExperiment() supports .raw with PeakFileOptions
pushdown. FileConverter -process_lowmemory now streams .raw instead of
silently loading it fully. OpenSwathWorkflow streams .raw into the SWATH
consumers and keeps only metadata for exp_meta (loadFromMSExperiment no
longer aliases the full map). SageAdapter and CometAdapter stream .raw into
their temporary mzML.

Part of #10522

Co-authored-by: Copilot App <[email protected]>
FileConverter -process_lowmemory streams .raw only to mzML and cachedMzML;
other outputs load the whole file with a warning. transformExperiment
applies PeakFileOptions for mzML and mzXML too (new FileHandler_test
section checks parity with loadExperiment); document that their
expected sizes are the unfiltered counts from the file.

Co-authored-by: Copilot App <[email protected]>
* [FEATURE,API,TEST] Export RNA modification sites as bedRMod

* [FIX,TEST] Preserve bedRMod identity and observation frequencies

* [DOC] Attribute generated RNA classes to Sam Wein

* [FIX,TEST] Aggregate bedRMod sites and validate export identity

* [TEST] Use TextFile iterators in no-truncation regression

* [FIX,TEST] Report buffered bedRMod write failures
* [FEATURE,TEST] Report raw residual precursor percentage

Preserve the complete reviewed PR change while rebuilding the stack on its current parent. Includes the existing review fixes and tests.

* [FIX,API,TEST] Export raw precursor metrics from observations

* [FIX,TEST] Refresh derived precursor percentages without narrowing windows
…build (#10558)

* [FIX] MetaboliteSpectralMatching.h: comparator objects are inline variables

PrecursorMZLess and SpectralMatchScoreGreater were defined (not just declared) in the
public header, so every translation unit including it defined them: two such TUs in one
program (e.g. a test linked against a static libOpenMS) fail with duplicate symbols.
Make them C++17 inline variables.

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

* [FIX] Protein group FDR: a group without a score gets the worst calibrated value explicitly

IDScoreGetterSetter::setScores_ looked a NaN group score up in the score-to-FDR map.
NaN is outside the ordering of std::map<double, double>, so the lookup is undefined:
libstdc++ returns the first/last element (the worst calibrated score, which
FalseDiscoveryRate_test expects), libc++ (Emscripten) returns an element in between
(q-value 1/3 instead of 2/3). Assign the worst calibrated value without a lookup.

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

* [FIX] Format long double as double under libc++

libc++ implements std::to_chars(long double) by converting to double, but appendToStr
asked for writtenDigits<long double>() digits, so toStr(17.012345L) printed the binary
expansion of the double (17.012344999999999828...). Affects libc++ targets whose long
double is wider than double (x86_64 macOS, Linux with libc++, wasm32). Under
_LIBCPP_VERSION write the value as a double with double's digits; the test framework
mirror in ClassTestUtils.h does the same. libstdc++ is unchanged.

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

* [FIX] IndexedMzMLDecoder, MzMLSpectrumDecoder: initialise Xerces before DOM parsing

Both relied on the static initialiser object in CONCEPT/Init.cpp. A static libOpenMS
links that object file only if something calls into it, so a program using only these
decoders used Xerces uninitialised (crash in IndexedMzMLDecoder_test). Call
Internal::xercesInitialize() once, as XMLFile, ImzMLFile and others already do.

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

* [FIX] DataValue stores integers as Int64

Integers were stored in a SignedSize (ptrdiff_t), which is 32 bits on 32-bit targets, so
DataValue(Int64) and xsd:long values were truncated there (XMLFile_test). Store Int64;
the union is 8 bytes either way, so 64-bit platforms keep their layout.

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

---------

Co-authored-by: Claude <[email protected]>
[FEATURE,API] Stream Thermo RAW files with constant memory (transform, FileConverter -process_lowmemory, OpenSWATH)
timosachsenberg and others added 4 commits October 17, 2026 10:42
The inputs of the PeptDeep models change shape from call to call (batch size,
peptide length). For each shape, ONNX Runtime's memory pattern plans one block
for all intermediate tensors of a Run, and every Run of that shape allocates
and frees that block again. For the MS2 model these blocks are 8 to 25 MB:
natively, 542 allocations of 4 MiB or more per search of a 75 MB file.
Without the pattern the tensors are allocated one by one, at most 8.6 MB each.

In WebAssembly, ONNX Runtime has no CPU arena (it has none on 32-bit
platforms), so these blocks come from malloc. mimalloc 3.5.1 (Emscripten
6.0.12) places an allocation larger than one 4 MiB arena chunk only in chunks
that are entirely free. When it finds none, it reserves new arenas and never
releases them.

On the threaded module, three PeptDeep-rescored searches of erwinia_tmt.mzML
took the heap from 351 to 1414, 2345 and 4096 MB; the PeptDeep steps alone
grew it by 540, 576 and 1305 MB. Without the pattern, the PeptDeep step of
every search after the first takes no new memory. The search around it still
grows the heap from search to search, as it does without PeptDeep.

- The features of all 2051 PSMs are bit-identical, at NCE 30 and with the
  automatic NCE, in WebAssembly and natively.
- Inference is as fast: natively 5.03 s instead of 5.08 s per search.
- Natively the CPU arena of the MS2 model peaks lower: 82 instead of 149 MB
  allocated, 59 instead of 93 MB in use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts sample once

The automatic NCE selection predicted its sample of up to 2000 confident PSMs
PSM by PSM. The predictions for the run, in contrast, were already made once
per distinct (sequence, charge).

A file that repeats its peptides therefore made repeated predictions, in
batches of up to 500 copies of the same peptides. big733.mzML, which holds
erwinia's spectra eight times, is such a file. In WebAssembly, the tensors of
those batches grew the heap by another 1.6 GB during "Selecting collision
energy", even without ONNX Runtime's memory pattern.

Each distinct peptide of the sample is now predicted once per candidate energy
and reused for every sampled PSM that identifies it.

- big733: the PeptDeep step takes the heap from 2151 to 2311 MB instead of
  3926 MB, in 6 to 8 s instead of 24 s.
- The selected NCE (39) and its median cosine are unchanged.
- The features are bit-identical: all 16408 PSMs of big733, and all 2051 of
  erwinia in WebAssembly and natively.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Distinct peptides of one length also make PeptDeep batches whose tensors grow
the heap of a WebAssembly module, because their memory is not reused. This
applies to the final prediction of a run with many peptides, where the batches
were capped at 500. The native default stays at 500.

- Heap: with batches of 50, 100 or 200, the spectra of DatabaseSuitability four
  times stayed at 810 MB. With 500 they grew to 3927 MB, in a module without
  the deduplication of the NCE sample.
- Time: unchanged. On erwinia the PeptDeep step takes 11.2 s with 128 instead of
  11.4 s.
- Results: the features are bit-identical with batches of 128 and 500 (erwinia
  at NCE 30 and automatic, big733 automatic).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…atch size 128

- "peptdeep:batch_size is 128 by default" checks the WebAssembly default of
  ProSEAlgorithm, in getDefaults() and getParameterValues().
- "repeated PeptDeep searches do not grow the heap per file" runs on a module
  of its own with 4 threads. It searches the spectra of
  DatabaseSuitability_in_spec.mzML twice in one file, so that the NCE sample
  repeats its peptides (the single small file does not reproduce the problem:
  its batches have at most 115 peptides). Two PeptDeep searches may differ in
  heap by at most 400 MiB.
  - The bound covers the growth that a threaded search shows from search to
    search even without PeptDeep. Before the fixes, the second search took
    another 1.9 GB.

Both tests fail on the module before the fixes. The heap test reports "the
heap grew from 1483800576 to 3429957632 bytes".

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

@timosachsenberg timosachsenberg left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed the changes specific to the expanded Wasm ProSE API at be22770: scoped parameter restoration, multi-file merge/FDR handling, result ownership, PSM table construction and spectrum-to-file mapping. No additional substantive finding in those paths. The shared rescoring changes are covered separately in #10578; the service-worker cache issue is posted on the base PR #10575. No workflow run was available for this head, and I did not execute a fresh Wasm/browser search. This review does not claim exhaustive coverage of all 304 files in the stacked diff.

timosachsenberg and others added 7 commits October 19, 2026 11:39
… chunks of a bounded size

For files that do not fit into JavaScript and the module's memory twice, e.g. a File of the
browser staged with FileReaderSync in a Web Worker, or an idXML handed back to the page:
- allocateFile(path, size): creates or resizes the file with one allocation. The memory backend of
  WasmFS keeps a file in one std::vector, which otherwise grows by doubling (up to three times the
  size while it grows).
- writeFileChunk(path, data, offset): one typed-array set per MiB, through a 1 MiB buffer (a chunk
  takes no memory of the module; mimalloc did not always reuse that of 16 MB buffers). Staging a
  733 MB mzML file in 16 MB chunks with FileReaderSync: 450-850 MB/s in Chromium; FS.write() copies
  byte by byte (about 25 MB/s).
- readFileChunk(path, offset, length): a new Uint8Array, fewer bytes at the end.
WasmFS is compiled without exceptions: an allocation that fails inside it unwinds through its
locks. So the memory a file needs at its new size is probed first (through a volatile pointer: the
compiler dropped a malloc that was freed unused) and OutOfMemory is thrown instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… memory cannot hold their buffer

Emscripten's (6.0.12, src/lib/libwasmfs.js) copy the data through a buffer from _malloc() and do
not check it. The module grows its memory (ALLOW_MEMORY_GROWTH, hence ABORTING_MALLOC=0): where the
memory cannot hold the buffer, malloc returns 0 and the data was written from address 0 over the
module's memory (FS.read(): read from there). With 3 GiB of files in the memory file system, an
FS.writeFile() of 1.3 GiB threw "Cannot read properties of undefined (reading 'ref')", and the
module then failed with "operation does not support unaligned accesses".

wasmfs_fs.js (--js-library, guarded by the Emscripten version) redefines FS_writeFile and replaces
FS.write and FS.read when the module starts: they throw FS.ErrnoError(ENOMEM) instead, and the module
stays usable. FS.write() also copies its data with one typed-array set instead of byte by byte.
New test: the three, and allocateFile()/writeFileChunk(), next to 3 GiB of files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… joined, not detached

The multi-file search reads file i + 1 on a helper thread while file i is searched (and a search
of one file reads it while the index is built). std::async detaches that thread. In WebAssembly
(Emscripten), a detached thread that ends gives its Web Worker back to the pool only when the event
loop of the module's main thread runs, which it does not while a search runs: every file read in
the background kept a Worker, and in Chromium with 4 threads searchFiles() of 7 or more files waited
for a Worker forever (with 78 MB and with 733 MB files alike, at any heap size).

BackgroundSpectra holds the std::future of the spectra and the std::thread of a std::packaged_task;
the thread that takes the spectra (get()) or drops them (destructor, move assignment) joins it, and
a join gives the Worker back at once. Natively nothing changes: std::async's future also waited for
the thread when it was taken or destroyed. Without threads (WebAssembly), the read stays deferred.

Tests: ProSEAlgorithm_test and the TOPP_ProSE tests (natively, applied to the merged tree: 74 of
74), ProSEAlgorithm_test in the threaded WebAssembly build, and a browser scenario of 12 files in
src/openms_wasm/tests/browser/run.mjs (with the next commit): it hung before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…for inputs larger than the memory

In a browser the input files live in the module's memory (WasmFS' memory backend), and
searchFiles() needed all of them for the whole call: two files of 733 MB took the heap to 3969 MB,
a third did not fit. With the options provideFile(i, path) and releaseFile(i, path), searchFiles()
searches the files one at a time: provideFile writes file i (e.g. from the user's File with
FileReaderSync, allocateFile() and writeFileChunk()), the file is searched alone
(searchWithModificationAnalysis() of that file) and the spectra of its PSMs are read
(ProSEResultSet::collectSpectraOfFile()), then releaseFile removes it. Then the results are pooled as
before (mergeFileResults()); an open search of several files gets the modification analysis of the
pooled PSMs, as the multi-file search computes it. spectra() gives the PSM rows their spectra after
the pooling (assignSpectra(), split out of collectSpectra()), and drops those of PSMs the pooling
removed.

- The results are the same as with all files there: summary, tables and spectra, compared in a
  Node.js test (TOPP_ProSE_13_merged with Percolator and removeDecoys, and an open search of two
  files) and in the Chromium runner (two files, in a Web Worker with FileReaderSync, on the page
  from bytes).
- Progress: the binding reports its own step "Searching <name> (i of n)..." per file; the step
  "(1 of 1)" of the search of one file is left out (JSProgressLogger::hideNestedFileSteps()), and
  "Reading the spectra of the PSMs..." comes inside the step of each file.
- What provideFile or releaseFile throws is caught in JavaScript and rethrown as OpenMS exception with
  its message (SearchFilesError), after releaseFile of that file: a JavaScript exception must not
  unwind the C++ frames of a search.
- Chromium, 4 threads, copies of a 733 MB mzML file: 1 file 2153 MB and 13.9 s (all files written
  first: 2393 MB, 14.5 s), 2 files 2269 MB, 4 files 2485 MB in 52.9 s, 12 files (8.8 GB) 2969 MB in
  163 s; writing with FileReaderSync 450-850 MB/s.
- The Chromium runner also searches 12 files at once (4 threads), which hung before the previous
  commit.
- README: the file-by-file search, an example for the ProSE app, the measurements, the export of
  idXML in chunks. CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, checked before any allocation

WasmFS' memory backend keeps a file in one std::vector, which holds less than 2 GiB in wasm32
(max_size() 2^31 - 1), and a block close to that cannot be allocated. In fresh modules, allocateFile()
of 1.99 GiB worked; 1.999 GiB and 2^31 - 1 passed the memory probe and then aborted inside WasmFS'
resize (RuntimeError: unreachable); 2^31 and more reported OutOfMemory, which is misleading.

- A size or the end of a write above 2 GiB - 64 MiB (2080374784 bytes) throws InvalidValue
  ("a file of the module's file system has to be smaller than 2 GiB ..."), before anything is
  allocated. Up to that size an allocation succeeds where the memory has room.
- The block that growing a file takes (its std::vector doubles) is computed and checked, too: a file of
  more than about 1 GiB cannot grow by a write past its end (InvalidValue: allocate it at its final size
  first). The probe allocates that block, not the new size.
- Offsets, sizes and the length of the data (a typed array can hold more than 4 GiB) are checked as
  64-bit values before any cast to size_t, which truncated above 4 GiB. Invalid numbers are reported as
  JavaScript writes them (NaN, Infinity).
- FS.write() and FS.read() check offset and length against their buffer before the allocation (EINVAL),
  so that a RangeError cannot leak it, and free it in a finally. FS.write() copies only typed arrays of
  bytes in one piece; others value by value, as Emscripten's.

Tests: the limit without any large allocation (sizes and offsets above it, beyond 4 GiB), and in the
fresh module of the memory test a file of exactly the limit, one byte more, the growth of a 1 GiB file,
and the ranges of FS.write() and FS.read(). README: the exact errors, for an app to say "file too large".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…; the equality test with different inputs

- A provideFile or releaseFile that returns a thenable (an async function, a Promise) makes searchFiles()
  throw IllegalArgument: "searchFiles(): provideFile must be synchronous (return nothing, not a
  Promise): provideFile(0, '<path>') returned a Promise." The search needs the file when the function
  returns and cannot wait. For provideFile, releaseFile is called for that file as for other errors.
  README and tests.
- The equality test of the file-by-file search: the open search now searches the two halves of
  DatabaseSuitability_in_spec.mzML (spectra at even and at odd positions; different PSMs), so that a
  search that mixed up its files would differ. The Percolator case compares with the cached search of
  TOPP_ProSE_13_merged (pooled()) instead of searching again: 32 s instead of 48 s.
- README: the measurements of the "written first" column say which run they come from (the 2-file one
  is from the run before FS.write() copied in one piece, which gave 2569 MB and 13.7 s for one file).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…GELOG entry of the library fix

The comment on BackgroundSpectra says that libc++'s std::async detaches its thread, and that a join
on the module's main thread (the thread a search runs on when called from JavaScript) gives the Web
Worker back at once. CHANGELOG: the fix of the reader thread is an entry of its own under
"OpenMS Library", out of the WebAssembly bullet. Comments only in the code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
timosachsenberg and others added 12 commits October 19, 2026 12:45
…reuse one block

mimalloc does not give the block of a removed file to a larger one. Files staged one at a time
(searchFiles() with provideFile/releaseFile), each removed before the next, therefore grew the heap
with every file larger than the ones before, although only one was there: allocated at their sizes,
0.9, 1.0 and 1.1 GiB took the heap to 1103, 2147 and 3295 MB, and 1.2 GiB did not fit; 64, 96 and
128 MB took it to 243, 359 and 507 MB. Files of equal size stayed flat (12 x 733 MB).

allocateFile(path, size, capacity) creates the file anew (an existing one is replaced, so that its
block is freed first) in a block of capacity bytes: the empty file is resized to the capacity, which
allocates exactly that block (and is what the probe checks), then to the size, which keeps it (libc++).
Allocated with the size of the largest as capacity, every file takes the block of the one before: 0.9
to 1.4 GiB in increasing order stay at 1615 MB, 64 to 160 MB at 339 MB, with a new path per file or one
path for all. The capacity has to be at least the size and smaller than 2 GiB. Writes past the size are
still checked as growth by doubling: WasmFS does not tell the capacity of a file, and a registry by path
or inode (the address of the file) can go stale, after which a missed allocation would abort.

- Test: files of 64, 96, 128 and 160 MB with the capacity of the largest keep the heap of a fresh module
  flat (fails without the capacity: 243, 359, 507 MB), one path for all replaces the file, the checks
  of the capacity.
- The Chromium runner stages its files with a capacity.
- README: the capacity and why, the recipe of the ProSE app with the largest input's size as capacity,
  and the paths that are still not guarded (growth of a file by FS.writeFile/FS.write, FS.truncate, files
  OpenMS writes such as storeIdXML()), and that a raw WebAssembly.Exception or a RuntimeError is fatal:
  terminate the Worker. CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…collision energy" (MS:1000045)

spectra() read Precursor::getActivationEnergy(), which MzMLHandler sets only
from MS:1000509 "activation energy". msconvert, ThermoRawFileParser and
Bruker's converter write MS:1000045 "collision energy" instead, which
MzMLHandler keeps as the precursor's meta value "collision energy" (what
PeptDeepRescoring reads), so collisionEnergy was NaN for typical mzML files.
It now takes the meta value first, then the activation energy, and is NaN if
there is neither.

The test stores a file with MS:1000045 only, with MS:1000045 and MS:1000509,
and with MS:1000509 only; it fails on the module before the change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
ProSEAlgorithm.search() reported only whether Percolator was applied and why it
was skipped; the caveat of an applied rescoring (its sanity check replaced the
learned model by the best single feature), which searchFiles() already passes
as percolator.warning, was dropped. search() sets it now (null if none), and
the d.ts says so.

The test searches the spectra against shuffled proteins (an open search, so
that there are PSMs for Percolator to train on), where Percolator warns, with
search() and searchFiles(); it fails on the module before the change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
ProSEMultiSummary now has what search() reports of the search as a whole, under
the same names: summary().search (database, enzyme, decoyMode, the size of the
fragment index, secondsIndexBuild, secondsTotal, ...), and each file's
precursorError and fragmentError ({ median, mad, recommended }: the tolerances
ProSE recommends), which the library computes per file.

The library does not set seconds_total for a multi-file search (its caller does),
so searchFiles() measures its whole call. A search without provideFile builds
the index once, which holds all of the digest; with provideFile each file's
search builds its own from the spectra of the file, so secondsIndexBuild adds
them up and the size is that of the first file's index (the README says so).
The database file is the path given, where the library has none for a search
from memory.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…without filtering

With FDR:PSM 0 (no filter) and no Percolator, psms.qValue was NaN for every
PSM, although the search had decoys. searchFiles() now gives the PSMs of each
file that Percolator did not rescore the q-values that FDR:PSM would compute
(ProSEAlgorithm::annotatePsmQValues(), the old demo's annotatePsmQValues),
without filtering anything. They are added as the meta value "q-value" of the
best hits, computed on a copy: the scores stay ProSE's, which the protein
inference of the pooled results ranks by, so nothing else changes. A file
without a decoy PSM keeps NaN, as does a search without decoys. The d.ts no
longer says "NaN: no FDR (no decoys)" only.

The test (an open search against shuffled proteins, with PSMs of all q-values)
requires the q-values to equal those of FDR:PSM 1, which filters nothing
either, with the same scores, and checks the cases with Percolator and
without decoys.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…60, else InvalidValue

predictMS2() accepted any positive charge and any finite energy, and the model
answers for them: charge 12 gave the ions of charge 8 (all charges from 8 on
are the same to it), an energy of 200 none. It now throws InvalidValue for a
charge outside 1 to 6 and an energy outside 10 to 60.

Neither the library nor peptdeep states a range (ML:: has only the
instruments), so this is the binding's choice, documented as such in the
source, the README and the error message. Measured on the model: the ions
become few from charge 6 on and an energy above 60 degrades them. A search can
use an energy outside the range (peptdeep:nce takes any value), which the
README mentions for the app.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… PeptDeep classes and ProSEAlgorithm

The number of peptides per ONNX Runtime run was written out in five places: 500
in the constructors of PeptDeepMS2Inference, PeptDeepRTInference and
PeptDeepCCSInference, in PeptDeepRescoring's 'batch_size', and (128 under
__EMSCRIPTEN__, since 888678e) in ProSEAlgorithm's 'peptdeep:batch_size'.
ML::PEPTDEEP_DEFAULT_BATCH_SIZE (PeptDeepUtils.h) is now the one definition:
500, and 128 in WebAssembly, where ONNX Runtime has no memory arena and the
memory of large tensors is not reused. Natively nothing changes. In
WebAssembly, PeptDeepRescoring and the inference classes default to 128 too
(the bindings' predictMS2() uses the inference class's default; its comment
said the batch size was that of the parameter, which was only true natively).

The PeptDeepLibraryPredictor config keeps its own 500: it is not part of ProSE's
rescoring.

Tests: the default of both parameters and the value of the constant. The
develop PR #10641 carries two of the PeptDeep memory commits but not
888678e, so the constant lives only in this branch.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…modification analysis, public

searchFiles() with provideFile (the WebAssembly bindings) searches the files one
at a time and analyses the modifications of the pooled PSMs of an open search
itself; it took the tolerance for that from the private
ProSEAlgorithm::computeModMatchTolerance_() by copying its rule. The rule is now
the public static ProSEAlgorithm::modMatchTolerance(lower, upper), which
computeModMatchTolerance_() and the bindings both use. No change of behaviour.

Test: the rule itself (the tighter side; a side of zero is a one-sided window)
and that computeModMatchTolerance_() follows it.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…efaults, write within the size, provideFile capacity

- peptides.proteinOffsets: documented in the d.ts and the README that
  proteinOffsets[k] === proteinOffsets[k + 1] means all proteins of the peptide
  failed the protein FDR; its PSMs stay (the app shows them as "below protein
  FDR").
- annotatePeaks() defaults maxCharge to the precursor charge - 1, while
  predictMS2() returns doubly charged ions for a precursor of charge 2 or more:
  documented in both README subsections (pass maxCharge to make them agree).
- allocateFile() with a capacity: the README now says that a write past a
  file's capacity can abort the module, and that writes have to stay within
  the size.
- provideFile in the d.ts mentions allocateFile(path, size, capacity).
- README: FS.writeFile() of WasmFS appends to a file that exists (found while
  writing a test); unlink it first.
- CHANGELOG: the changes of the bindings of this round.
- The title of the PeptDeep heap test no longer says "do not grow the heap per
  file", which the test does not show (the search's own growth remains): "take
  no memory per file beyond the search's own".

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… and the index size of the summary

The summary of searchFiles() has the search statistics now, whose times differ
between two searches and whose index differs between a search with all files
there and one file by file (the latter builds it for each file from its spectra).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…mall files, allocateFile replacing

From the scoped final review of the ProSE app bindings:
- the index of a one-file search holds only the reachable peptides only on one thread;
- the heap growth of many small files depends on the thread count and on PeptDeep (measured
  12 x 75 MB file by file at 4, 8 and 16 threads); fewer threads for searches of many files;
- only allocateFile(path, size, capacity) creates a file anew; the two-argument form resizes in place.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o the cluster mass, not the lowest within the tolerance

mapDeltaMassesToModifications() took the entry of lowest mass within +-tolerance of a
cluster (lower_bound) and the entry of highest mass (the last one <= cluster + tolerance),
and named the cluster "A//B" after both, or after the one if they were the same. The entry
nearest to the cluster mass was never named when it lay between others. With the Unimod
table, +15.9949 Da (oxidation) was "thiocarboxylic acid//Oxidation or Hydroxylation":
thiocarboxylic acid (+15.9772 Da) is the lowest mass within 0.02 Da. histogram_found
recorded the same two extremes, and the later lookups took the lowest entry of their window:

- the PTM meta value of the PSMs of the oxidation cluster was "thiocarboxylic acid"
  (first entry of histogram_found within the tolerance),
- DeltaMassEntry::mapped_modification of generateDeltaMassStatistics() was "thiocarboxylic
  acid" (the lowest mass still wins),
- a cluster at +16.9949 Da was "thiocarboxylic acid+1Da" (first entry in the window around
  cluster - 1 Da) instead of "Oxidation or Hydroxylation+1Da".

Now a cluster is named after the entry nearest to its mass if that is within the tolerance
(still capped at 0.02 Da). "A//B" is kept for genuine ambiguity: entries whose distance to
the cluster exceeds that of the nearest by at most 0.0005 Da, the width of the delta mass
histogram bins, are named as well (in order of mass), as a cluster mass is not known better
than that. Only the entries that name the cluster go into histogram_found. The nearest entry
is also used wherever histogram_found is searched (the +1 Da variant, a modification found
before, the PTM annotation of the hits), by generateDeltaMassStatistics() (same naming), and
for the combination of two modifications, which was looked up at or above the cluster mass
only (lower_bound(cluster)), so that a combination below it, within the tolerance, was missed
(a cluster of -114.043 Da was "Unknown" with a combination 0.011 Da below it).

The ModificationsDB lookups by mass (searchModificationsByDiffMonoMass*, getBest...) do not
fit: the table here is the Unimod search modifications, one name per mass, and is also the
basis of the combinations and the +1 Da logic; the sorted-map lookup is O(log n) per cluster
for histograms of 1e4-1e5 bins.

Tests: OpenSearchModificationAnalysis_test maps clusters at oxidation, thiocarboxylic acid
and between them, with the tolerance, in ppm mode, with PSM annotation, the +1 Da variant,
the combination (against a brute force over the Unimod table) and generateDeltaMassStatistics.
No reference file changes; the ModificationAnalysis tables of TOPP_ProSE_12_open_* gain one
combination name for a cluster that was "Unknown" (-114.043 Da).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
(cherry picked from commit 42fe579)
@timosachsenberg
timosachsenberg merged commit 2589222 into claude/wasm-prose-webapp Oct 20, 2026
2 checks passed
@timosachsenberg
timosachsenberg deleted the claude/wasm-prose-app-bindings branch October 20, 2026 06:55
@timosachsenberg

Copy link
Copy Markdown
Contributor Author

Merged into #10575: the stack is now #10564 ← #10575. These commits are on claude/wasm-prose-webapp (fast-forward), develop is merged into both branches (the library parts #10578/#10602/#10644 are in develop), and the old demo examples/prose/ is removed in favour of the ProSE app (https://timosachsenberg.github.io/prose-web/). Further work and review happen in #10575.

🤖 Generated with Claude Code

timosachsenberg added a commit that referenced this pull request Oct 23, 2026
…cts each sampled peptide once (#10641)

* [FIX] ONNXPredictorBase: without ONNX Runtime's memory pattern

The inputs of the PeptDeep models change shape from call to call (batch size,
peptide length). For each shape, ONNX Runtime's memory pattern plans one block
for all intermediate tensors of a Run, and every Run of that shape allocates
and frees that block again. For the MS2 model these blocks are 8 to 25 MB:
natively, 542 allocations of 4 MiB or more per search of a 75 MB file
(erwinia_tmt.mzML). Without the pattern the tensors are allocated one by one,
at most 8.6 MB each.

Natively, DisableMemPattern changes only the peak memory:
- The features of all 2051 PSMs of erwinia_tmt.mzML are bit-identical, at NCE
  30 and with the automatic NCE.
- Inference is as fast: 5.03 s instead of 5.08 s per search.
- The CPU arena of the MS2 model peaks lower: 82 instead of 149 MB allocated,
  59 instead of 93 MB in use.
- A whole ProSE search with PeptDeep and the automatic NCE (16 threads, median
  of 5 runs) takes 5.73 s instead of 5.77 s and peaks at 309 instead of 337
  MiB resident. Its idXML output is identical.

Where ONNX Runtime has no CPU arena (it has none on 32-bit platforms), these
blocks come from malloc, and the allocator decides whether they are reused.
This was found in a WebAssembly build of PeptDeepRescoring (the stacked
branch of #10604, not part of this commit). There, mimalloc 3.5.1 (Emscripten
6.0.12) places an allocation larger than one 4 MiB arena chunk only in chunks
that are entirely free. When it finds none, it reserves new arenas and never
releases them.

On the threaded WebAssembly module, three PeptDeep-rescored searches of
erwinia_tmt.mzML took the heap from 351 to 1414, 2345 and 4096 MB; the
PeptDeep steps alone grew it by 540, 576 and 1305 MB. Without the pattern, the
PeptDeep step of every search after the first takes no new memory. The search
around it still grows the heap from search to search, as it does without
PeptDeep. The features are bit-identical in WebAssembly as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 217d1e3)

* [FIX] PeptDeepRescoring: the NCE selection predicts each peptide of its sample once

The automatic NCE selection predicted its sample of up to 2000 confident PSMs
PSM by PSM. The predictions for the run, in contrast, were already made once
per distinct (sequence, charge).

A file that repeats its peptides therefore made repeated predictions, in
batches of up to 500 copies of the same peptides. big733.mzML, which holds
erwinia's spectra eight times, is such a file.

Each distinct peptide of the sample is now predicted once per candidate energy
and reused for every sampled PSM that identifies it.

Natively, the NCE selection makes fewer predictions on a file that repeats its
peptides: as many per candidate energy as the sample has distinct (sequence,
charge), instead of one per sampled PSM. A ProSE search with PeptDeep and the
automatic NCE (16 threads, median of 5 runs, on top of the memory pattern
change) takes:
- for big733.mzML 6.0 s instead of 12.6 s, with 59 instead of 161 CPU seconds;
- for erwinia_tmt.mzML 5.6 s instead of 5.7 s.
The results do not change. The idXML output is identical for both files, i.e.
the features of all 2051 PSMs of erwinia_tmt.mzML and all 16408 PSMs of
big733.mzML. The selected NCE (39 for both) and the median cosine of big733
(0.631769) are the same.

In WebAssembly (the stacked branch of #10604, not part of this commit), the
tensors of those batches grew the heap by another 1.6 GB during "Selecting
collision energy", even without ONNX Runtime's memory pattern. For big733 the
PeptDeep step now takes the heap from 2151 to 2311 MB instead of 3926 MB, in 6
to 8 s instead of 24 s. The features are bit-identical there as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 7e9a861)

---------

Co-authored-by: timosachsenberg <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants