{"id":49643416,"url":"https://github.com/tacular-omics/uniprotptmpy","last_synced_at":"2026-05-05T21:39:20.447Z","repository":{"id":353655330,"uuid":"1194002663","full_name":"tacular-omics/uniprotptmpy","owner":"tacular-omics","description":"Python library for parsing and querying the UniProt post-translational modification (PTM) controlled vocabulary.","archived":false,"fork":false,"pushed_at":"2026-04-28T17:32:40.000Z","size":144,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-05T21:39:14.753Z","etag":null,"topics":["omics","ontology","peptide","protein","proteomics","ptm","uniprot"],"latest_commit_sha":null,"homepage":"https://tacular-omics.github.io/uniprotptmpy/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tacular-omics.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-27T20:11:39.000Z","updated_at":"2026-04-27T01:07:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/tacular-omics/uniprotptmpy","commit_stats":null,"previous_names":["tacular-omics/uniprotptmpy"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/tacular-omics/uniprotptmpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacular-omics%2Funiprotptmpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacular-omics%2Funiprotptmpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacular-omics%2Funiprotptmpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacular-omics%2Funiprotptmpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tacular-omics","download_url":"https://codeload.github.com/tacular-omics/uniprotptmpy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tacular-omics%2Funiprotptmpy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32669433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["omics","ontology","peptide","protein","proteomics","ptm","uniprot"],"created_at":"2026-05-05T21:39:17.106Z","updated_at":"2026-05-05T21:39:20.436Z","avatar_url":"https://github.com/tacular-omics.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# uniprotptmpy\n\n[![CI](https://github.com/tacular-omics/uniprotptmpy/actions/workflows/ci.yml/badge.svg)](https://github.com/tacular-omics/uniprotptmpy/actions/workflows/ci.yml)\n[![PyPI version](https://img.shields.io/pypi/v/uniprotptmpy)](https://pypi.org/project/uniprotptmpy/)\n[![Python](https://img.shields.io/pypi/pyversions/uniprotptmpy)](https://pypi.org/project/uniprotptmpy/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\nPython library for parsing and querying the [UniProt post-translational modification (PTM) controlled vocabulary](https://ftp.uniprot.org/pub/databases/uniprot/current_release/knowledgebase/complete/docs/ptmlist.txt).\n\n- Zero core dependencies\n- Bundled PTM data (748 entries) — works offline out of the box\n- Typed, immutable data models (`py.typed` / PEP 561)\n- TSV/CSV export and round-trip `ptmlist.txt` writer\n- Optional FastAPI / [Model Context Protocol](https://modelcontextprotocol.io) server (`pip install uniprotptmpy[server]`)\n\n## Online Viewer\n#### [Click Me!](https://tacular-omics.github.io/uniprotptmpy/)\n\nThe same database is also reachable as a hosted REST + MCP service — see\n[HTTP API and MCP Server](#http-api-and-mcp-server) below.\n\n\n## Installation\n\n```bash\npip install uniprotptmpy\n```\n\nOr with [uv](https://docs.astral.sh/uv/):\n\n```bash\nuv add uniprotptmpy\n```\n\nRequires Python 3.12+. No third-party dependencies.\n\n## Quick Start\n\n```python\nfrom uniprotptmpy import load\n\n# Load the bundled PTM database\ndb = load()\nprint(len(db))  # 748\n\n# Look up by accession\nentry = db.get_by_id(\"PTM-0450\")\nprint(entry.name)  # (2-aminosuccinimidyl)acetic acid (Asn-Gly)\n\n# Look up by name (case-insensitive)\nentry = db.get_by_name(\"phosphoserine\")\nprint(entry.id)  # PTM-0253\n\n# Free-text search across name, ID, target, and keywords\nresults = db.search(\"acetylation\")\n\n# Dict-style access (raises KeyError if not found)\nentry = db[\"PTM-0450\"]\n\n# Iterate all entries\nfor entry in db:\n    print(entry.id, entry.name)\n```\n\n### Chemical Formulas\n\n```python\nentry = db.get_by_id(\"PTM-0476\")  # 3-hydroxyproline\nprint(entry.correction_formula)   # O1\nprint(entry.dict_composition)     # {'O': 1}\nprint(entry.proforma_formula)     # O\n```\n\n### Exporting to TSV/CSV\n\n```python\n# Write all entries to a tab-separated file\ndb.write_tsv(\"ptms.tsv\")\n\n# Or CSV\ndb.write_tsv(\"ptms.csv\", delimiter=\",\")\n\n# Standalone function also available\nfrom uniprotptmpy import write_tsv\nwrite_tsv(db, \"ptms.tsv\")\n```\n\n### Writing back to ptmlist.txt format\n\n```python\n# Round-trip: write entries back to the original UniProt flat-file format\ndb.write_ptmlist(\"out/ptmlist.txt\")\n\n# Re-parse the written file — identical entry count and field values\nfrom uniprotptmpy import parse_ptm_list\ndb2 = parse_ptm_list(\"out/ptmlist.txt\")\n\n# Standalone function\nfrom uniprotptmpy import write_ptmlist\nwrite_ptmlist(db, \"out/ptmlist.txt\")\n```\n\n### Downloading the Latest Data\n\n```python\nfrom uniprotptmpy import download, load\n\npath = download()   # downloads to ~/.cache/uniprotptmpy/ptmlist.txt\ndb = load(path)     # load from the downloaded file\n```\n\n## HTTP API and MCP Server\n\nThe optional `[server]` extra ships a FastAPI app that exposes the same\ndatabase over a JSON REST API *and* over the\n[Model Context Protocol](https://modelcontextprotocol.io) so language-model\ntools can query the UniProt PTM vocabulary directly.\n\n```bash\npip install uniprotptmpy[server]\nuvicorn uniprotptmpy.server.app:app --reload\n```\n\n### REST endpoints\n\n| Method \u0026 path | Returns |\n|---------------|---------|\n| `GET /api/health` | Service metadata and entry count. |\n| `GET /api/entries?limit=\u0026offset=` | Paginated full entries. |\n| `GET /api/entries/{id}` | One full entry by accession (`PTM-0450` or `0450`). |\n| `GET /api/entries/by-name/{name}` | One full entry by exact name. |\n| `GET /api/search?q=\u0026limit=` | Search hits as lightweight summaries. |\n\nSearch responses contain just `{id, name, feature_type, target,\nmonoisotopic_mass}` to keep token cost low; call `/api/entries/{id}` on any\nhit for the full record (including taxonomic ranges and cross-references).\n\n### MCP server\n\nThe same FastAPI app mounts an MCP endpoint at `POST /mcp` with three tools:\n\n| Tool | Purpose |\n|------|---------|\n| `get_by_id(id)` | Look up a single PTM by accession. |\n| `get_by_name(name)` | Exact name lookup. |\n| `search(query, limit=25)` | Free-text search returning summaries. |\n\nTool responses use MCP's structured-output mechanism: the server emits an\n`outputSchema` per tool in `tools/list` and returns both `structuredContent`\n(typed Pydantic instance) and `content` (text fallback) on `tools/call`, so\nLLM clients can parse the response without re-reading the JSON string.\n\nConfigure your MCP-aware client to point at `http://localhost:8000/mcp`\n(or wherever you deploy the app). Example with the Anthropic CLI:\n\n```bash\nclaude mcp add uniprot-ptm http://localhost:8000/mcp --transport http\n```\n\n## API Overview\n\n| Symbol | Description |\n|--------|-------------|\n| `load(source=None)` | Load the PTM database. Uses bundled data by default. |\n| `download(dest=None)` | Download the latest ptmlist.txt from UniProt FTP. |\n| `parse_ptm_list(path)` | Parse a ptmlist.txt file into a `PtmDatabase`. |\n| `write_tsv(entries, path, *, delimiter)` | Write entries to a TSV (or CSV) file. |\n| `write_ptmlist(entries, path)` | Write entries back to UniProt ptmlist.txt flat-file format. |\n| `PtmDatabase` | Indexed collection with `get_by_id()`, `get_by_name()`, `search()`, `write_tsv()`, `write_ptmlist()`, iteration, and `len()`. |\n| `PtmEntry` | Frozen dataclass with all PTM fields, plus `dict_composition` and `proforma_formula` properties. |\n| `FeatureType` | StrEnum: `CROSSLNK`, `MOD_RES`, `LIPID`, `CARBOHYD`, `DISULFID`. |\n| `CrossReference` | Frozen dataclass with `database` and `accession` fields. |\n| `TaxonomicRange` | Frozen dataclass with `taxon_name`, `tax_id`, `description`, and `raw` fields. |\n\n## Development\n\n```bash\njust install   # install dependencies with uv\njust lint      # ruff check\njust format    # ruff format\njust ty        # ty type check\njust test      # pytest\njust check     # lint + type check + test\n```\n\n## Related Projects\n\n| Package | Description |\n|---------|-------------|\n| [unimodpy](https://github.com/tacular-omics/unimodpy) | Parse and query the UNIMOD mass spectrometry modifications database |\n| [psimodpy](https://github.com/tacular-omics/psimodpy) | Parse and query the PSI-MOD protein modification ontology |\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftacular-omics%2Funiprotptmpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftacular-omics%2Funiprotptmpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftacular-omics%2Funiprotptmpy/lists"}