Python library for parsing UniProt XML data
Project description
uniprotlib
Note: This library was vibe coded with Claude. It works, it's tested, but review accordingly.
Python library for parsing UniProt XML files. Handles both single-entry downloads and multi-GB gzip-compressed database dumps with bounded memory usage.
Installation
pip install uniprotlib
Or with uv:
uv add uniprotlib
Usage
from uniprotlib import parse_xml
# single file
for entry in parse_xml("Q9Y261.xml"):
print(entry.primary_accession, entry.protein_name)
# gzipped bulk download
for entry in parse_xml("uniprot_sprot.xml.gz"):
print(entry.gene.primary, entry.organism.scientific_name)
# multiple files
for entry in parse_xml("human.xml.gz", "mouse.xml.gz"):
print(entry.primary_accession)
parse_xml() returns an iterator that yields UniProtEntry objects. Gzip detection is automatic based on the .gz extension. Memory stays bounded regardless of file size.
Parsed fields
| Model | Fields |
|---|---|
UniProtEntry |
primary_accession, accessions, entry_name, dataset, protein_name, gene, organism, sequence, keywords, db_references |
Gene |
primary, synonyms, ordered_locus_names, orf_names |
Organism |
scientific_name, common_name, tax_id, lineage |
Sequence |
value, length, mass, checksum |
DbReference |
type, id, molecule, properties |
All model classes are dataclasses with full type annotations and py.typed support.
Development
Requires Python >= 3.12 and uv.
uv sync
uv run pytest tests/ -v
License
MIT
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 uniprotlib-0.2.0.tar.gz.
File metadata
- Download URL: uniprotlib-0.2.0.tar.gz
- Upload date:
- Size: 93.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b06c0a0fcb533c41f9f23d8bc774ab059185f151c14037a5aacc5fa49780072a
|
|
| MD5 |
f5835078d7727163a8f134785815e1c7
|
|
| BLAKE2b-256 |
9ad9cb395465c719163bee53aff75bb8f35d6628fa664502d3b4e56304033dd3
|
Provenance
The following attestation bundles were made for uniprotlib-0.2.0.tar.gz:
Publisher:
publish.yml on mpreusse/uniprotlib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uniprotlib-0.2.0.tar.gz -
Subject digest:
b06c0a0fcb533c41f9f23d8bc774ab059185f151c14037a5aacc5fa49780072a - Sigstore transparency entry: 904897075
- Sigstore integration time:
-
Permalink:
mpreusse/uniprotlib@b57e39df6be844cac474ffc4296cfa4822f510ea -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/mpreusse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b57e39df6be844cac474ffc4296cfa4822f510ea -
Trigger Event:
push
-
Statement type:
File details
Details for the file uniprotlib-0.2.0-py3-none-any.whl.
File metadata
- Download URL: uniprotlib-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.6 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 |
030b7083232e9a0dc6a10a3b3bcc193dabbddde4f8b11d27f5d26b0aaffe77b6
|
|
| MD5 |
fcb80e31d949543825d29e2a0cb383d5
|
|
| BLAKE2b-256 |
ee28a16af47aa870800e8fa79f9fa93651defa0d5c733b60a1314a7efd7ace95
|
Provenance
The following attestation bundles were made for uniprotlib-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on mpreusse/uniprotlib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uniprotlib-0.2.0-py3-none-any.whl -
Subject digest:
030b7083232e9a0dc6a10a3b3bcc193dabbddde4f8b11d27f5d26b0aaffe77b6 - Sigstore transparency entry: 904897127
- Sigstore integration time:
-
Permalink:
mpreusse/uniprotlib@b57e39df6be844cac474ffc4296cfa4822f510ea -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/mpreusse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b57e39df6be844cac474ffc4296cfa4822f510ea -
Trigger Event:
push
-
Statement type: