Skip to main content

Tests Coverage Status PyPI PyPI downloads Docs

Varcode

Varcode is a Python library that predicts what genomic variants do to genes, transcripts, and proteins. Load a VCF or MAF file, and for each variant on each overlapping transcript, Varcode reports the predicted consequence (for example a substitution such as p.L159M, a frameshift, or a gene fusion). Where the sequence can be determined, it also gives the mutant protein.

In the OpenVax tools, Varcode reads gene annotations through PyEnsembl. Isovar reconstructs variant sequences from RNA reads, and Topiary and Vaxrank use Varcode's predicted proteins to choose and rank candidate peptides; see how the libraries fit together.

Install

Requires Python 3.11 or later:

pip install varcode
pyensembl install --release 81 --species human

The second command downloads the gene annotation and transcript sequences used in the example below (Ensembl 81, GRCh38). For your own data, choose an annotation that matches your input's genome build; see reference setup.

Varcode installs ORFdata, which supplies the ORFs for noncanonical ORF consequences. The optional varcode[rna] extra adds pysam for phasing variants from RNA-seq reads (pysam does not support Windows).

Quick start

Predict the effect of a single GRCh38 variant on a CFTR transcript:

from varcode import Variant

variant = Variant("7", 117_531_100, "T", "A", genome=81)
transcript = variant.genome.transcript_by_id("ENST00000003084")
effect = variant.effect_on_transcript(transcript)

print(effect.gene.name, effect.short_description)
protein = effect.mutant_protein_sequence
print(protein[158])  # Python offsets start at zero
CFTR p.L159M
M

Annotate every variant in a VCF called against the same genome build, and print the most severe effect for each:

from varcode import load_vcf

variants = load_vcf("variants.vcf", genome=81)
effects = variants.effects()
for variant, effect in effects.top_priority_effect_per_variant().items():
    print(variant.short_description, effect.short_description)

For a VCF containing only the variant above, this prints:

chr7 g.117531100T>A p.L159M

Before relying on the output, read how to read results. In short: each prediction belongs to one transcript; "top priority" means most severe, not most likely; None means unknown, not unchanged; and a predicted protein is not evidence that it is expressed.

Command line

The varcode command annotates variant files without writing Python and saves one row per variant and transcript:

varcode effects --genome GRCh38 --vcf variants.vcf --output-csv effects.csv

varcode genes lists the genes each variant overlaps, and varcode check-samples screens a cohort of VCFs for possible sample mix-ups. varcode --help lists the subcommands. See the command-line guide and sample identity checks.

Documentation

Full documentation: openvax.github.io/varcode.

Development

./develop.sh   # editable install into the active environment
./lint.sh      # Ruff and mypy
./test.sh      # pytest; needs the Ensembl releases listed in CONTRIBUTING.md
mkdocs build --strict

See CONTRIBUTING.md for the development environment and reference data, and the changelog for release history. For bugs or questions, open an issue.

License

Varcode is released under the Apache 2.0 license.

Metadata

Release files for varcode 11.15.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for varcode 11.15.3
File Size Uploaded Provenance Actions
varcode-11.15.3.tar.gz 15.5 MB Without provenance Details for varcode-11.15.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for varcode 11.15.3
File Interpreter ABI Platform Actions
varcode-11.15.3-py3-none-any.whl Python 3 none any Details for varcode-11.15.3-py3-none-any.whl

Total release size: 15.9 MB

Release files / varcode-11.15.3.tar.gz

Download URL varcode-11.15.3.tar.gz
Size 15.5 MB
Tags Source
SHA-256 checksum
How to use checksums
de11ff4119f76888020b34b04397f771fd50511eb7574c9749275b72b5822392
BLAKE2b-256 checksum
How to use checksums
964619792dfd4538e6a6a963a9c78a25f068a4ccb8dce96c32b79f8b1b8db54b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.3

Release files / varcode-11.15.3-py3-none-any.whl

Download URL varcode-11.15.3-py3-none-any.whl
Size 406.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2f94d88af1ca6d2c80eec5bf4bce5e0b8837358980e65cbdb21ccf8af22ec45
BLAKE2b-256 checksum
How to use checksums
4fb023718618cb75dc063bbe9bbd06713426bc6263129460d0b1f44fc8b54882
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.3

Security for varcode 11.15.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

11.15.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page