Skip to main content

variantgrid_api

PyPi version Python versions

Python API client for VariantGrid Open source Variant database and analysis platform

See changelog

Install

python3 -m pip install variantgrid_api

Example

from variantgrid_api.api_client import VariantGridAPI
from variantgrid_api.data_models import EnrichmentKit

api = VariantGridAPI(server="https://variantgrid.com", api_token="YOUR_API_TOKEN")
enrichment_kit = EnrichmentKit(name="idt_haem", version=1)
result = api.create_enrichment_kit(enrichment_kit)

Annotate a VCF and download it back

Upload a VCF, wait for VariantGrid to import + annotate any novel variants, then download the cohort-level annotated export (all samples, single-sample VCFs included). The whole flow is a one-liner:

from variantgrid_api.api_client import VariantGridAPI

api = VariantGridAPI(server="https://variantgrid.com", api_token="YOUR_API_TOKEN")

# export_type is "vcf" (gzipped *.vcf.gz) or "csv" (zipped *.csv.zip)
path = api.annotate_vcf("input.vcf", export_type="vcf", dest_path="/data/results/")
print(f"Annotated VCF written to {path}")

Or drive each step yourself:

# For ad-hoc uploads pass path=None so the upload isn't treated as a SeqAuto backend-link hint
upload = api.upload_file("input.vcf", path=None)
uploaded_file_id = upload["uploaded_file_id"]           # or upload["sha256_hash"]
api.wait_for_annotation(uploaded_file_id, timeout=3600, poll_interval=10)  # raises on error/timeout
path = api.download_annotated(uploaded_file_id, export_type="csv", dest_path="/data/results/")

poll_upload_status(uploaded_file_id) returns the raw status dict (including annotation_complete, progress_percent, error, vcf_id, samples, ...) if you want to inspect progress directly. All of these accept sha256=<hash> instead of uploaded_file_id - the server dedups on the content hash, so it is stable across machines and useful if you didn't retain the id.

Notes:

  • The annotate_vcf wrapper already uploads with path=None. Only pass a path to upload_file for SeqAuto uploads that link to a registered JointCalledVCF / SingleSampleVCF (that is what path is for - it is ignored on non-SeqAuto deployments).
  • Downloads require the target deployment to have the cohort export analysis templates configured (ANALYSIS_TEMPLATES_AUTO_COHORT_EXPORT) - otherwise a clear error is returned.

Testing

# Install required testing packages
python3 -m pip install -e ".[test]"
python3 -m pytest --cov=variantgrid_api

Download files

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

Source Distribution

variantgrid_api-1.3.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

variantgrid_api-1.3.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file variantgrid_api-1.3.0.tar.gz.

File metadata

  • Download URL: variantgrid_api-1.3.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for variantgrid_api-1.3.0.tar.gz
Algorithm Hash digest
SHA256 7ba5a549ad017e3910df742e26e0b5cd8602d4c2ad5f7a45c944b88018cdc1ee
MD5 d533ba2e9d133af503596b2efc872889
BLAKE2b-256 b4ea0896dc2891c197cd11126e6d14bf58545472c1a343cec986df286a9de479

See more details on using hashes here.

File details

Details for the file variantgrid_api-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for variantgrid_api-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0a11d3bb665d704a47ab32cf744e30dbc979b43008e87534a4aefd920523d76
MD5 d85c7ad4d84eb83668037e630dc13aea
BLAKE2b-256 c2fe1f15a2838754c4eb8133623cea8b99bc6dea2547d2541c60b14f9b3ac825

See more details on using hashes here.

Release history Release notifications | RSS feed

1.4.0

2 files

1.3.2

2 files

1.3.1

2 files

This release

1.3.0 This release

2 files

1.2.0

2 files

1.1.1

2 files

1.0.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.5

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1

2 files

0.0.2

1 file

Supported by

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