Skip to main content

Python library for the PSI-MOD protein modification ontology

Project description

psimodpy

CI PyPI version Python License: MIT

Python library for parsing and querying the PSI-MOD protein modification ontology.

  • Zero dependencies
  • Bundled PSI-MOD data (2,116 entries) — works offline out of the box
  • Typed, immutable data models (py.typed / PEP 561)

Installation

pip install psimodpy

Or with uv:

uv add psimodpy

Requires Python 3.12+. No third-party dependencies.

Quick Start

import psimodpy

# Load the bundled PSI-MOD database
db = psimodpy.load()

# Lookup by ID
entry = db[46]  # O-phospho-L-serine
print(entry.name)       # "O-phospho-L-serine"
print(entry.diff_mono)  # 79.966331
print(entry.origin)     # AminoAcid.SER

# Lookup by name (case-insensitive)
entry = db.get_by_name("O-phospho-L-serine")

# Also accepts MOD:NNNNN format
entry = db.get_by_id("MOD:00046")

# Search across names, definitions, and synonyms
results = db.search("phospho")

# Find all modifications for an amino acid
ser_mods = db.get_by_origin("S")

# Filter entries
slim = db.filter(slim_only=True, include_obsolete=False)

# Formula parsing
print(entry.dict_diff_formula)      # {'C': 0, 'H': 0, 'N': 0, 'O': 3, 'P': 1}
print(entry.proforma_diff_formula)  # 'O3P'

API Overview

Loading

Function Description
psimodpy.load() Load the bundled PSI-MOD database.
psimodpy.load_from(path) Load from a custom OBO file.
psimodpy.parse_obo(path) Parse an OBO file into a database.
psimodpy.download_obo() Download the latest OBO file from GitHub.

PsiModDatabase

Method Description
db[id] Lookup by ID (int or "MOD:00046"), raises KeyError.
db.get_by_id(id) Lookup by ID, returns None if missing.
db.get_by_name(name) Case-insensitive name lookup.
db.search(query) Full-text search in names, definitions, synonyms.
db.get_by_origin(aa) Find entries by amino acid origin.
db.get_parents(entry) Direct parent entries (is_a hierarchy).
db.get_children(entry) Direct child entries.
db.get_related(entry, type) Follow relationship edges (derives_from, contains, etc.).
db.filter(...) Filter by obsolete/slim status.

PsiModEntry

Each entry provides: id, name, definition, synonyms, is_a, relationships, origin, diff_mono, diff_avg, diff_formula, mass_mono, mass_avg, formula, term_spec, source, formal_charge, xref_unimod, xref_uniprot_ptm, xref_gnome, xref_remap, in_slim_subset, is_obsolete.

Computed properties: dict_diff_formula, dict_formula, proforma_diff_formula.

Data Types

  • AminoAcid — single-letter amino acid codes
  • Crosslink — multi-residue or MOD-referenced origins
  • Synonym / SynonymType — typed synonyms
  • Relationship / RelationshipType — directed relationships
  • TermSpec — positional specificity
  • Source — modification origin

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
uniprotptmpy Parse and query the UniProt PTM controlled vocabulary

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

psimodpy-0.1.2.tar.gz (267.8 kB view details)

Uploaded Source

Built Distribution

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

psimodpy-0.1.2-py3-none-any.whl (264.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for psimodpy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7ecf438d35eb82e66d3b2ff13d662e2266a5410f196bbd532590874075850aad
MD5 4efd2722ff8a0ee13a63a641e8776d12
BLAKE2b-256 85c630c99caec21a5a296f07f7da6e245940bfe19529c34eeb4ef6f7d5cf69df

See more details on using hashes here.

Provenance

The following attestation bundles were made for psimodpy-0.1.2.tar.gz:

Publisher: release.yml on tacular-omics/psimodpy

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

File details

Details for the file psimodpy-0.1.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for psimodpy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eddf16354ea3312b164ddb4bb3284d15e96361ba47e442e9bb2f5fb7a4ec497c
MD5 05cbdd829a0d118acde57d84e08b0116
BLAKE2b-256 33e228304136eaf71ee18baddcc0247328c3afdb78095520c0b81f6da7fa1d89

See more details on using hashes here.

Provenance

The following attestation bundles were made for psimodpy-0.1.2-py3-none-any.whl:

Publisher: release.yml on tacular-omics/psimodpy

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