40 breaking releases

new 0.41.0 Jan 2, 2025
0.40.0 Dec 15, 2024
0.39.0 Nov 30, 2024
0.25.0 Jul 26, 2024
0.3.0 Jul 23, 2021

#506 in Parser implementations

Download history 275/week @ 2024-09-18 117/week @ 2024-09-25 182/week @ 2024-10-02 177/week @ 2024-10-09 209/week @ 2024-10-16 52/week @ 2024-10-23 296/week @ 2024-10-30 185/week @ 2024-11-06 159/week @ 2024-11-13 239/week @ 2024-11-20 501/week @ 2024-11-27 467/week @ 2024-12-04 376/week @ 2024-12-11 147/week @ 2024-12-18 33/week @ 2024-12-25 292/week @ 2025-01-01

924 downloads per month
Used in 4 crates

Apache-2.0

1.5MB
34K 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–39MB
~577K SLoC