Quickstart

Install paftacular with pip install paftacular (see Installation for extras).

There are two parsing functions:

  • parse: Parses exactly one mzPAF annotation and returns a PafAnnotation. Raises PafParseError for zero or several annotations.

  • parse_multi: Parses comma-separated mzPAF annotations. Always returns a list of PafAnnotation.

Every error caused by bad input is a PaftacularError (a ValueError).

import paftacular as pft

# Parse a simple peptide ion
ann = pft.parse("y5")
print(ann.ion_type.series)
print(ann.ion_type.position)
y
5
# Parse with modifications
ann = pft.parse("y5-H2O^2/1.2ppm*0.95")
print(ann.charge)
print(ann.mass_error.value)
print(ann.confidence)
2
1.2
0.95

Compute the mass of an annotated ion. Without a sequence, get_mass() is the ion offset only, and mz() needs a sequence (embedded or from resolve()):

ann = pft.parse("y5")
print(ann.get_mass())
19.017841150651

Serialize back to mzPAF:

print(pft.parse("y5-H2O^2").serialize())
y5-H2O^2

Next, read Usage for every ion type, modifications, isotopes, adducts and the peptacular integration.