Skip to main content

mzpaf parser

Project description

paftacular

Paftacular Logo

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 Documentation Status PyPI version Python 3.12+ License: MIT

Features

  • mzPAF parsing: Handles parsing / serializing of mzPAF strings
  • Properties: Supports calculating mass and composition of annotated ions
  • Type-Annotations: typed.py file for static type checking
  • Caching: serialization and parsing results are cached for performance (when applicable)
  • Peptacular: Optionally integrated with peptacular to enable parsing of included sequences and generation of mzPAF annotations

Installation

   pip install paftacular
   pip install paftacular[peptacular] # with peptacular integration
   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)  # y
print(ann.ion_type.position)  # 5

# Calculate masses
print(ann.mass())              # Monoisotopic mass by default
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-1.1.0.tar.gz (569.8 kB view details)

Uploaded Source

Built Distribution

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

paftacular-1.1.0-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for paftacular-1.1.0.tar.gz
Algorithm Hash digest
SHA256 768f2bdf2ab3b8ef59a6f74a66750d9e7dfd9fd983e562ec9807fa8b2818daa9
MD5 930ec69a4e01d022be658990cd4ac16d
BLAKE2b-256 1638437d0f539636e5a811832f293f8d68d4559e5777429f4b4cd5a0545b95c3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for paftacular-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af1409995ddf15b16f906f4dc4081e37a8f090dec35045f85decc809ac5b706e
MD5 496dc2c47eb7cc0ab2ec4f82547fc555
BLAKE2b-256 692e97ac23f8357297c40dd7ce64ef7888b7ec2a217ff74f5102c320755c8021

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