Skip to content

mscompress.datasets

Optional ML dataset adapters.

PyTorch

Install with pip install 'mscompress[torch]'.

MSCompressDatasetMember

MSCompressDatasetMember(
    path: Union[str, Path],
    load_annotations: Optional[
        List[AnnotationFormat]
    ] = None,
    cache=None,
)

A single MSZ/MSZX/mzML file. Opens lazily and per-process so it is safe to construct in the parent and use from forked DataLoader workers.

JAX / grain

Install with pip install 'mscompress[jax]'.

MSCompressJaxDataset

MSCompressJaxDataset(
    path: Union[str, Path],
    load_annotations: Optional[
        List[AnnotationFormat]
    ] = None,
)

JAX-friendly random-access dataset over mzML / MSZ / MSZX files.

Implements the grain RandomAccessDataSource protocol (__len__ and __getitem__) so it composes directly with grain.MapDataset.source.

Parameters:

Name Type Description Default
path Union[str, Path]

Path to a msz, mszx, or mzML file, or a directory containing such files.

required
load_annotations Optional[List[AnnotationFormat]]

List of annotation formats to load from MSZX files. Only applicable for MSZX files. Annotations will be returned in getitem if present.

None