mzrust provides low-level, handle-based access to mzML files from R using Rust.
Load the package and open an mzML file:
library(mzrust)
con <- open_mzml("example.mzML")
Inspect file-level scan metadata and count the indexed spectra:
hdr <- header(con)
n <- spectrum_count(con)
hdr
n
Read one scan or just its peak table:
sp <- spectrum(con, scan = 1L)
pk <- peaks(con, scan = 1L)
sp
pk
Write a filtered copy containing only spectra within a retention-time window:
subset_path <- write_mzml(con, "subset.mzML", rt_min = 5, rt_max = 10)
subset_path
Close the handle when you are finished:
close_mzml(con)
Gzipped input files (.mzML.gz) are also supported by open_mzml(). If you want a packaged example file after installing mzrust, use:
path <- system.file("extdata", "test-spectrum.mzML", package = "mzrust")
con <- open_mzml(path)