ensembl.vep.sources.file.vcf namespace#

Submodules#

ensembl.vep.sources.file.vcf.variation module#

VCF-backed variation feature sources.

Two of them, differing only in what a record is: VCFVariationSource reads parsed records, and PicklableVCFVariationSource reads the input’s own lines, which is what an annotation run needs because a record it hands a worker has to pickle.

class ensembl.vep.sources.file.vcf.variation.PicklableVCFVariationSource(*, sequence_source=None, slice_cache=WeakSliceCache(), file_path, sequence_region_resolver=None)[source]#

Bases: VCFVariationSource

VCF variation source whose records are the input’s own lines.

An annotation run reads in one process and builds models in another: the process driving the run reads records and the worker annotating them turns records into variations. A record has to pickle to make that crossing, which the Rust parser’s VCFRecord does not, and output has to echo the input’s own text back, which a record built from a line can no longer give. The line is both, so this source’s record is a line – narrowing the record type its parent reads, and leaving everything about building models from them the same.

Nothing here batches. iter_all_records yields one record at a time and whoever drives the source groups them (workflow.executor.PayloadIterator), which is what lets a format say what a record is without also deciding how many of them cross a process boundary at once.

get_all_records()[source]#

Return every record line in the input, in input order.

Return type:

list[str]

get_records_by_region(region=None, *, seq_region_name=None, start=None, end=None, **kwargs)[source]#

Return the record lines an indexed region query reads.

Parameters:
  • region (str | None, default: None) – The region (e.g., “chr1:1000-2000”) to read.

  • seq_region_name (str | None, default: None) – The name of the sequence region (e.g., “chr1”).

  • start (int | None, default: None) – The start position of the region.

  • end (int | None, default: None) – The end position of the region.

  • **kwargs (object) – Unused here; a format whose query takes more accepts it.

Returns:

The record lines the query read, empty when the region names none.

Return type:

list[str]

header_lines()[source]#

Return the input’s leading header lines, without line endings.

Return type:

list[str]

iter_all_records()[source]#

Yield each record’s line, as the input spells it, without its line ending.

Yields:

Iterator[str] – Each record’s line, in input order.

Raises:

ValueError – If a line holds fewer than the eight fixed VCF columns.

iter_records_by_region(region=None, *, seq_region_name=None, start=None, end=None, **kwargs)[source]#

Yield the record lines an indexed region query reads.

Parameters:
  • region (str | None, default: None) – The region (e.g., “chr1:1000-2000”) to read.

  • seq_region_name (str | None, default: None) – The name of the sequence region (e.g., “chr1”).

  • start (int | None, default: None) – The start position of the region.

  • end (int | None, default: None) – The end position of the region.

  • **kwargs (object) – Unused here; a format whose query takes more accepts it.

Returns:

The record lines the query reads, in file order.

Return type:

Iterator[str]

static record_columns(record)[source]#

Return a record’s own columns, which output echoes back as the input gave them.

Parameters:

record (str) – The record line to split.

Returns:

Its columns, in input order.

Return type:

tuple[str, ...]

records_to_features(records)[source]#

Return the variations for a set of record lines, in input order.

A record is a line alone, so the file’s own header is read back here: what a line means can depend on an INFO or contig declaration that only the header holds.

Parameters:

records (Sequence[str]) – The record lines to parse and build models from.

Returns:

The variations the lines describe.

Return type:

list[Variation]

static region_of(record)[source]#

Return the sequence region a record names.

Parameters:

record (str) – The record line to read.

Returns:

Its sequence-region name, taken from the line’s first field rather than from all

of them: this is read once per record in the process driving a run, and the whole line is split again only for the records output echoes.

Return type:

str

class ensembl.vep.sources.file.vcf.variation.VCFVariationSource(*, sequence_source=None, slice_cache=WeakSliceCache(), file_path, sequence_region_resolver=None)[source]#

Bases: FileFeatureSource[VCFParser, VCFRecord, Variation]

Variation source backed by a VCF file.

Variables:

adaptor – The parser adaptor used to stream VCF records.

adaptor: VCFParser#
record_count(*, scan=False)[source]#

Return how many records the input holds, or None when nothing declares it.

Parameters:

scan (bool, default: False) – Whether to count by reading the whole input when it has no index. Default is False.

Returns:

The record count, or None when the input has no index and scan is

False.

Return type:

int | None

records_to_features(records)[source]#

Convert VCFRecords into Variation or StructuralVariation objects.

Parameters:

records (list[VCFRecord]) – VCF records to convert into variation features.

Returns:

Variation and StructuralVariation objects created from the VCF records.

Return type:

list[Variation]

sequence_region_resolver: SequenceRegionResolver | None#