Expand description
The DataArray implementation for data buffer manipulation used for, amongst other things,
mapping numeric data to and from optionally compressed little endian base-64 byte arrays with
as few data copies as possible, algebraically.
Also covers the ArrayType enum that covers the standardized array flavors telling us which
dimension an array describes, BinaryArrayMap collections of (ArrayType, DataArray), and
traits for converting to and from BinaryArrayMap based upon the set of available ArrayType.
This includes a generalization for BinaryArrayMap3D when ion mobility is available.
§Compression
mzdata supports several kinds of data compression methods with tradeoffs
§Lossless methods
zlibcompressionBinaryCompressionType::Zlib: A well known, widely available general-purpose compressor codec with many implementations, with varying speed and size tradeoffs taken fromflate2.zstdcompressionBinaryCompressionType::Zstd: A newer general-purpose codec that is not widely used in mzML but very popular in other applications. Much faster and often better compression compared tozlib. Requires featurezstdbyte-shuffled zstdcompressionBinaryCompressionType::ShuffleZstd: This first applies a byte shuffle transform to the data to compress thenth byte of each value contiguously, and then applyzstd. This makes sorted data compress more effectively. Requires featurezstddictionary encoded zstdBinaryCompressionType::ZstdDict: Another elaboration ofbyte-shuffled zstdwhere the values are first dictionary-encoded so that repeated values are denoted by indices rather than the full size value itself. The dictionary is sorted and then both the dictionary and the indices are byte shuffle encoded and thenzstdcompressed. This is even more effective than previous codecs for data with repeated, semi-sorted values like m/z and ion mobility. Requires featurezstd
§Lossy methods
numpress-linearcompressionBinaryCompressionType::NumpressLinear: A combination simple linear model fit and byte packing codec that stores the model coefficients as float64 and the residuals as unsigned 16 or 32-bit integers. With an optimal fixed point, this will produce a median loss of accuracy below of about 2e-8 absolute units, but may vary widely from dataset to dataset. This codec MUST be used with sorted data only, and is only suitable for float64 data. It may be combined withzlibBinaryCompressionType::NumpressLinearZliborzstdBinaryCompressionType::NumpressLinearZstdfor even greater space savings. See details at https://doi.org/10.1074/mcp.O114.037879. /// Requires featurenumpressnumpress-slofcompressionBinaryCompressionType::NumpressSLOF: A lossy numerical approximation that log transforms and scales values to make them very close to 16-bit integers. This codec is lossier the larger the value is, and is only appropriate for count data like intensities. It can also combine withzlibBinaryCompressionType::NumpressSLOFZlibandzstdBinaryCompressionType::NumpressSLOFZstd. See details at https://doi.org/10.1074/mcp.O114.037879 Requires featurenumpressnumpress-piccompressionBinaryCompressionType::NumpressPIC: This simply rounds a floating point value and then packs it into a truncated integer. May be suitable for intensity values, but not consistently better thanBinaryCompressionType::NumpressSLOF. See details at https://doi.org/10.1074/mcp.O114.037879 Requires featurenumpress- Linear prediction compression
BinaryCompressionType::LinearPrediction: The same concept asBinaryCompressionType::NumpressLinearwithout the truncation All of the same concerns apply though it loses less precision. This does not perform any form of compression. It was uses as part of mzMLb which applies container-level compression. Only suitable for float64 data. - Delta encoding
BinaryCompressionType::DeltaPrediction: This computes first order difference of a sorted array of values and stores the difference and the starting point. It is sometimes more accurate thanBinaryCompressionType::LinearPrediction. LikeBinaryCompressionType::LinearPrediction, it does not do any actual compression. It was meant for use with mzMLb, which compresses the entire container. Only suitable for float64 data. - Delta-shuffled
zstdBinaryCompressionType::DeltaShuffleZstd: CombinesBinaryCompressionType::DeltaPredictionwithBinaryCompressionType::ShuffleZstd. Requires featurezstd
§Supported Data types
mzdata supports five basic binary data types via the BinaryDataArrayType enum. Data that doesn’t follow any of these types
may still be transported with the BinaryDataArrayType::Unknown variant, but it will not be directly usable.
These values may be decoded on the fly or stored for faster repeated access. Coercion with DataArray::coerce relies on
bytemuck to do the heavy lifting. Conversion through DataArray::convert maps between different types but makes copies.
Modules§
Structs§
- Binary
Array Map - A collection of
DataArrays that are identified by name. - Binary
Array Map3D - Represent a set of
BinaryArrayMapthat has been split across an ion mobility dimension. - Data
Array - Represents a data array that holds a byte buffer that may be compressed, base64 encoded, or raw little endian bytes, and provides views of those bytes as a small range of supported types.
- Data
Array Slice - Represent a slice of a
DataArraythat manages offsets and decoding automatically.
Enums§
- Array
Retrieval Error - A high level set of failure modes that an operation to retrieve a typed memory buffer
from a
BinaryArrayMapmight encounter. May also be used to represented conversion during reading or writing. - Array
Type - The kinds of data arrays found in mass spectrometry data files governed by the PSI-MS controlled vocabulary.
- Arrays
Available - Whether or not sufficient arrays are available in a
BinaryArrayMapto construct a peak list usingBuildFromArrayMaporBuildFromArrayMap3D - Binary
Compression Type - The range of compression and encoding states that a raw byte buffer
might be in during different stages of decoding. Other than
Decoded, these states may or may not include intermediate base64 encoding. - Binary
Data Array Type - The canonical primitive data types found in MS data file formats supported by the PSI-MS controlled vocabulary
Traits§
- Build
Array Map3D From - An extension of
BuildArrayMapFromthat producesBinaryArrayMap3Dinstead. - Build
Array MapFrom - A trait for converting a slice of peaks or features into a
BinaryArrayMap. - Build
From Array Map - A trait for reconstructing a
Vecof peaks or features from aBinaryArrayMap. - Build
From Array Map3D - An extension of
BuildFromArrayMapthat consumes [BinaryArray3D] to build aVecofSelf. - Byte
Array View - A byte array that may be encoded and compressed as [
BinaryCompressionType], or unpacked in memory and re-interpreted as native types appropriate toBinaryDataArrayType. - Byte
Array View Mut - A mutable byte array
Functions§
- as_
bytes - Reinterpret a slice of a
bytemuck::Podtype as raw bytes without copying or converting endianness. - delta_
decoding - The decoder for
BinaryCompressionType::DeltaPrediction. - delta_
encoding - The encoder for
BinaryCompressionType::DeltaPrediction. - linear_
prediction_ decoding - The decoder for
BinaryCompressionType::LinearPrediction. - linear_
prediction_ encoding - The encoder for
BinaryCompressionType::LinearPrediction. - to_
bytes - Convert the values in
datainto an owned buffer of little-endian bytes - vec_
as_ bytes - Convert an owned
Vecof abytemuck::Podtype into an owned buffer of bytes.