Skip to main content

pyMzLib

mzLib for Python. mzLib is a mass-spectrometry and proteomics library written in C#, developed in the Smith lab at UW–Madison. pyMzLib makes it callable from Python.

pip install mzlib

Install it as mzlib, import it as pymzlib — the same split as pip install scikit-learn / import sklearn.

That is the whole installation. There is no .NET to install, no runtime to configure, and no third-party Python package to reconcile with the rest of your environment — pyMzLib declares zero runtime dependencies and carries everything it needs inside the wheel.

Quick start

import pymzlib

# What's in a PRIDE Archive project?
files = pymzlib.pride.list_files("PXD000001")
print(f"{len(files)} files, {pymzlib.pride.total_size_bytes(files) / 1e9:.2f} GB")

for f in files:
    print(f"{f.category:8s} {f.size_mb:9.1f} MB  {f.file_name}")

# Pull down just the raw file (220 MB).
raw_files = pymzlib.pride.download("PXD000001", "downloads", category="RAW")

# Read it: mzML, Thermo .raw, Bruker .d, timsTOF .d, MGF and msalign all work the same way.
# Scan headers always; peaks only when you ask, because they are thousands of times larger.
scans = pymzlib.readers.read_spectra(raw_files[0], ms_order=2, limit=5, peaks=True)
print(scans.scan_count, scans.columns["selected_ion_mz"])

Downloads stream to a temporary name and are moved into place only when complete, so an interrupted transfer never leaves you with a truncated file. Pass overwrite=False to skip files you already have — a cheap resume for a large project.

What's covered

Coverage is deliberately partial and grows by demand, the same way pyOpenMS grew.

Area Status
PRIDE Archive — list project files, filtered download ✅
Peptidoforms — digest an annotated protein, apply its modifications, fragment every peptide ✅
Quantification — FlashLFQ label-free quant with match-between-runs, and median-polish protein roll-up ✅
Readers — read spectra from mzML, Thermo .raw, Bruker .d, timsTOF .d, MGF and msalign; identify and read all 36 file types mzLib knows, search results included; many files in one call; MetaMorpheus protein groups, FlashLFQ peptides and PTM site occupancy as long tables ✅
SDRF experimental design — read an SDRF-Proteomics file, pool several experiments into one analysis table; validate, lint and assess them; one row per sample with ages in years ✅
Protein databases (proteins) — organism, taxon, GO terms and Ensembl genes per accession; resolve proteins to Ensembl genes against a pinned release; peptide uniqueness with I = L ✅
Everything else in mzLib not yet — tell us what you need

How it works, and why you probably don't care

mzLib runs as a self-contained executable bundled inside this package; pyMzLib starts it, speaks JSON to it, and hands you ordinary Python objects. The mechanism is an implementation detail and may change — the public API will not.

The consequence worth knowing: calls carry a small fixed startup cost (tens of milliseconds), so pyMzLib is built for coarse-grained operations, not for calling in a tight per-spectrum loop.

Errors

Everything mzLib can fail at arrives as a typed Python exception:

try:
    pymzlib.pride.list_files("PXD000001")
except pymzlib.UsageError:      # you passed something invalid
    ...
except pymzlib.BridgeError as e:  # mzLib/PRIDE failed; e.error_type says how
    ...

Development

# Build the .NET payload and stage it into the package
.\..\build\publish-bridge.ps1

# Set up a dev environment and run the fast tests
python -m venv .venv
.\.venv\Scripts\python -m pip install -e ".[dev]"
.\.venv\Scripts\python -m pytest -m "not network"

pytest -m network additionally hits the live PRIDE Archive.

License

LGPL-3.0-or-later, matching mzLib.

Metadata

Release files for mzlib 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for mzlib 0.2.0
File
mzlib-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
mzlib-0.2.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
mzlib-0.2.0-py3-none-macosx_12_0_x86_64.whl Python 3 none macOS 12.0+ x86-64 Details
mzlib-0.2.0-py3-none-macosx_12_0_arm64.whl Python 3 none macOS 12.0+ ARM64 Details

Total release size: 250.7 MB

Release files / mzlib-0.2.0-py3-none-win_amd64.whl

Download URL mzlib-0.2.0-py3-none-win_amd64.whl
Size 62.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
0c66dcd792637acba39480f7fbc7823bb13b87787f2ae81344e9bef50295df9c
BLAKE2b-256 checksum
How to use checksums
40567e79c2af370dba7ab8f410902672bcf2cc3aa52f24ec7582232433b0ab49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / mzlib-0.2.0-py3-none-manylinux_2_28_x86_64.whl

Download URL mzlib-0.2.0-py3-none-manylinux_2_28_x86_64.whl
Size 59.5 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
9f180069d20eee4dfe5350d4a862141c6a9c417d73a2aff06138cf9aab4582ed
BLAKE2b-256 checksum
How to use checksums
a4c208986f2c0389ae4eb57dde3c317c25e133a21e5fecfe647b3b776a2c26a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / mzlib-0.2.0-py3-none-macosx_12_0_x86_64.whl

Download URL mzlib-0.2.0-py3-none-macosx_12_0_x86_64.whl
Size 65.3 MB
Tags Python 3 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
415ed38effe1bf040cbe2f8f6f98302ee6d7e0f9cff1b09e6e9110760348acbb
BLAKE2b-256 checksum
How to use checksums
bc7830737d5a3990bea3f56067ac3d446b5838df74a3edd6ef4f082307dadfb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / mzlib-0.2.0-py3-none-macosx_12_0_arm64.whl

Download URL mzlib-0.2.0-py3-none-macosx_12_0_arm64.whl
Size 63.2 MB
Tags Python 3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
49bd9f66996e71b787f2109f263cdec464888c4de881c0e31e919a9eae7bc712
BLAKE2b-256 checksum
How to use checksums
47b8fc7904413a96ec1c4753cb3be53db4c7c5d1864d9645b6eb33a685191d71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

4 release files

0.3.0

4 release files

This release

0.2.0 This release

4 release files

0.1.1

4 release files

0.1.0

4 release files

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page