ensembl.vep.buffer.input_buffer package#

Input buffering.

Submodules#

ensembl.vep.buffer.input_buffer.base module#

Input buffers: a batch of input objects, indexed for overlap discovery.

class ensembl.vep.buffer.input_buffer.base.InputBuffer[ObjectT: IntervalLike](*, objects=())[source]#

Bases: Generic[ObjectT]

Indexed batch of input objects for overlap discovery.

The index is built on the first query and discarded whenever the batch changes, so a buffer that is only ever filled costs nothing to index.

Variables:

objects (tuple[ObjectT, ...]) – The objects in the current batch, in input order.

clear()[source]#

Drop the index built for the batch, leaving the batch itself alone.

get_objects_by_intervals(intervals)[source]#

Return the objects meeting any candidate interval, in input order.

Parameters:

intervals (Iterable[Interval]) – The candidate intervals to query.

Returns:

Every object meeting at least one interval, reported once.

Return type:

list[ObjectT]

get_overlapping_objects(start, end)[source]#

Return the objects overlapping one inclusive interval, in input order.

Parameters:
  • start (int) – The 1-based inclusive start coordinate.

  • end (int) – The inclusive end coordinate.

Returns:

The overlapping objects, empty when the batch is.

Return type:

list[ObjectT]

property is_empty: bool#

Return whether the input this batch was drawn from is spent.

next(items)[source]#

Reset the batch and refill it from items.

Parameters:

items (Iterator[ObjectT]) – The objects left to buffer. The iterator stays with the caller, so a buffer holds nothing that cannot cross a process boundary.

Raises:

NotImplementedError – Always; a refill policy defines this.

objects: tuple[ObjectT, ...]#

ensembl.vep.buffer.input_buffer.fixed_size module#

Fixed-size input buffer: one sequence region, at most buffer_size objects.

ensembl.vep.buffer.input_buffer.fixed_size.DEFAULT_BUFFER_SIZE = 5000#

How many objects one batch holds at most.

ensembl.vep.buffer.input_buffer.fixed_size.DEFAULT_MAX_NOT_ORDERED_VARIANTS = 5#

How many out-of-order objects are tolerated before the input is called unsorted.

ensembl.vep.buffer.input_buffer.fixed_size.DEFAULT_MAX_NOT_ORDERED_VARIANTS_DISTANCE = 50#

How far back an object may start before it counts as out of order.

class ensembl.vep.buffer.input_buffer.fixed_size.FixedSizeInputBuffer[ObjectT: Feature](*, objects=(), buffer_size=5000, max_not_ordered_variants=5, max_not_ordered_variants_distance=50)[source]#

Bases: InputBuffer[ObjectT]

Fixed-size input batch restricted to one sequence region.

An object read past the end of a batch, or on the next sequence region, is held back for the following refill rather than dropped.

Variables:
  • buffer_size (int) – How many objects one batch holds at most.

  • max_not_ordered_variants (int) – How many out-of-order objects to tolerate.

  • max_not_ordered_variants_distance (int) – How far back an object may start before it counts as out of order, which leaves room for deletions and minimised alleles.

buffer_size: int#
max_not_ordered_variants: int#
max_not_ordered_variants_distance: int#
next(items)[source]#

Reset the batch and refill it from the held-back objects, then from items.

Parameters:

items (Iterator[ObjectT]) – The objects left to buffer, in input order.

Raises:
  • RuntimeError – If the input looks unsorted.

  • ValueError – If an object carries no slice to group it by.