Skip to main content

Crate openmassspec_io

Crate openmassspec_io 

Source
Expand description

openmassspec-io is the umbrella crate that ties together the open Rust mass-spec parsers (opentfraw, opentimstdf, openwraw, openaraw, opensxraw, openszraw) behind a uniform vendor-detection + mzML-conversion API.

Each vendor parser is gated behind a Cargo feature (thermo, bruker, waters, agilent, sciex, shimadzu); the all meta-feature pulls in every supported vendor. The reader crates are private dependencies: no reader type appears in this crate’s API, so a reader’s major release does not change it. Reader errors arrive as Error::Reader; Error::reader_error gives the reader’s own error for downcasting. The arrow feature re-exports openmassspec-arrow as [arrow]; no Arrow type appears anywhere else in this crate’s API.

Even with no features enabled, detect_format is available so callers can probe a path without paying the compile-time cost of a parser they will not use.

§Errors in the record stream

Every vendor source yields Result records: a spectrum or chromatogram the parser cannot decode is reported as an error, never dropped. collect, stream, and collect_chromatograms stop at the first such error and return it. convert_to_mzml does the same by default; ConvertOptions::with_record_error_policy with RecordErrorPolicy::Skip leaves unreadable records out instead and reports how many in the returned WriteSummary.

§Centroiding

ConvertOptions::with_centroid, collect_centroided, and stream_centroided centroid every profile-mode spectrum first via openmassspec_core::Centroided. Centroiding is always opt-in.

§Example

use std::path::Path;
use openmassspec_io::core::RecordErrorPolicy;
use openmassspec_io::{convert_to_mzml, detect_format, ConvertOptions};

let detected = detect_format(Path::new("run.raw")).expect("supported format");
let opts = ConvertOptions::new()
    .with_indexed(true)
    .with_record_error_policy(RecordErrorPolicy::Skip);
let summary = convert_to_mzml(&detected, Path::new("run.mzML"), &opts)?;
if summary.skipped() > 0 {
    eprintln!("warning: {} unreadable records skipped", summary.skipped());
}

Re-exports§

pub use openmassspec_core as core;

Structs§

ConvertOptions
Options for convert_to_mzml and convert_to_mzml_writer.
Detected
Result of probing a filesystem path for a supported vendor format.
VecSource
A trivial in-memory SpectrumSource backed by a Vec<SpectrumRecord> and a RunMetadata. Hand it to openmassspec_core::write_mzml when you already have the records in hand and just want to emit mzML.

Enums§

Error
Errors produced by the umbrella openmassspec-io API.
VendorFormat
Detected on-disk vendor / format family.

Functions§

collect
Decode every spectrum of detected into a Vec, together with the run-level metadata. Used by tools that need a second pass over the data (conformance validation, info summaries).
collect_centroided
Like collect, but every profile-mode spectrum is centroided first via openmassspec_core::Centroided. Already-centroided spectra pass through unchanged. min_intensity, when Some, discards picked peaks below that noise floor.
collect_chromatograms
Decode chromatogram traces from a vendor acquisition without decoding its spectra. The returned records retain their native channel IDs and time/intensity arrays; vendors without decoded traces return an empty vec.
convert_to_mzml
Convert a detected vendor acquisition to an mzML file at output.
convert_to_mzml_writer
Like convert_to_mzml but writes to an arbitrary writer (gzip, stdout, an in-memory buffer). The writer is not flushed.
detect_format
Inspect path (file or directory) and return the matching vendor format, or None when none of the supported signatures match.
metadata_only
Return only the run-level metadata for detected, without decoding any spectra.
stream
Like collect, but visits each spectrum through on_spectrum as soon as it is decoded instead of buffering the whole run into a Vec first. Memory use is bounded by whatever on_spectrum itself retains, not by the acquisition size.
stream_centroided
Like stream, but every profile-mode spectrum is centroided first via openmassspec_core::Centroided. Already-centroided spectra pass through unchanged. min_intensity, when Some, discards picked peaks below that noise floor.
with_source
Open the vendor source for detected and run f on it.

Type Aliases§

BoxError
A vendor reader’s own error, type-erased.
Result
Convenience alias mirroring the vendor crates.