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 31 file types mzLib knows, search results included
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.

Release files for mzlib 0.1.1

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.1.1
File
mzlib-0.1.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
mzlib-0.1.1-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details
mzlib-0.1.1-py3-none-macosx_12_0_x86_64.whl Python 3 none macOS 12.0+ x86-64 Details
mzlib-0.1.1-py3-none-macosx_12_0_arm64.whl Python 3 none macOS 12.0+ ARM64 Details

Total release size: 249.4 MB

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

Download URL mzlib-0.1.1-py3-none-win_amd64.whl
Size 62.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
6f50d620f6699cf2f50c02113c0c5a984dd6eea4756d7e52420571ce455abc86
BLAKE2b-256 checksum
How to use checksums
7fafc17aa524b0eb034a2878f6ba20e739205ecce9d43a0f861520f7f4201403
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 18, 2026.

Transparency log

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

Download URL mzlib-0.1.1-py3-none-manylinux_2_28_x86_64.whl
Size 59.2 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
84a093d2459554e09829b5d19558f1eeb20583cd632927e03675bbe1e6363614
BLAKE2b-256 checksum
How to use checksums
bfe4e0cf66d4b866fbfbbe1437ab6d3f94757479bc2a0a60497ec08b47ecddff
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 18, 2026.

Transparency log

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

Download URL mzlib-0.1.1-py3-none-macosx_12_0_x86_64.whl
Size 65.0 MB
Tags Python 3 macOS 12.0+ x86-64
SHA-256 checksum
How to use checksums
bab8e30a661648dbbfc05170adee62e0029cd183aee78941b406bc17014fd092
BLAKE2b-256 checksum
How to use checksums
d5687ec80796a114a39507e6b1f206a6e69793c92ae7f12f17cee6ad32d02505
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 18, 2026.

Transparency log

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

Download URL mzlib-0.1.1-py3-none-macosx_12_0_arm64.whl
Size 62.9 MB
Tags Python 3 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
8d184c4b552287aeb3f13a198501ea935f65ccb1c5c62a970b90c8a6c0503cba
BLAKE2b-256 checksum
How to use checksums
4cd319545e758f1234912590d5f325e1b8721a39cb1ee1a8da94931f4bfb6eb6
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 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

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