Skip to main content

Cache-based VCF annotation accelerator

Project description

VCFcache – Cache once, annotate fast

Cache common variants once, reuse them for every sample. VCFcache builds a normalized blueprint, annotates it once, and reuses those results so only rare/novel variants are annotated at runtime.


What’s new

  • Single lean Docker image: ghcr.io/julius-muller/vcfcache:<version>
  • Caches/blueprints live on Zenodo and are resolved by alias via public_caches.yaml
  • Alias schema:
    • Blueprint: bp-<genome>-<source>-<release>-<filt>
    • Cache: cache-<genome>-<source>-<release>-<filt>-<tool>-<tool_version>-<preset>
  • Manifest entries carry version (vcfcache version used), no image tags
  • Bundled bcftools 1.22; no Nextflow/JVM required

Quick start (pip install)

Requirements: Python >= 3.11, bcftools >= 1.20

# Install vcfcache
pip install vcfcache

# Run comprehensive demo (tests all 4 commands)
vcfcache demo

# Use it
vcfcache --help

Note: bcftools is a runtime dependency and must be installed separately:

  • Ubuntu/Debian: sudo apt-get install bcftools
  • macOS: brew install bcftools
  • Conda: conda install -c bioconda bcftools

The demo command runs a complete workflow testing:

  1. blueprint-init - Create cache from variants
  2. blueprint-extend - Add more variants
  3. cache-build - Annotate the cache
  4. annotate - Use cache to annotate sample VCF

Quick start (from source)

Requirements: Python 3.13+, uv, bcftools >= 1.20

git clone https://github.com/julius-muller/vcfcache.git
cd vcfcache
uv venv .venv && source .venv/bin/activate
uv pip install -e ".[dev]"
vcfcache --help
python -m pytest tests -q   # optional

Quick start (Docker + public cache)

The CLI can fetch caches from Zenodo by alias using the bundled public_caches.yaml.

docker pull ghcr.io/julius-muller/vcfcache:v0.3.0

docker run --rm -v $(pwd):/work ghcr.io/julius-muller/vcfcache:v0.3.0 \
  annotate \
    -a cache-hg38-gnomad-4.1joint-AF0100-vep-115.2-basic \
    --vcf /work/tests/data/nodata/sample4.bcf \
    --output /work/out \
    --force

List public caches:

vcfcache list --public-caches

Show the recorded annotation command without running it:

vcfcache annotate -a cache-hg38-gnomad-4.1joint-AF0100-vep-115.2-basic --show-command

Build your own cache

  1. Normalize/deduplicate into a blueprint:
vcfcache blueprint-init \
  --vcf gnomad_subset.bcf \
  --output ./cache \
  -y params.yaml \
  --force
  1. Annotate the blueprint (cache-build) with your recipe:
vcfcache cache-build \
  --name vep_custom \
  --db ./cache \
  -a annotation.yaml \
  -y params.yaml \
  --force
  1. Use the cache on samples:
vcfcache annotate \
  -a ./cache/cache/vep_custom \
  --vcf sample.bcf \
  --output ./results \
  --force

Manifest & aliases

  • Manifest: public_caches.yaml
  • Fields (minimum): alias, type (blueprint|cache), version, genome, source, release, filt, doi, updated_at, md5, plus tool/tool_version/preset for caches.
  • Aliases:
    • Blueprint: bp-hg38-gnomad-4.1joint-AF0100
    • Cache: cache-hg38-gnomad-4.1joint-AF0100-vep-115.2-basic
  • vcfcache annotate -a <alias> auto-downloads from Zenodo and extracts to ~/.cache/vcfcache/caches/<alias>.
  • vcfcache pull --doi <doi> --dest <dir> for manual download/extract.
  • vcfcache push --cache-dir <dir> uploads to Zenodo (requires ZENODO_TOKEN; uses real Zenodo by default).

Configuration (YAML)

Two files, stored with the cache for reproducibility:

  1. params.yaml — resource paths/tools:
bcftools_cmd: "bcftools"         # bundled bcftools by default
annotation_tool_cmd: "vep"
tool_version_command: "vep --version"
temp_dir: "/tmp"
optional_checks: {}
  1. annotation.yaml — immutable annotation recipe:
annotation_cmd: |
  ${params.bcftools_cmd} view ${INPUT_BCF} | \
  ${params.annotation_tool_cmd} --offline --cache \
    --dir_cache ${params.vep_cache} --format vcf --vcf \
    -i STDIN -o STDOUT | \
  ${params.bcftools_cmd} view -o ${OUTPUT_BCF} -Ob -W
must_contain_info_tag: CSQ
required_tool_version: "115.2"
optional_checks:
  vep_cache_version: "115"
  genome_build: "GRCh38"

Special variables: ${INPUT_BCF}, ${OUTPUT_BCF}, ${AUXILIARY_DIR}, and ${params.*}.


Testing

  • From source: python -m pytest tests -q
  • In Docker (dev stage):
    docker build --target test -f docker/Dockerfile.vcfcache -t vcfcache:test .
    docker run --rm vcfcache:test /opt/venv/bin/python -m pytest tests -q

Docker

  • Lean runtime: ghcr.io/julius-muller/vcfcache:v0.3.0 (bundled bcftools 1.22)
  • Multi-stage build: docker/Dockerfile.vcfcache
    • --target test installs dev deps and can run pytest
    • --target final is the shipped image (small)

Notes

  • No Nextflow/JVM needed.
  • Caches are portable tarballs; manifest version is informational to track which vcfcache built them.
  • bcftools is bundled and used by default; override via bcftools_cmd if you need a different binary.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcfcache-0.3.3.tar.gz (93.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcfcache-0.3.3-py3-none-any.whl (69.2 kB view details)

Uploaded Python 3

File details

Details for the file vcfcache-0.3.3.tar.gz.

File metadata

  • Download URL: vcfcache-0.3.3.tar.gz
  • Upload date:
  • Size: 93.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for vcfcache-0.3.3.tar.gz
Algorithm Hash digest
SHA256 c52a59b4e19df34d4f686b55ebc98e49768391abe3b6ed67561640d64040f8e3
MD5 e7c734c59251843ea2222e9349adcdc1
BLAKE2b-256 96f0632376086b3f27a591b3e384188acfceea7c5c47bd9036c3957c97fbfc49

See more details on using hashes here.

File details

Details for the file vcfcache-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: vcfcache-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 69.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for vcfcache-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f8ed6db37469daf484290e09d17609f7135ecc8823d0407a6d42cf22698275bc
MD5 fec2ff651d240ec0ce20c1a0d8a5c302
BLAKE2b-256 5252fc480ce6d3cff2c977b256ac29381df3b19ff5aae1ffc680c4cc21b33122

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page