Expand description
mzdata
provides basic access to raw and processed mass spectrometry data formats in
Rust.
The library currently supports reading:
- MGF files using
MGFReader
inmzdata::io::mgf
- mzML & indexedmzML files using
MzMLReader
inmzdata::io::mzml
- mzMLb files using
MzMLbReader
inmzdata::io::mzmlb
, if themzmlb
feature is enabled - Thermo RAW files using
ThermoRawReader
inmzdata::io::thermo
, if thethermo
feature is enabled
and writing:
- MGF files using
MGFWriter
inmzdata::io::mgf
- mzML & indexedmzML files using
MzMLWriter
inmzdata::io::mzml
- mzMLb files using
MzMLbWriter
inmzdata::io::mzmlb
, if themzmlb
feature 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::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;
Modules§
- Reading and writing mass spectrometry data file formats and abstractions over them.
- Metadata describing mass spectrometry data files and their contents.
- Elements of controlled vocabularies used to describe mass spectra and their components.
- A set of foundational traits used throughout the library.
- The data structures and components that represent a mass spectrum and how to access their data.
Macros§
- Delegates the implementation of
MSDataFileMetadata
to a member. Passing an extra levelextended
token implements the optional methods. - Assumes a field for the non-
Option
facets of theMSDataFileMetadata
implementation are present. Passing an extra levelextended
token implements the optional methods. - Implement the
ParamDescribed
trait for type$t
, referencing aparams
member that is anOption<Vec<
Param
>>
that will lazily be initialized automatically when it is accessed mutably. - A macro that dynamically works out how to get a
SpectrumSource
-derived object from a path orio::Read
+io::Seek
boxed object. This is meant to be a convenience for working with a scoped file reader without penalty. - A macro that dynamically works out how to get a
SpectrumWriter
from a path orio::Write
boxed object.