Skip to main content

paftacular

Paftacular Logo

Python package codecov Documentation Status PyPI version DOI Python 3.12+ License: MIT

paftacular parses and serializes mzPAF (Peak Annotation Format), the HUPO-PSI standard for describing MS/MS fragment ion annotations — ion type, modifications, charge state, mass error, and confidence — as a compact string. It's for anyone reading or writing fragment annotations from spectral libraries or search-engine output who wants a strict, round-trippable parser instead of ad hoc string splitting. It's built on tacular's chemistry lookups, and optionally integrates with peptacular for full peptide-sequence context — peptacular's own fragment generator emits mzPAF strings that paftacular parses directly.

Why paftacular?

  • Strict mzPAF parsing and serialization, single or comma-separated batches, with precise, zero-based error locations on invalid input.
  • Mass and elemental composition for parsed ions, with or without a resolved peptide sequence.
  • Optional peptacular integration: resolve a fragment against a full ProForma analyte for complete mass/m/z, or round-trip fragments generated by peptacular straight back into PafAnnotation objects.
  • Versioned JSON interchange (to_dict/from_dict) for durable storage, alongside a compact as_dict() display format.
  • Typed (py.typed) and cached: repeated modifier/ion components share bounded instance caches.

Install

pip install paftacular
pip install paftacular[peptacular]  # resolve fragments against full sequences
pip install paftacular[smiles]      # SMILES support
pip install paftacular[mcp]         # local MCP server for AI agents
pip install paftacular[all]         # everything

Quick example

import paftacular as pft

# Parse a peptide fragment-ion annotation
ann = pft.parse("y5")
print(ann.ion_type.series, ann.ion_type.position)  # y 5
print(ann.mass())  # 19.017841466812 (offset only; no sequence context)

# Parse several comma-separated annotations at once
anns = pft.parse("y5-H2O^2/1.2ppm*0.95,b3^2")
for a in anns:
    print(a.charge, a.confidence)
# 2 0.95
# 2 None

There are 3 parsing entry points: parse (single or comma-separated, returns one PafAnnotation or a list), parse_multi (always a list), and parse_single (always exactly one, raises ValueError otherwise).

What else it can do

Resolve a fragment against a full peptide with paftacular[peptacular] installed:

import paftacular as pft

ann = pft.parse_single("y2").resolve("PEPTIDE")
print(ann.sequence, ann.mz())  # DE 263.087377579912

Round-trip fragments generated by peptacular straight back into PafAnnotation objects:

import peptacular as pt
import paftacular as pft

fragments = pt.fragment("PEPTIDE", ion_types=("b", "y"), charges=[1])
ann = pft.parse_single(fragments[1].to_mzpaf())
print(ann.ion_type.series, ann.ion_type.position)  # b 2

Batch-parse with per-item error handling, and interchange via versioned JSON:

import json
import paftacular as pft

for result in pft.iter_parse(["y2,b3", "invalid", "p^2"]):
    if result.ok:
        print(result.index, len(result.annotations))
    else:
        print(result.index, result.error.position, result.error.reason)

ann = pft.parse_single("y2/0.000001ppm")
restored = pft.PafAnnotation.from_dict(json.loads(json.dumps(ann.to_dict())))
assert restored == ann

AI agent integration (MCP)

Install with pip install "paftacular[mcp]", then configure your MCP client to launch paftacular-mcp. The server provides nine tools for parsing, construction, sequence resolution, calculations, fragment generation, and m/z matching, plus scientific reference resources and analysis prompts. The mcp extra includes peptide support (paftacular[mcp,smiles] adds SMILES too); the base library needs no MCP dependencies. See the MCP guide for configuration and examples.

mzPAF format

[&][analyte@]ion_type[modifications][^charge][/mass_error][*confidence]

Examples: y5, b2{PEP}, y5-H2O^2, y5/1.2ppm*0.95

See the PSI mzPAF specification for full details.

Documentation

Citation

If you use paftacular in research, cite the archived software release. Machine-readable citation metadata is available in CITATION.cff; GitHub's Cite this repository menu can render it as APA or BibTeX. The stable DOI for all versions is 10.5281/zenodo.19076277; individual releases also receive version-specific DOIs from Zenodo.

License

paftacular is distributed under the MIT License. The bundled mzPAF specification remains under its own PSI copyright and distribution terms; see third-party notices.

Contributing

See CONTRIBUTING.md for development setup, issue reporting, support, and pull-request guidance. Project governance is described in GOVERNANCE.md, and security reports are handled according to SECURITY.md.

Author: Patrick Garrett (pgarrett@scripps.edu)

Release files for paftacular 1.4.0

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

Source distribution (sdist)

Source distribution for paftacular 1.4.0
File Size Uploaded
paftacular-1.4.0.tar.gz 99.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for paftacular 1.4.0
File Interpreter ABI Platform
paftacular-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 148.8 kB

Release files / paftacular-1.4.0.tar.gz

Download URL paftacular-1.4.0.tar.gz
Size 99.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2b6904482f39ea519e1ed3bff2e71858310933722615234ee7b0edadcba47294
BLAKE2b-256 checksum
How to use checksums
9c391313b3138700b27ce467ad09abb24b850e579140b24bfacb5ed93cf00d80
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 / paftacular-1.4.0-py3-none-any.whl

Download URL paftacular-1.4.0-py3-none-any.whl
Size 49.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbe47080762d0420ccc7777042af080058e97186916763b9489f8f164cc24363
BLAKE2b-256 checksum
How to use checksums
fc032edc4f5aeeacd83ed3d400d9214cc5d59c2401680a288cc24b4cdd22f949
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

2.0.0

2 release files

This release

1.4.0 This release

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.0

2 release files

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