hgvs - manipulate biological sequence variants according to Human Genome Variation Society recommendations
The hgvs package provides a Python library to parse, format, validate, normalize, and map sequence variants according to Variation Nomenclature (aka Human Genome Variation Society) recommendations.
Specifically, the hgvs package focuses on the subset of the HGVS recommendations that precisely describe sequence-level variation relevant to the application of high-throughput sequencing to clinical diagnostics. The package does not attempt to cover the full scope of HGVS recommendations. Please refer to issues for limitations.
- Parsing is based on formal grammar.
- An easy-to-use object model that represents most variant types (SNVs, indels, dups, inversions, etc) and concepts (intronic offsets, uncertain positions, intervals)
- A variant normalizer that rewrites variants in canonical forms and substitutes reference sequences (if reference and transcript sequences differ)
- Formatters that generate HGVS strings from internal representations
- Tools to map variants between genome, transcript, and protein sequences
- Reliable handling of regions genome-transcript discrepancies
- Pluggable data providers support alternative sources of transcript mapping data
- Extensive automated tests, including those for all variant types and "problematic" transcripts
- Easily installed using remote data sources. Installation with local data sources is straightforward and completely obviates network access
Wang M, Callenberg KM, Dalgleish R, Fedtsov A, Fox N, Freeman PJ, et al.
hgvs: A Python package for manipulating sequence variants using HGVS nomenclature: 2018 Update.
Hum Mutat. 2018. doi:10.1002/humu.23615
- You are encouraged to browse issues. All known issues are listed there. Please report any issues you find.
- Use a pip package specification to stay within minor releases.
For example,
hgvs>=1.5,<1.6. hgvs uses Semantic Versioning.
Important: For more detailed installation and configuration instructions, see the HGVS readthedocs
libpq
python3
postgresql
Examples for installation:
MacOS :
brew install libpq
brew install python3
brew install postgresql
Ubuntu :
sudo apt install gcc libpq-dev python3-dev
By default, hgvs uses remote data sources, which makes installation easy. If you would like to use local instances of the data sources, see the readthedocs.
-
Create a virtual environment using your preferred method.
Example:
python3 -m venv venv -
Run the following commands in your virtual environment:
source venv/bin/activate pip install --upgrade setuptools pip install hgvs
See Installation instructions for details, including instructions for installing Universal Transcript Archive (UTA) and SeqRepo locally.
See examples and readthedocs for usage.
The hgvs package is a community effort. Please see Contributing to get started in submitting source code, tests, or documentation. Thanks for getting involved!
These tools are required to get started:
- git: Version control system
- GNU make: Current mechanism for consistent invocation of developer tools.
- uv: An extremely fast Python package and project manager, written in Rust.
- Install brew
brew install git make uv
You may also install using distribution packages:
sudo apt install git make
Then install uv using the uv installation instructions.
Create a Python virtual environment, install dependencies, install pre-commit hooks, and install an editable package:
make devready
N.B. Developers are expected to use make to invoke tools to
ensure consistency with the CI/CD pipelines. Type make to see a list of
supported targets. A subset are listed here:
Β» make
ππ biocommons conventional make targets ππ
Using these targets promots consistency between local development and ci/cd commands.
usage: make [target ...]
BASIC USAGE
help Display help message
SETUP, INSTALLATION, PACKAGING
devready Prepare local dev env: Create virtual env, install the pre-commit hooks
build Build package
publish publish package to PyPI
FORMATTING, TESTING, AND CODE QUALITY
cqa Run code quality assessments
test Test the code with pytest
DOCUMENTATION
docs-serve Build and serve the documentation
docs-test Test if documentation can be built without warnings or errors
CLEANUP
clean Remove temporary and backup files
cleaner Remove files and directories that are easily rebuilt
cleanest Remove all files that can be rebuilt
distclean Remove untracked files and other detritus
Existing tests use a cache that is committed with the repo to ensure that tests do not require external networking. To develop new tests, which requires loading the cache, you should install UTA and Seqrepo (and the rest service) locally.
docker compose --project-name biocommons -f ./misc/docker-compose.yml up
IMPORTANT: Loading the test caches is currently hampered by
#551,
#760, and
#761. To load reliably, use
make test-relearn-iteratively for now.