HGVS
raw JSON → 1.5.7 verified Fri May 01 auth: no python
HGVS (Human Genome Variation Society) nomenclature parser, formatter, validator, and mapper. Version 1.5.7 supports Python >=3.10. Released irregularly, with recent focus on selenocysteine support and bug fixes.
pip install hgvs Common errors
error AttributeError: 'UTA_postgresql' object has no attribute '_pool' ↓
cause Outdated psycopg2 or missing pool module; fixed in 1.5.5.
fix
Upgrade hgvs to >=1.5.5 or install psycopg2-binary.
error ValueError: Could not find a data provider; set UTA_DB_URL or provide connection ↓
cause No database connection configured.
fix
Set environment variable UTA_DB_URL or pass url to hgvs.dataproviders.uta.connect().
error hgvs.exceptions.HGVSParseError: Expected '>' at position ... ↓
cause Malformed variant string (e.g., missing allele after '>').
fix
Verify the variant string conforms to HGVS syntax; e.g., 'NM_000551.3:c.101T>A'.
Warnings
deprecated hgvs.dataproviders.uta.connect() uses an environment-based connection string; UTA_DB_URL must be set. ↓
fix Set environment variable UTA_DB_URL or use hgvs.dataproviders.uta.connect(url='postgresql://...')
breaking In version 1.5.7, selenocysteine support changed protein translation for variants in selenocysteine-encoding transcripts (UGA codon). Existing code relying on prior behavior may produce different protein HGVS strings. ↓
fix Review and update expected protein variant strings for transcripts with selenocysteine.
gotcha hgvs requires a sequence data provider (e.g., UTA or seqrepo) for mapping operations. Without one, c_to_t, etc. will fail. ↓
fix Ensure a data provider is configured via environment variables or explicitly passed.
gotcha UTA database credentials may be URL-encoded; decoding is fixed in 1.5.8rc1, but 1.5.7 may fail if UTA_DB_URL contains percent-encoded characters. ↓
fix Upgrade to 1.5.8rc1 or pass raw (non-encoded) credentials.
Imports
- parser
import hgvs.parser - variantmapper
import hgvs.variantmapper - SequenceVariant wrong
import hgvs.SequenceVariantcorrectfrom hgvs.sequencevariant import SequenceVariant
Quickstart
import hgvs.parser
import hgvs.dataproviders.uta
# Initialize parser
hp = hgvs.parser.Parser()
# Parse an HGVS variant string
var = hp.parse_hgvs_variant('NM_000551.3:c.101T>A')
print(var) # SequenceVariant(...)
# For mapping, need a data provider (e.g., UTA)
# hdp = hgvs.dataproviders.uta.connect()
# vm = hgvs.variantmapper.VariantMapper(hdp)
# t_vm = vm.c_to_t(var)
# print(t_vm)