Skip to main content

mzpaf parser

Project description

paftacular

Paftacular Logo

paftacular

A Python library for parsing and serializing mzPAF (Peak Annotation Format), a standardized format for annotating mass spectrometry fragment ions in peptide/proteomics analysis. mzPAF is a specification from the Proteomics Standards Initiative (PSI) that provides a compact, human-readable notation for describing fragment ion types, chemical modifications, charge states, mass errors, and confidence scores.

Python package codecov PyPI version Python 3.12+ License: MIT

Features

  • Parse and serialize mzPAF annotations with full specification support
  • Handle fragment ions, neutral losses, isotopes, adducts, charge states, mass errors, and confidence scores
  • Calculate monoisotopic and average masses with elemental composition tracking
  • Type-safe with comprehensive type hints and dataclasses

Installation

   pip install paftacular
   pip install paftacular[sequence] # for peptide sequence support
   pip install paftacular[smiles] # with smiles support
   pip install paftacular[all] # with all optional dependencies

Quick Start

There are 3 parsing methods available:

  • parse: Parses a single or multiple comma-separated mzPAF annotations. Returns a single PafAnnotation or a list of them.
  • parse_multi: Parses multiple comma-separated mzPAF annotations. Always returns a list of PafAnnotation.
  • parse_single: Parses a single mzPAF annotation. Returns a single PafAnnotation. Raises ValueError if multiple annotations are provided.
import paftacular as pft

# Parse a simple peptide ion
ann = pft.parse("y5")
print(ann.ion_type.series)  # IonSeries.Y
print(ann.ion_type.position)  # 5

# Calculate masses
print(ann.monoisotopic_mass)   # Calculated mass
print(ann.serialize())         # Round-trip back to string

# Parse multiple ions
anns = pft.parse("y5-H2O^2/1.2ppm*0.95,b3^2")
for ann in anns:
  print(ann.charge)
  print(ann.mass_error.value)
  print(ann.confidence)

Documentation

Full documentation is available at Read the Docs.

mzPAF Format

The mzPAF format uses compact notation:

[&][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.

License

MIT

Contributing

Contributions welcome! Please submit a Pull Request.

Author: Patrick Garrett (pgarrett@scripps.edu)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paftacular-0.1.0.tar.gz (509.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paftacular-0.1.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file paftacular-0.1.0.tar.gz.

File metadata

  • Download URL: paftacular-0.1.0.tar.gz
  • Upload date:
  • Size: 509.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for paftacular-0.1.0.tar.gz
Algorithm Hash digest
SHA256 deab03460ebb0af9e17fa02e93b53b137721bd960cf7dd2ce1fccd9e446b8128
MD5 bbb876c97829a2ca71ba3c341e730304
BLAKE2b-256 a987b67bb7809cc619038d33ff4f947e36ad98285d5b0d143cb441c7c43cdc29

See more details on using hashes here.

File details

Details for the file paftacular-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: paftacular-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for paftacular-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de78b23e152d3780d306c1f40a0eee82908993a0f451e26b3849adf0aea16ac0
MD5 b2d48555df72fd45223a8b1a48d7c02b
BLAKE2b-256 00905c69d75d5657e02e21eac06da6f8c73f0d8a347e493c6fc11b355c13ecc8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page