Crate mzdata[][src]

Expand description

mzdata provides basic access to raw and processed mass spectrometry data formats in Rust.

The library currently supports reading:

  1. MGF files using MGFReader in mzdata::io::mgf
  2. mzML files using MzMLReader in mzdata::io::mzml

It also includes a set of representation layers for spectra in mzdata::spectrum


use std::fs;
use mzdata::io::prelude::*;
use mzdata::io::mzml::MzMLReader;

let mut ms1_count = 0;
let mut msn_count = 0;
let mut reader = MzMLReader::open_path("./test/data/small.mzML").unwrap();
for scan in reader {
    if scan.ms_level() == 1 {
        ms1_count += 1;
    } else {
        msn_count += 1;
println!("MS1 Count: {}\nMSn Count: {}", ms1_count, msn_count);
assert_eq!(ms1_count, 14);
assert_eq!(msn_count, 34);

It also provides a sorted data structure for representing peak lists, PeakSet and a trait implementing the majority of the logic, PeakCollection.


pub use crate::io::mgf::MGFReader;
pub use crate::params::Param;
pub use crate::params::ParamDescribed;
pub use crate::params::ParamList;


The data structures and components that represent a mass spectrum and how we access their data.



Represent a single m/z coordinate with an intensity and an index. Nearly the most basic peak representation for peak-picked data.

Represent a single neutral mass coordinate with an intensity, a known charge and an index.

Represents a spectrum that hasn’t been processed yet, with only data arrays, potentially no discrete peaks.


Represents a unit of mass accuracy, and provides the means for measuring them.


A trait for an ordered container of mass spectral peaks. The trait interoperates with CoordinateLike.

A trait for providing a uniform delegated access to spectrum metadata

Type Definitions

A specialization of MzMLReaderType for the default peak types, for common use.

A PeakSetVec of CentroidPeak items ordered by m/z