Python library for parsing and querying the UniProt PTM controlled vocabulary list.
Project description
uniprotptmpy
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1123d59627d9718adf5fbfb9ca2bbe72ba2b5c982c8b414b319b6f8d3549d073
|
|
| MD5 |
b2ee1914e7cc80ab4a35e0645bd3039c
|
|
| BLAKE2b-256 |
717b4c9403fa5cc2fc5523001d9c43a458c55452bde26504512fa4728781a9be
|
Provenance
The following attestation bundles were made for uniprotptmpy-0.1.0.tar.gz:
Publisher:
release.yml on tacular-omics/uniprotptmpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uniprotptmpy-0.1.0.tar.gz -
Subject digest:
1123d59627d9718adf5fbfb9ca2bbe72ba2b5c982c8b414b319b6f8d3549d073 - Sigstore transparency entry: 1189509065
- Sigstore integration time:
-
Permalink:
tacular-omics/uniprotptmpy@9fcd0dd534e13240d8de09e089a685d0dc5b7810 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/tacular-omics
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9fcd0dd534e13240d8de09e089a685d0dc5b7810 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b3f91edc96745e8fefcd12180eb5b6e9a149fcd8b68b070af35026cd4b56db
|
|
| MD5 |
bc9d56bbdabe44663f2df2e8b6ff3dda
|
|
| BLAKE2b-256 |
dbede7593d125eaaf19f493674139eb8996f2461e90bebb821e2ce367aed6c36
|
Provenance
The following attestation bundles were made for uniprotptmpy-0.1.0-py3-none-any.whl:
Publisher:
release.yml on tacular-omics/uniprotptmpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uniprotptmpy-0.1.0-py3-none-any.whl -
Subject digest:
60b3f91edc96745e8fefcd12180eb5b6e9a149fcd8b68b070af35026cd4b56db - Sigstore transparency entry: 1189509066
- Sigstore integration time:
-
Permalink:
tacular-omics/uniprotptmpy@9fcd0dd534e13240d8de09e089a685d0dc5b7810 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/tacular-omics
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9fcd0dd534e13240d8de09e089a685d0dc5b7810 -
Trigger Event:
release
-
Statement type: