paftacular
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
PafAnnotationobjects. - Versioned JSON interchange (
to_dict/from_dict) for durable storage, alongside a compactas_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
- Full docs: paftacular.readthedocs.io
- Changelog: CHANGELOG.md
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.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| paftacular-1.3.2.tar.gz | 785.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| paftacular-1.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 832.3 kB
Release files / paftacular-1.3.2.tar.gz
| Download URL | paftacular-1.3.2.tar.gz |
|---|---|
| Size | 785.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7539f2cdd16b7fb3ae0fa82878bc6754f2e086b76be562e96e61a77a33cc111a
|
|
BLAKE2b-256 checksum How to use checksums |
83c972ac544a775656e31c6e54e8daf33fee42cfb94fd38c73055d80b7d96de5
|
| 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 23, 2026.
Transparency logRelease files / paftacular-1.3.2-py3-none-any.whl
| Download URL | paftacular-1.3.2-py3-none-any.whl |
|---|---|
| Size | 47.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58990553ebf46afa64139b6264ae80f36e323c7444b2416aa914f6b27e08c1cb
|
|
BLAKE2b-256 checksum How to use checksums |
ef8d31ffa871384da1205843be3287541d0c0332e66b4564202f618a6fe4d878
|
| 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 23, 2026.
Transparency log