Skip to content

tinyhgvs

PyPI Python Versions CI License crates.io docs.rs

tinyhgvs is a lightweight HGVS parsing library with a Rust core and a Python API. The project focuses on a small but expandable data model, clear error diagnostics for unsupported syntax, and parity between the Rust and Python surfaces.

Installation

tinyhgvs can be installed directly from PyPI:

pip install tinyhgvs

Local deployment

For local development of the Python package:

cd py-tinyhgvs
uv run maturin develop

Quick Examples

Parse a coding DNA substitution:

from tinyhgvs import parse_hgvs

variant = parse_hgvs("NM_004006.2:c.357+1G>A")
print(variant.coordinate_system.value)
print(variant.description.edit)

Parse a repeat:

from tinyhgvs import parse_hgvs

variant = parse_hgvs("NM_004006.3:r.-124_-123[14]")
print(variant.description.edit.sequence[0].quantity.count)

Parse a protein frameshift consequence:

from tinyhgvs import parse_hgvs

variant = parse_hgvs("NP_0123456.1:p.Arg97ProfsTer23")
print(variant.description.edit.to_residue)
print(variant.description.edit.stop.ordinal)

Inspect an unsupported syntax error:

from tinyhgvs import TinyHGVSError, parse_hgvs

try:
    parse_hgvs("NC_000023.11:g.pter_qtersup")
except TinyHGVSError as error:
    print(error.code)
    print(error.fragment)