ensembl.vep.annotators package#

Annotator contracts and built-in registries.

Importing this package registers the built-in consequence and haplo annotators.

Subpackages#

Submodules#

ensembl.vep.annotators.base module#

Annotator protocol shared by all annotation domains.

Annotator is the contract callers depend on. registry.get_annotator returns one without requiring inheritance, allowing Python and native implementations to share the registry. The protocol exposes single-overlap and batch annotation; implementations may derive either operation from the other.

class ensembl.vep.annotators.base.Annotator[ResultT](*args, **kwargs)[source]#

Bases: Protocol[ResultT]

Define the common contract for annotators producing ResultT.

Variables:

name (str) – The registry name this annotator is registered under, e.g. “consequence.linear”.

annotate_feature_overlap(overlap)[source]#

Annotate a feature overlap.

Parameters:

overlap (FeatureOverlap) – The overlap to annotate.

Returns:

What this annotator produces for the overlap. May be empty – for a

consequence annotator that means callers apply the default/fallback term (e.g. intergenic_variant) themselves rather than the annotator doing so.

Return type:

list[ResultT]

annotate_feature_overlaps(overlaps)[source]#

Annotate a batch of feature overlaps at once.

Parameters:

overlaps (Sequence[FeatureOverlap]) – The overlaps to annotate, in order.

Returns:

One result list per input overlap, in the same order as

overlaps.

Return type:

list[list[ResultT]]

name: str#
class ensembl.vep.annotators.base.ResultT#

What an annotator produces per overlap.

alias of TypeVar(‘ResultT’)

ensembl.vep.annotators.factory module#

Build annotators and run-scoped context from plain values.

Registered strategies accept different keyword arguments, so construction derives supported options from each factory signature instead of maintaining a duplicate table. That is what lets a caller spread a whole configuration section over build_annotator: the options the chosen strategy declares reach it, and the rest are warned about and dropped.

ensembl.vep.annotators.factory.build_annotator(*, annotator='consequence.linear', batch_size=256, early_subsumption_skip=False, zone_map=False, zone_map_bytes=268435456, codon_cache=False, codon_cache_entries=65536, mapper_cache=False, mapper_cache_bytes=67108864, readthrough=Readthrough.NONE, fact_cost_override=False, upstream_distance=5000, downstream_distance=5000, annotator_context=None, **options)[source]#

Return a configured annotator, with its caches attached.

Parameters:
  • annotator (str, default: 'consequence.linear') – Registered annotator name.

  • batch_size (int, default: 256) – Overlaps per chunk, for the strategies that batch.

  • early_subsumption_skip (bool, default: False) – Skip rules already suppressed by a hit, where supported.

  • zone_map (bool, default: False) – Enable the positional-fact zone map.

  • zone_map_bytes (int, default: 268435456) – Byte budget for the zone map cache.

  • codon_cache (bool, default: False) – Enable the shared-codon edit cache.

  • codon_cache_entries (int, default: 65536) – Maximum codon cache entries.

  • mapper_cache (bool, default: False) – Enable the mapper index cache.

  • mapper_cache_bytes (int, default: 67108864) – Byte budget for the mapper index cache.

  • readthrough (str | Readthrough, default: Readthrough.NONE) – How far translation may run past a destroyed stop codon.

  • fact_cost_override (bool, default: False) – Use the packaged measured fact costs, when building the context.

  • upstream_distance (int, default: 5000) – Bases before a feature’s 5’ end that still count as upstream.

  • downstream_distance (int, default: 5000) – Bases past a feature’s 3’ end that still count as downstream.

  • annotator_context (AnnotatorContext | None, default: None) – A context to share across annotators, or None to build one from the cache arguments.

  • **options (Any) – Further options for the chosen strategy, such as the ones another annotation kind declares. Each is passed on only if that strategy’s factory accepts it; unsupported options are logged as warnings.

Returns:

The annotator instance.

Return type:

Annotator[OverlapConsequence]

Raises:

KeyError – If no annotator is registered under annotator.

ensembl.vep.annotators.factory.build_annotator_context(*, zone_map=False, zone_map_bytes=268435456, codon_cache=False, codon_cache_entries=65536, mapper_cache=False, mapper_cache_bytes=67108864, readthrough=Readthrough.NONE, fact_cost_override=False, upstream_distance=5000, downstream_distance=5000)[source]#

Return the run-scoped context described by a set of cache choices.

Parameters:
  • zone_map (bool, default: False) – Enable the per-transcript positional-fact zone map.

  • zone_map_bytes (int, default: 268435456) – Byte budget for the zone map cache.

  • codon_cache (bool, default: False) – Enable the shared-codon edit cache.

  • codon_cache_entries (int, default: 65536) – Maximum codon cache entries.

  • mapper_cache (bool, default: False) – Enable the genomic-to-CDS mapper index cache.

  • mapper_cache_bytes (int, default: 67108864) – Byte budget for the mapper index cache.

  • readthrough (str | Readthrough, default: Readthrough.NONE) – How far translation may run past a destroyed stop codon, as a level or its lowercased name.

  • fact_cost_override (bool, default: False) – Order fact evaluation by the packaged measured costs instead of the declared tiers. The table is process-wide, so this changes every annotator built after it.

  • upstream_distance (int, default: 5000) – Bases before a feature’s 5’ end that still count as upstream.

  • downstream_distance (int, default: 5000) – Bases past a feature’s 3’ end that still count as downstream.

Returns:

The context, with only the enabled caches attached.

Return type:

AnnotatorContext

ensembl.vep.annotators.registry module#

Annotator registry keyed by <domain>.<strategy> names.

ensembl.vep.annotators.registry.available_annotators()[source]#

Return the sorted set of registered annotator names.

Return type:

tuple[str, ...]

ensembl.vep.annotators.registry.get_annotator(name, /, *args, **kwargs)[source]#

Return a registered annotator instance.

Parameters:
  • name (str) – Registry name, e.g. "consequence.linear".

  • *args (object) – Positional arguments forwarded to the registered factory.

  • **kwargs (object) – Keyword arguments forwarded to the registered factory.

Returns:

A new annotator instance.

Return type:

Annotator[AnnotatorResultT]

Raises:

KeyError – If no annotator is registered under name.

ensembl.vep.annotators.registry.register_annotator(name, factory=None)[source]#

Register an annotator factory under a name.

Parameters:
  • name (str) – Registry name, e.g. "consequence.linear".

  • factory (Callable[..., Annotator[AnnotatorResultT]] | None, default: None) – Factory to register, or None when used as a decorator.

Returns:

The registered factory

or a decorator that registers one.

Return type:

Callable[..., Annotator[AnnotatorResultT]] | Callable[[Callable[..., Annotator[AnnotatorResultT]]], Callable[..., Annotator[AnnotatorResultT]]]