Crates.io | mzdata |
lib.rs | mzdata |
version | 0.39.0 |
source | src |
created_at | 2021-07-20 00:44:57.606594 |
updated_at | 2024-11-30 23:29:16.640265 |
description | A library to read mass spectrometry data formats |
homepage | |
repository | https://github.com/mobiusklein/mzdata |
max_upload_size | |
id | 424972 |
size | 2,822,269 |
A Rust library for reading mass spectrometry data file formats.
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);
}
mzML
and indexedmzML
MGF
mzMLb
This library was made in part to learn Rust, so it may not use the preferred idioms, patterns, or libraries. Any recommendations are welcome.