16 breaking releases

new 0.17.0 May 18, 2024
0.15.0 May 2, 2024
0.13.0 Mar 29, 2024
0.7.0 Dec 26, 2023
0.3.0 Jul 23, 2021

#534 in Parser implementations

Download history 12/week @ 2024-01-22 6/week @ 2024-01-29 19/week @ 2024-02-12 14/week @ 2024-02-19 76/week @ 2024-02-26 6/week @ 2024-03-04 111/week @ 2024-03-11 3/week @ 2024-03-18 114/week @ 2024-03-25 94/week @ 2024-04-01 46/week @ 2024-04-08 136/week @ 2024-04-22 183/week @ 2024-04-29 250/week @ 2024-05-06

569 downloads per month
Used in 2 crates

Apache-2.0

1MB
22K SLoC

mzdata

Latest Version docs.rs

A Rust library for reading mass spectrometry data file formats.

Quickstart

use std::fs;
use mzdata::prelude::*;
use mzpeaks::Tolerance;
use mzdata::MzMLReader;
use mzdata::spectrum::SignalContinuity;

fn main() {
    let mut ms1_count = 0;
    let mut msn_count = 0;
    let reader = MzMLReader::new(fs::File::open("./test/data/small.mzML").unwrap());
    for spectrum in reader {
        if spectrum.ms_level() == 1 {
            ms1_count += 1;
        } else {
            msn_count += 1;
        }
        println!("Scan {} => BP {}", spectrum.id(), spectrum.peaks().base_peak().mz);
        if spectrum.signal_continuity() == SignalContinuity::Centroid {
            let peak_picked = spectrum.into_centroid().unwrap();
            println!("Matches for 579.155: {:?}", peak_picked.peaks.all_peaks_for(579.155, Tolerance::Da(0.02)));
        }
    }
    println!("MS1 Count: {}\nMSn Count: {}", ms1_count, msn_count);
    assert_eq!(ms1_count, 14);
    assert_eq!(msn_count, 34);
}


Supported Formats

  1. mzML and indexedmzML
  2. MGF
  3. mzMLb
  4. Thermo RAW

Disclaimer

This library was made in part to learn Rust, so it may not use the preferred idioms, patterns, or libraries. Any recommendations are welcome.

Dependencies

~7–32MB
~422K SLoC