Expand description
mzdata provides basic access to raw and processed mass spectrometry data formats in
Rust.
For a guide, see the tutorial section.
The library currently supports reading:
- MGF files using
MGFReaderinmzdata::io::mgf - mzML & indexedmzML files using
MzMLReaderinmzdata::io::mzml - mzMLb files using
MzMLbReaderinmzdata::io::mzmlb, if themzmlbfeature is enabled - Thermo RAW files using
ThermoRawReaderinmzdata::io::thermo, if thethermofeature is enabled
and writing:
- MGF files using
MGFWriterinmzdata::io::mgf - mzML & indexedmzML files using
MzMLWriterinmzdata::io::mzml - mzMLb files using
MzMLbWriterinmzdata::io::mzmlb, if themzmlbfeature is enabled
This menagerie of different formats and gzip compression or not can be inferred from a path or io::Read using io::infer_format and io::infer_from_stream.
Conventional dispatch is possible through MZReader. The mz_read macro provides a convenient means of working with
a value with zero added overhead, but with a limited scope. The mz_write macro is the equivalent for opening a writer.
There are additional tools for dealing with file format dispatch in MassSpectrometryReadWriteProcess.
It also includes a set of representation layers for spectra in mzdata::spectrum
§Example
use std::fs;
use mzdata::prelude::*;
use mzpeaks::Tolerance;
use mzdata::MZReader;
use mzdata::spectrum::SignalContinuity;
let reader = MZReader::open_path("./test/data/small.mzML").unwrap();
for spectrum in reader {
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)
)
);
}
}It uses mzpeaks to represent peaks and peak lists, and re-exports the basic types. While the high-level
types are templated on simple peak types, more complex, application-specific peak types can be substituted.
See mzdata::spectrum::bindata for more information about how to directly convert
data arrays to peak lists.
§Traits
The library makes heavy use of traits to abstract over the implementation details of different file formats.
These traits are included in mzdata::prelude. It also imports mzpeaks::prelude.
Re-exports§
pub use crate::io::MZReader;pub use crate::io::MZReaderBuilder;pub use crate::io::mgf::MGFReader;pub use crate::io::mgf::MGFWriter;pub use crate::io::mzml::MzMLReader;pub use crate::io::mzml::MzMLWriter;pub use crate::io::mzmlb::MzMLbReader;pub use crate::io::mzmlb::MzMLbWriter;pub use crate::io::mzmlb::MzMLbWriterBuilder;pub use crate::params::Param;pub use crate::params::ParamList;pub use crate::spectrum::CentroidSpectrum;pub use crate::spectrum::RawSpectrum;pub use crate::spectrum::Spectrum;pub use mzpeaks;pub use mzsignal;
Modules§
- io
- Reading and writing mass spectrometry data file formats and abstractions over them.
- meta
- Metadata describing mass spectrometry data files and their contents.
- params
- Elements of controlled vocabularies used to describe mass spectra and their components.
- prelude
- A set of foundational traits used throughout the library.
- spectrum
- The data structures and components that represent a mass spectrum and how to access their data.
- tutorial
- A series of written introductions to specific topics in
mzdata - utils
Macros§
- curie
- cvmap
- delegate_
impl_ metadata_ trait - Delegates the implementation of
MSDataFileMetadatato a member. Passing an extra levelextendedtoken implements the optional methods. - find_
param_ method - impl_
metadata_ trait - Assumes a field for the non-
Optionfacets of theMSDataFileMetadataimplementation are present. Passing an extra levelextendedtoken implements the optional methods. - impl_
param_ described - Implement the
ParamDescribedtrait for type$t, referencing aparamsmember of typeVec<Param>. - impl_
param_ described_ deferred - Implement the
ParamDescribedtrait for type$t, referencing aparamsmember that is anOption<Vec<Param>>that will lazily be initialized automatically when it is accessed mutably. - mz_read
- A macro that dynamically works out how to get a
SpectrumSource-derived object from a path orio::Read+io::Seekboxed object. This is meant to be a convenience for working with a scoped file reader without penalty. - mz_
write - A macro that dynamically works out how to get a
SpectrumWriterfrom a path orio::Writeboxed object.