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 every file type mzLib knows, search results included; many files in one call; MetaMorpheus protein groups, FlashLFQ peptides and PTM site occupancy as long tables, RNA transcript groups and oligos included ✅
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; the label-free design FlashLFQ and MetaMorpheus take, or every reason it was refused ✅
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; Gene Ontology on protein groups, every member kept ✅
Isobaric kits (isobaric) — every TMT, TMTpro, iTRAQ and DiLeu channel with its reporter-ion m/z and matching window, as MetaMorpheus quantifies them ✅
Differential abundance (stats) — limma's moderated t-test (checked against limma to 1e-8), Benjamini-Hochberg, and random-effects meta-analysis across studies, with no R ✅
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.3.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.3.0
File
mzlib-0.3.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
mzlib-0.3.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
mzlib-0.3.0-py3-none-macosx_12_0_x86_64.whl Python 3 none macOS 12.0+ x86-64 Details
mzlib-0.3.0-py3-none-macosx_12_0_arm64.whl Python 3 none macOS 12.0+ ARM64 Details

Total release size: 258.9 MB

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

Download URL mzlib-0.3.0-py3-none-win_amd64.whl
Size 64.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
728ff20417f1c216a35d51829fd5167c17a698580b68ee36668e9f6cb9d5a7fe
BLAKE2b-256 checksum
How to use checksums
de74b3d5ad5e3d3be33b00fa6a09bab20b5265333ae8204f39df392eb27bd482
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 Oct 3, 2026.

Transparency log

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

Download URL mzlib-0.3.0-py3-none-manylinux_2_28_x86_64.whl
Size 61.6 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
340290d0fd7c2942392b9f49afa8a975b0d53484922fb30b3c103a772fac1bc8
BLAKE2b-256 checksum
How to use checksums
6bae5a3dc796b63d6501a89f93a8766dd2587074eb3a5e16b85d730fc401d642
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 Oct 3, 2026.

Transparency log

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

Download URL mzlib-0.3.0-py3-none-macosx_12_0_x86_64.whl
Size 67.4 MB
Tags Python 3 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
71651c3ff2509ea63d06d4d87a706e3f0debec22956bd748b45d8989bf46ff36
BLAKE2b-256 checksum
How to use checksums
ac800be015dffb609070b9df423efbc70e806819d86407b5f50bba68c0e423a7
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 Oct 3, 2026.

Transparency log

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

Download URL mzlib-0.3.0-py3-none-macosx_12_0_arm64.whl
Size 65.2 MB
Tags Python 3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
9ea35c9eb77457fc70225f311e6ef71c7c93e10731377ee78cf1cb47f379cb1b
BLAKE2b-256 checksum
How to use checksums
1afadf2c09931bfcedb4d0e50fad2a135d6a7f0c95a87cac177bd7d17a3d7c73
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 Oct 3, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.0

4 release files

This release

0.3.0 This release

4 release files

0.2.0

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