Skip to main content

Crate openreadout_mzml

Crate openreadout_mzml 

Source
Expand description

Readers for the open mass-spectrometry exchange formats mzML 1.1 (HUPO-PSI) and mzXML 2.x/3.x (ISB).

Both are XML with base64 binary arrays; files run to many gigabytes, so nothing is loaded whole: the trailing offset index (indexedmzML, mzXML index) is read and spot-checked at open, and each spectrum is parsed from its byte offset on demand. Without a usable index the file is scanned once to locate every spectrum. Layout and vocabulary: docs/formats/mzml.md. Provenance: docs/provenance/mzml.md.

§Example

Every reader implements openreadout_core::FormatReader: descriptor says what it reads, sniff recognises a file from its first bytes, and open returns a openreadout_core::Dataset with a header-only info() summary and lazy data access.

use openreadout_core::FormatReader;
use openreadout_mzml::MzmlReader;

let format = MzmlReader.descriptor();
assert_eq!(format.id, openreadout_mzml::MZML_FORMAT_ID);
println!("{} ({}): .{}", format.name, format.family, format.extensions.join(", ."));

Reading a file:

use std::path::Path;

use openreadout_core::FormatReader;
use openreadout_mzml::MzmlReader;

let mut dataset = MzmlReader.open(Path::new("run.mzML"))?;
let info = dataset.info()?; // headers only
let run = &info.spectra[0];
println!("{} spectra, MS levels {:?}", run.scan_count, run.ms_levels);
// Spectrum 0 of run 0: parallel m/z and intensity arrays.
let spectrum = dataset.read_spectrum(0, 0)?;
println!("MS{} at {:?} s: {} points", spectrum.ms_level, spectrum.rt_s, spectrum.mz.len());

Applications that accept any instrument file usually register every reader in an openreadout_core::Registry and let it detect the format; that is what the openreadout command-line tool does.

§API stability

The supported API is what this page documents. The parser modules are public only so that tests and fuzz targets can reach them: they are hidden from this documentation and may change in any release.

Structs§

ImzmlReader
The imzML reader (mass spectrometry imaging: mzML metadata, arrays in a .ibd file).
MzmlReader
The mzML reader.
MzmlbReader
The mzMLb reader (mzML with its arrays in HDF5 datasets).
MzxmlReader
The mzXML reader.

Constants§

IMZML_FORMAT_ID
Format id of imzML on the command line and in JSON.
MZMLB_FORMAT_ID
Format id of mzMLb on the command line and in JSON.
MZML_FORMAT_ID
Format id of mzML on the command line and in JSON.
MZXML_FORMAT_ID
Format id of mzXML on the command line and in JSON.