Repository navigation
[FEATURE] ThermoRawFile: faster reading, scan selection and PeakFileOptions pushdown (bridge 1.0.0) - #10541
Conversation
…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]>
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]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Change: Feature Merge Risk: ⚪ Minimal · up to
|
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]>
timosachsenberg
left a comment
There was a problem hiding this comment.
Reviewed fc4c9ea as the first PR in the stack #10541 → #10544 → #10547, including scan selection, precursor reconstruction, read-ahead, PeakFileOptions pushdown and the affected callers.
No blocking issue found in this PR. LGTM, pending successful CI. The findings on streaming and random access belong to the follow-up PRs and do not block merging this one independently.
At review time, the Linux GCC/Clang build-and-test checks, header-set compatibility and documentation checks have passed. Other platform and wheel checks are still running or queued, so this approval is not a claim that all checks have passed.
Validation: source review and inspection of the current CI results; no full OpenMS build or real-RAW integration tests were run locally.
PR 1 of 3 for #10522 (Thermo RAW reader speed). Follow-ups: (2) streaming
transform()/ FileConverter-process_lowmemory/ OpenSWATH, (3) random access +ISpectrumAccess+ pyOpenMS. Both reuse the per-scan core added here.Changes
Internal::ThermoRawScanReader(new, private, pimpl): reusable conversion of one vendor scan into anMSSpectrum.header(scan)must be called for every scan in acquisition order, because precursors are reconstructed sequentially.convert()turns that scan into anMSSpectrum. If the parent MS1 of an MSn scan was not loaded (MS1 filtered out, metadata-only), the reader decodes it on demand for the precursor-intensity estimate, so MS2 output is identical to an unfiltered load.ThermoRawFile::loadis now a thin loop over this reader.ThermoRawFileMetadata: a per-file trailer label→index map replaces the linear string scans,std::from_charsreplaces locale-imbuedistringstream, and filter strings and SPS labels are parsed without astd::regexper scan.ThermoRawFile:preserve_trailersis set, and without a DOM;MSSpectrumis filled directly, with no per-spectrum sort (the bridge returns m/z-sorted peaks);sortSpectraruns only if RTs are not monotone, e.g. PDA spectra interleaved withall_detectors.Read-ahead on worker threads: with more than one OpenMP thread, up to 3 workers read scans ahead while the calling thread converts them; output is unchanged (see below).
New
ThermoRawFile::Options:first_scan/last_scan,rt_min/rt_max,ms_levels,precursor_mz_min/precursor_mz_max,metadata_only,skip_chromatograms. No peaks are read for skipped scans or withmetadata_only.Checksum:
FileHandler::loadExperimentno longer asks the bridge for a SHA-1; it computes its own whencompute_hashis set. FileConverter gets the opt-in-raw_checksumflag, which writes the SHA-1 into the mzML provenance.FileHandler pushdown:
PeakFileOptionsfor MS levels, RT range, precursor m/z range, metadata-only and skip chromatograms are mapped intoThermoRawFile::Options.applyPostLoadOptions_only applies the options that are not pushed down (m/z range, intensity range). MS2-only tools such as SimpleSearchEngine and ProSE therefore no longer decode MS1 peaks.openms-thermo-bridge 1.0.0 API:
ScanHeaderplus per-file trailer layout;file_sha1()call.Pins updated in
cmake/cmake_findExternalLibs.cmake,vcpkg-overlays/ports/openms-thermo-bridgeandtools/ci/fetch_thermo_assets.sh.pyOpenMS bindings for the new options; tests in ThermoRawFile_test, ThermoRawFileMetadata_test, FileHandler_test (pushdown) and test_ThermoRawFile.py;
doc/thermo_raw_mzml.mdand CHANGELOG.Bridge pin
The bridge is pinned to the v1.0.0 release, commit
75849ec, the merge of OpenMS/openms-thermo-bridge#13.fetch_thermo_assets.shverifies the pre-built managed assets for all four platforms (linux-x64, linux-arm64, osx-arm64, win-x64) against their SHA-256. The linux-arm64 zip was added to the v1.0.0 release by OpenMS/openms-thermo-bridge#15.Parity
Checked with a dump tool written for this PR; it is not committed. Per spectrum it records native id, RT, MS level, peak count, a hash of m/z and intensity, data arrays, all meta values (recursively including precursors, activation, scan windows and acquisitions), plus chromatograms and run metadata.
Every change was verified against a develop baseline on all datasets and in these configurations:
Filtered loads were compared against the unfiltered baseline with the same filter applied after loading. The output is identical except for the intentional differences below.
Intentional differences
-raw_checksumto get it back; without it the mzML has an empty SHA-1 cvParam.skip_chromatogramsis now honoured for.rawfiles; it was ignored before.metadata_onlyreads no peaks, so there is no precursor intensity estimate and no lowest/highest observed m/z, and the base peak comes from the vendor scan statistics.noise_data, scans without a centroid stream (ion trap scans) no longer get a "sampled noise m/z array" without intensity or baseline arrays. The vendor returned the segmented scan masses there, not noise samples. This affects 6,949 ITMS scans in the SPS-MS3 file; FTMS noise arrays are unchanged. The change comes from bridge v1.0.0.Benchmark
Setup: macOS arm64 (M-series, 12 cores), .NET 8 arm64, Release build. Each value is the median of 3 runs; RSS is the peak resident set size. Before = develop with bridge 0.3.1; after = this PR with bridge 1.0.0, using the default OpenMP thread count. FileHandler and ThermoRawFile rows are library loads; FileConverter runs with its default
-threads 1.In the FileConverter rows, mzML writing is now the larger share of the time. FileConverter with
-threads 4on HeLa takes 6.9 s instead of 8.4 s.Read-ahead on worker threads
With more than one OpenMP thread (TOPP
-threads), up to three worker threads read the following scans on their own bridge accessors (thread_accessor), in chunks of 128 scans with a bounded window. Each scan is read in a single call: header, trailer text, and peaks when they are needed. The calling thread keeps parsing precursors sequentially and converting in acquisition order, so vendor decoding overlaps with conversion. Inside an enclosing OpenMP parallel region, or with one thread, the reader stays sequential.HeLa FileHandler default with different thread counts:
Compared with sequential reading, this is a further 1.3–1.8× on library loads. Peak RSS is unchanged except SPS-MS3 in profile mode, which uses about 230 MB more for the look-ahead buffer. Output is identical for every thread count: parity dumps match, and a new class test compares 1 thread vs 4 threads, including early stop and header-only scans.
The bridge's own reading alone scales poorly beyond 3 accessors (2.55 s with 1 thread, 1.90 s with 3, 2.40 s with 8), hence the cap. Batch
read_scansgave no gain over per-scan reads.Not adopted: typed trailer values
Typed values would make the header read about 0.6 s faster on HeLa, but they are not equivalent to the vendor-formatted text that OpenMS parses today. The text is rounded to display precision; typed values carry full precision or float32 noise, for example:
Adopting them would change precursor m/z, SPS masses and injection times in the output. With
preserve_trailerson (the default), the text is read anyway for the trailer meta value. This is left for a separate decision.Testing
test_ThermoRawFile.pypasses, including the new tests. The wheel-only bundle-layout check is not applicable in-tree.Summary by CodeRabbit
New Features
-raw_checksum.Changes