API reference¶
vepyr.build_cache(release, cache_dir, *, cache_type, entity=None, chroms=None, species='homo_sapiens', assembly=_DEFAULT_ASSEMBLY, partitions=8, cache_format='parquet', local_cache=None, download_retries=10, show_progress=True, on_progress=None, overwrite=False)
¶
Download an Ensembl VEP cache and convert it to an optimized cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
release
|
int
|
Ensembl release number (e.g. 115). |
required |
cache_dir
|
str
|
Root directory for cache data and Parquet output. |
required |
cache_type
|
str
|
Required Ensembl VEP cache type: |
required |
entity
|
str or None
|
Build a single raw entity instead of the whole cache, leaving the rest
of the output directory untouched. One of |
None
|
chroms
|
list[str] or None
|
Restrict the build to specific contigs (e.g. |
None
|
species
|
str
|
Species name (default: |
'homo_sapiens'
|
assembly
|
str
|
Genome assembly (default: |
_DEFAULT_ASSEMBLY
|
partitions
|
int
|
Number of DataFusion partitions for parallelism (default: 8). |
8
|
cache_format
|
str
|
Cache format to build. Only |
'parquet'
|
local_cache
|
str or None
|
Path to an already-unpacked Ensembl VEP cache directory (the one
containing |
None
|
download_retries
|
int
|
Maximum number of resume-retries for the cache download (default: 10). Each retry resumes from the last byte received. |
10
|
show_progress
|
bool
|
Show the download progress bar and the tqdm bars during conversion (default: True). .. note::
The partitioned-Parquet build path does not currently emit
per-batch progress events, so no bars appear during the cache
build regardless of |
True
|
on_progress
|
callable or None
|
Custom progress callback with signature
|
None
|
overwrite
|
bool
|
Rebuild existing cache outputs instead of skipping them. |
False
|
Returns:
| Type | Description |
|---|---|
list[tuple[str, int]]
|
List of |
vepyr.build_plugin_cache(plugin, version, *, source_path, cache_dir, plugin_cache_root, chroms=None, plugins_repo=None, overwrite=False, verify_source=True)
¶
Build a per-chromosome plugin cache.
plugin/version select plugins/<plugin>/<plugin>.source.toml from
the public vepyr-plugins repo at that git tag (or plugins_repo for
offline). Tiering is inherited from the variation cache at cache_dir.
Returns per-chrom (chrom, rows, warm, cold) tuples.
source_path points each [[source]] at a real file, since the paths a
manifest ships are placeholders. A single-source manifest takes a plain path;
a manifest that declares several sources (each with a part) takes a
{part: path} mapping, and every part must be mapped::
build_plugin_cache(
"cadd", "v1.0",
source_path={"snv": ".../whole_genome_SNVs.tsv.gz",
"indel": ".../gnomad.genomes.r4.0.indel.tsv.gz"},
...
)
The sources are registered as plugin_<name>_src_<part> and combined by the
manifest's own ingest_sql -- there is no need to concatenate them first.
verify_source guards against building from the wrong bytes. Before the
first chromosome is ingested, each resolved source file is MD5-hashed once
(streaming, bounded memory) and compared with the manifest's md5.
True / "strict" (default) raises on a mismatch,
naming the part, both digests and the upstream url; "warn" logs it
and keeps building -- for a build input that is a derived artifact of the
upstream file (AlphaMissense's BGZF re-compression; its plugin README
documents the preprocessing); False / "skip" never hashes -- use it
for a chromosome slice cut with tabix, whose digest can never match the
whole file. A manifest that declares no md5 is never hashed. The digest
actually verified, with the file's size and mtime, is recorded under
sources in the emitted manifest.json; an incremental chroms=[...]
build against an unchanged file trusts that record instead of re-hashing.
The cache manifest records the source as <version>@<commit SHA>. This
keeps mutable refs auditable and prevents an incremental build from mixing
chromosomes produced from different manifest revisions. Builds for the
same plugin cache are serialized across processes so the revision check
and shard update observe one cache revision. This coordination applies to
calls through this API on filesystems that honor advisory locks; external
writers are outside the lock.
vepyr.download_cache(release, cache_dir, *, cache_type, assembly='GRCh38', chroms=None, revision=None, show_progress=True)
¶
Download a published vepyr cache from Hugging Face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
release
|
int
|
Ensembl release, e.g. |
required |
cache_dir
|
str
|
Root directory; the cache is written to
|
required |
cache_type
|
('ensembl', 'merged', 'refseq')
|
Cache type. |
"ensembl"
|
assembly
|
str
|
Genome assembly (default: |
'GRCh38'
|
chroms
|
list of str or None
|
Contigs to download, e.g. |
None
|
revision
|
str or None
|
Dataset revision. |
None
|
show_progress
|
bool
|
Show download progress bars (default: True). |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The cache directory, ready for |
Re-running resumes and skips files already present, and ``chroms`` can
|
|
add contigs to an earlier download. A directory holds one dataset
|
|
revision, recorded in ``.cache/vepyr/download.json``: downloading another
|
|
revision into it is refused, and so is downloading into a directory filled
|
|
some other way (e.g. by :func:`build_cache`) unless ``hf download`` wrote
|
|
it at the same revision.
|
|
vepyr.download_plugin_cache(plugin, release, plugin_cache_root, *, assembly='GRCh38', chroms=None, revision=None, show_progress=True)
¶
Download a published vepyr plugin cache from Hugging Face.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin
|
str
|
Plugin name, e.g. |
required |
release
|
int
|
Ensembl release, e.g. |
required |
plugin_cache_root
|
str
|
Root of the plugin cache tree; the cache is written to
|
required |
assembly
|
str
|
Genome assembly (default: |
'GRCh38'
|
chroms
|
list of str or None
|
Contigs to download, as for :func: |
None
|
revision
|
str or None
|
Dataset revision; |
None
|
show_progress
|
bool
|
Show download progress bars (default: True). |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The plugin cache directory. Pass |
Re-running resumes; the directory keeps one dataset revision, as for
|
|
func:`download_cache`.
|
|
vepyr.annotate(vcf, cache_dir, *, reference_fasta, shift_hgvs=None, no_escape=False, remove_hgvsp_version=False, hgvsp_use_prediction=False, expected_cache_version=None, distance=None, gencode_basic=False, gencode_primary=False, all_refseq=False, exclude_predicted=False, pick=False, pick_allele=False, per_gene=False, pick_allele_gene=False, flag_pick=False, flag_pick_allele=False, flag_pick_allele_gene=False, pick_order=None, buffer_size=5000, failed=0, workers=1, skip_csq=True, fields=None, plugin_cache_root=None, plugins=None, allow_non_variant=False, info_fields=None, format_fields=None, output_vcf=None, preserve_record_layout=None, show_progress=True, compression=None, on_batch_written=None)
¶
Annotate variants from a VCF file with VEP consequences.
Reads the VCF, runs annotate_vep() against the partitioned parquet
cache produced by :func:build_cache, and returns a polars LazyFrame.
The engine auto-discovers context tables (transcript, exon, translation,
regulatory, motif) from cache_dir subdirectories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vcf
|
str
|
Path to the input VCF file. |
required |
cache_dir
|
str
|
Path to the parquet cache directory produced by :func: |
required |
reference_fasta
|
str
|
Path to the reference FASTA. Required: annotation always runs
Ensembl VEP |
required |
shift_hgvs
|
bool or None
|
3' shift HGVS notation. |
None
|
no_escape
|
bool
|
Don't URI-escape HGVS strings. |
False
|
remove_hgvsp_version
|
bool
|
Remove version from HGVSp transcript ID. |
False
|
hgvsp_use_prediction
|
bool
|
Use predicted rather than observed protein sequence. |
False
|
distance
|
int or tuple[int, int] or None
|
Upstream/downstream distance for transcript overlap. Single int = both directions; tuple = (upstream, downstream). |
None
|
gencode_basic
|
bool
|
Restrict to transcripts in the GENCODE basic set. Mutually exclusive
with |
False
|
gencode_primary
|
bool
|
Restrict to transcripts in the GENCODE primary set (GRCh38 only).
Mutually exclusive with |
False
|
all_refseq
|
bool
|
Keep all RefSeq transcripts including CCDS/EST-style rows. |
False
|
exclude_predicted
|
bool
|
Exclude predicted RefSeq transcripts ( |
False
|
pick
|
bool
|
Emit one selected consequence per variant, matching VEP |
False
|
pick_allele
|
bool
|
Emit one selected consequence per allele, matching VEP
|
False
|
per_gene
|
bool
|
Emit one selected consequence per gene while retaining non-transcript
rows, matching VEP |
False
|
pick_allele_gene
|
bool
|
Emit one selected consequence per allele and gene, matching VEP
|
False
|
flag_pick
|
bool
|
Retain all consequences and add |
False
|
flag_pick_allele
|
bool
|
Retain all consequences and add |
False
|
flag_pick_allele_gene
|
bool
|
Add a standalone |
False
|
pick_order
|
str or None
|
Comma-separated VEP pick ranking order, e.g.
|
None
|
buffer_size
|
int
|
Number of input variants per VEP-style annotation buffer. Defaults to
Ensembl VEP's |
5000
|
failed
|
int
|
Maximum allowed |
0
|
expected_cache_version
|
str or None
|
Optional assertion against the cache version embedded in each requested chromosome's Parquet metadata. It cannot supply missing cache identity. |
None
|
workers
|
int
|
Number of within-contig annotation pipelines (default: 1) on both
output paths. Values greater than 1 require a tabix-indexed (bgzip +
|
1
|
skip_csq
|
bool
|
Exclude the raw CSQ column from the output (default: True). When True, only the parsed annotation columns are returned. |
True
|
fields
|
'core'
|
Ordered base CSQ fields to emit, mirroring VEP |
"core"
|
plugin_cache_root
|
str or None
|
Root of a plugin cache tree built by :func: Plugin values are appended to the |
None
|
plugins
|
list or tuple of str, or None
|
Restrict annotation to these plugin names, a subset of the directories
under |
None
|
info_fields
|
list of str
|
Input INFO fields the |
None
|
format_fields
|
list of str
|
Input FORMAT fields, same convention. Single-sample inputs get one
column per field; multi-sample inputs a nested |
None
|
output_vcf
|
str or None
|
Path to write annotated VCF output. When set, annotation results are
written directly to a VCF file and the output path is returned.
When |
None
|
allow_non_variant
|
bool
|
Keep records that carry no alternate allele -- |
False
|
preserve_record_layout
|
bool
|
Write each record's INFO fields in the order the input wrote them, and
its own FORMAT keys (default: on). On the LazyFrame it adds two string
columns, |
None
|
show_progress
|
bool
|
Show a progress bar while annotating (default: True). On the VCF
output path it is a determinate bar over the pre-counted input. On
the |
True
|
compression
|
str or None
|
VCF output compression. |
None
|
on_batch_written
|
callable or None
|
Callback invoked after each batch is written to VCF, with signature
|
None
|
Notes
Filtering the returned LazyFrame on chrom, start or end
restricts the input before annotation (region pushdown): unselected
contigs are skipped and indexed inputs are read by seek. Results are
identical to filtering after collect(). A RuntimeWarning is
raised when the input has no .tbi/.csi index. See the "Region
filters" section of the Polars DataFrames docs page for the recognised
predicate shapes.
Returns:
| Type | Description |
|---|---|
LazyFrame or str
|
When |
Examples: