Package 'mzrust'

Title: Low-Level mzML Access via Rust
Description: Experimental low-level access to mzML files from R using the Rust mzdata crate.
Authors: Tom Wilson [aut, cre]
Maintainer: Tom Wilson <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-06-07 23:03:20 UTC
Source: https://github.com/wilsontom/mzrust

Help Index


Handle-Based Access To mzML Files

Description

These functions provide a small handle-based API for low-level mzML access from R. open_mzml() validates the file and returns an external-pointer handle. header() returns a data frame of per-spectrum metadata, spectrum_count() returns the number of indexed spectra, spectrum() returns a named list describing a single scan together with its peaks data frame, peaks() returns a data frame with mz and intensity columns for a single scan, or a list of such data frames when scan = NULL, and close_mzml() marks the handle as closed. write_mzml() writes a new indexed mzML file containing only spectra whose retention times fall within the inclusive rt_min to rt_max window, together with recomputed TIC and base-peak summary chromatograms for that subset.

Usage

open_mzml(path)

header(handle)

spectrum_count(handle)

spectrum(handle, scan)

peaks(handle, scan = NULL)

close_mzml(handle)

write_mzml(handle, output_path, rt_min = -Inf, rt_max = Inf)

Arguments

path

Path to a .mzML file. Gzipped .mzML.gz files are also supported.

handle

An mzml_handle returned by open_mzml().

scan

A 1-based scan index. If NULL, return all scans as a list of peak data frames.

output_path

Path where the filtered mzML file will be written. Output is written as indexed .mzML. If the source handle was opened from .mzML.gz, the filtered output is gzipped as well and .gz is appended when needed. The output includes recomputed TIC and base-peak summary chromatograms for the retained spectra.

rt_min

Inclusive lower retention-time bound, using the same units reported by header().

rt_max

Inclusive upper retention-time bound, using the same units reported by header().

Examples

## Not run: 
con <- open_mzml("example.mzML")
hdr <- header(con)
n <- spectrum_count(con)
sp <- spectrum(con, scan = 1L)
pk <- peaks(con, scan = 1L)
all_peaks <- peaks(con)
write_mzml(con, "subset.mzML", rt_min = 5, rt_max = 10)
close_mzml(con)

## End(Not run)