gnomad-api-cache
Fetch gnomAD annotations for the variants in a VCF, cache them in SQLite, and export to various output formats (parquet, csv, tsv, json).
The public gnomAD API allows roughly 10 requests (of 25 variants each) per minute. Annotating a cohort twice — or exporting a second format — fetches from the locally built cache rather than requerying.
Re-running into an existing cache fetches only what is missing.
Install
pip install gnomad-api-cache
# or with uv
uv pip install gnomad-api-cache # into the active environment
uv add gnomad-api-cache # into a project
uv tool install gnomad-api-cache # just the CLI
Requires Python 3.11 or newer.
Usage
Command line
Inputs are any VCF-like file (VCF, BCF, or bgzipped VCF) and a SQLite database to store the cache. The output retrieves all variants from the cache and writes them to a file in the specified format.
gnomad-api-cache -i cohort.vcf.gz -c gnomad.sqlite -o annotations.parquet
The output format is inferred from the file extension (.csv, .tsv,
.parquet, .json, .jsonl) and can be forced with -f:
gnomad-api-cache -i cohort.vcf.gz -c gnomad.sqlite -o annotations.txt -f tsv
Omit -o to populate the cache without writing a table:
gnomad-api-cache -i cohort.vcf.gz -c gnomad.sqlite
python -m gnomad_api_cache accepts the same arguments. Run
gnomad-api-cache --help for the full list, including --dataset,
--include-populations, and --require-build.
Python
from gnomad_api_cache import VariantCache
with VariantCache("gnomad.sqlite") as cache:
summary = cache.fetch_vcf("cohort.vcf.gz")
print(summary) # 1234 requested, 0 already cached, 1200 fetched, ...
cache.to_parquet("annotations.parquet")
cache.to_csv("annotations.csv")
Pass a filter_function(cyvcf2.Variant) -> bool to decide which variants are worth querying:
from cyvcf2 import Variant
from gnomad_api_cache import VariantCache
def rare_only(variant: Variant) -> bool:
af = variant.INFO.get("gnomad41_exome_AF", 0)
return float(0 if af == "." else af) <= 0.05
with VariantCache("gnomad.sqlite") as cache:
cache.fetch_vcf("cohort.vcf.gz", filter_function=rare_only)
An open cache is a read-only Mapping keyed by chrom-pos-ref-alt, so cached
records are available without another request:
record = cache["1-55051215-G-A"] # None if gnomAD has no such variant
print(len(cache), cache.status_counts())
Acknowledgement & Citation
This is an unofficial client. It queries the public gnomAD GraphQL API at https://gnomad.broadinstitute.org/api and is not affiliated with or endorsed by the Broad Institute or the gnomAD project. Please use the shared API considerately — the default delay between requests is set to stay within the documented rate limit.
If you use gnomAD data obtained through this tool, cite the current flagship gnomAD paper. As of the latest release, it is as follows (v4 Preprint, Vancouver):
Guez J, Goodrich JK, Moldovan MA, Chao KR, Kar P, Panchal R, Wilson MW, Laricchia KM, Rohlicek G, Biba D, Marten D. Integrating 730,947 exome sequences with clinical literature improves gene discovery. Medrxiv. 2026 Mar 25. https://doi.org/10.64898/2026.03.23.26349081
gnomAD data use terms: https://gnomad.broadinstitute.org/terms
License
MIT — see LICENSE.
Metadata
Release files for gnomad-api-cache 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gnomad_api_cache-0.1.0.tar.gz | 33.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gnomad_api_cache-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 57.4 kB
Release files / gnomad_api_cache-0.1.0.tar.gz
| Download URL | gnomad_api_cache-0.1.0.tar.gz |
|---|---|
| Size | 33.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
926423305ac457c5f1f39207799acc1ce2e6e67d91140a9dc0e57d2421710e2e
|
|
BLAKE2b-256 checksum How to use checksums |
5af0981be1329df5418a5452d8ccc3864b3eac4c56b067706de4822ccd9e3e6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.
Transparency logRelease files / gnomad_api_cache-0.1.0-py3-none-any.whl
| Download URL | gnomad_api_cache-0.1.0-py3-none-any.whl |
|---|---|
| Size | 24.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e22ccbb6cb331e24fc59280b1c5378a8c448cebbe97acf79bcf216afd2094440
|
|
BLAKE2b-256 checksum How to use checksums |
9b012491385c7d92f78dc6d84206dad80c5fd30880fe60c37f0c71d03a4e6ce8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.
Transparency log