HGVS Models
Public Python data model for parsed HGVS variants.
The package is split into:
tinyhgvs.models.corefor reference, coordinate-system, location, and certainty modelstinyhgvs.models.allelefor allele and allele-form modelstinyhgvs.models.cdnafor coding-DNA outcome modelstinyhgvs.models.nucleotidefor nucleotide coordinates, edits, and variantstinyhgvs.models.rnafor RNA outcome modelstinyhgvs.models.repeatfor repeat units and quantitiestinyhgvs.models.proteinfor protein coordinates, edits, and outcomes
Internal description aliases in this module are used for annotations only.
HgvsVariant
dataclass
HgvsVariant(reference: ReferenceSpec | None, coordinate_system: CoordinateSystem, description: _VariantDescription)
Top-level model describing a parsed HGVS variant.
This is the root object returned by tinyhgvs.parse_hgvs. It ties the
reference field, coordinate system, and parsed variant description together.
Attributes:
| Name | Type | Description |
|---|---|---|
reference |
ReferenceSpec | None
|
Reference sequence field preceding the |
coordinate_system |
CoordinateSystem
|
HGVS coordinate type. |
description |
_VariantDescription
|
Model describing a nucleotide or protein variant. |
Examples:
A coding DNA splice-site substitution parsed into reference, location, and edit models:
>>> from tinyhgvs import parse_hgvs
>>> variant = parse_hgvs("NM_004006.2:c.357+1G>A")
>>> variant.reference.primary.id
'NM_004006.2'
>>> variant.coordinate_system.value
'c'
>>> variant_description = variant.description
>>> variant_location = variant_description.location
>>> variant_location.start.coordinate
357
>>> variant_location.start.offset
1
>>> variant_location.start.anchor
<NucleotideAnchor.ABSOLUTE: 'absolute'>
>>> variant_location.end is None
True
>>> variant_description.reference
'G'
>>> variant_description.alternate
'A'
A 5' UTR substitution keeps the signed coordinate from the HGVS string:
>>> utr = parse_hgvs("NM_007373.4:c.-1C>T")
>>> utr.description.location.start.coordinate
-1
>>> utr.description.location.start.is_five_prime_utr
True
A protein frameshift is still exposed through the same top-level variant container:
>>> protein = parse_hgvs("NP_0123456.1:p.Arg97ProfsTer23")
>>> protein.description.edit.is_frameshift
True
>>> protein.description.edit.to_residue
'Pro'