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 an exact repeat:

from tinyhgvs import parse_hgvs

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

Parse a protein frameshift consequence:

from tinyhgvs import parse_hgvs

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

Inspect an unsupported syntax error:

from tinyhgvs import TinyHGVSError, parse_hgvs

try:
    parse_hgvs("NP_003997.1:p.[Lys31Asn,Val25_Lys31del]")
except TinyHGVSError as error:
    print(error.code)
    print(error.fragment)