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.2.tar.gz (40.8 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.2-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: uniprotptmpy-0.1.2.tar.gz
  • Upload date:
  • Size: 40.8 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.2.tar.gz
Algorithm Hash digest
SHA256 f2302bdd1feceb79e066031115654026b7e01233ebdcca941313c6f0171c8c29
MD5 f99d5a9186c46a8a62067dcb164ddf2d
BLAKE2b-256 b25599b062bc7f53d85e60555372f2bf8810039a10b509cde3f33660de21e77d

See more details on using hashes here.

Provenance

The following attestation bundles were made for uniprotptmpy-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: uniprotptmpy-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4bab54c55ddd447ad5e7aabaf7ef2a7362e3b52948a380f146c5f8bffb8a775c
MD5 79b2a368e429d55e25e4fdeff9b94afa
BLAKE2b-256 7ff5cfa2549bf7563489250a1c47621ab0612a198607b745230857498931b520

See more details on using hashes here.

Provenance

The following attestation bundles were made for uniprotptmpy-0.1.2-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