Skip to main content

Python library for parsing and querying the UniProt PTM controlled vocabulary list.

Project description

uniprotptmpy

CI PyPI version Python License: MIT

Python library for parsing and querying the UniProt post-translational modification (PTM) controlled vocabulary.

  • Zero dependencies
  • Bundled PTM data (748 entries) — works offline out of the box
  • Typed, immutable data models (py.typed / PEP 561)

Installation

pip install uniprotptmpy

Or with uv:

uv add uniprotptmpy

Requires Python 3.12+. No third-party dependencies.

Quick Start

from uniprotptmpy import load

# Load the bundled PTM database
db = load()
print(len(db))  # 748

# Look up by accession
entry = db.get_by_id("PTM-0450")
print(entry.name)  # (2-aminosuccinimidyl)acetic acid (Asn-Gly)

# Look up by name (case-insensitive)
entry = db.get_by_name("phosphoserine")
print(entry.id)  # PTM-0253

# Free-text search across name, ID, target, and keywords
results = db.search("acetylation")

# Dict-style access (raises KeyError if not found)
entry = db["PTM-0450"]

# Iterate all entries
for entry in db:
    print(entry.id, entry.name)

Chemical Formulas

entry = db.get_by_id("PTM-0476")  # 3-hydroxyproline
print(entry.correction_formula)   # O1
print(entry.dict_composition)     # {'O': 1}
print(entry.proforma_formula)     # O

Downloading the Latest Data

from uniprotptmpy import download, load

path = download()   # downloads to ~/.cache/uniprotptmpy/ptmlist.txt
db = load(path)     # load from the downloaded file

API Overview

Symbol Description
load(source=None) Load the PTM database. Uses bundled data by default.
download(dest=None) Download the latest ptmlist.txt from UniProt FTP.
parse_ptm_list(path) Parse a ptmlist.txt file into a PtmDatabase.
PtmDatabase Indexed collection with get_by_id(), get_by_name(), search(), iteration, and len().
PtmEntry Frozen dataclass with all PTM fields, plus dict_composition and proforma_formula properties.
FeatureType StrEnum: CROSSLNK, MOD_RES, LIPID, CARBOHYD, DISULFID.
CrossReference Frozen dataclass with database and accession fields.
TaxonomicRange Frozen dataclass with taxon_name, tax_id, description, and raw fields.

Development

just install   # install dependencies with uv
just lint      # ruff check
just format    # ruff format
just ty        # ty type check
just test      # pytest
just check     # lint + type check + test

Related Projects

Package Description
unimodpy Parse and query the UNIMOD mass spectrometry modifications database
psimodpy Parse and query the PSI-MOD protein modification ontology

License

MIT

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

uniprotptmpy-0.1.0.tar.gz (40.6 kB view details)

Uploaded Source

Built Distribution

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

uniprotptmpy-0.1.0-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for uniprotptmpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1123d59627d9718adf5fbfb9ca2bbe72ba2b5c982c8b414b319b6f8d3549d073
MD5 b2ee1914e7cc80ab4a35e0645bd3039c
BLAKE2b-256 717b4c9403fa5cc2fc5523001d9c43a458c55452bde26504512fa4728781a9be

See more details on using hashes here.

Provenance

The following attestation bundles were made for uniprotptmpy-0.1.0.tar.gz:

Publisher: release.yml on tacular-omics/uniprotptmpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

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

File hashes

Hashes for uniprotptmpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60b3f91edc96745e8fefcd12180eb5b6e9a149fcd8b68b070af35026cd4b56db
MD5 bc9d56bbdabe44663f2df2e8b6ff3dda
BLAKE2b-256 dbede7593d125eaaf19f493674139eb8996f2461e90bebb821e2ce367aed6c36

See more details on using hashes here.

Provenance

The following attestation bundles were made for uniprotptmpy-0.1.0-py3-none-any.whl:

Publisher: release.yml on tacular-omics/uniprotptmpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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