ensembl.vep.sources.file package#

Feature sources — file-backed and database-backed providers of domain Feature objects.

Subpackages#

Submodules#

ensembl.vep.sources.file.file_feature_source module#

The file-backed feature source contract.

class ensembl.vep.sources.file.file_feature_source.FileFeatureSource[P: Parser, R, F: Feature](*, sequence_source=None, slice_cache=WeakSliceCache(), file_path, adaptor)[source]#

Bases: FeatureSource[R, F], Generic[P, R, F]

Feature source backed by a parser-readable file.

Variables:
  • file_path (str) – Path to the feature file.

  • adaptor (P) – Parser for the file’s record type.

  • source_type (SourceType) – File source marker.

adaptor: P#
close()[source]#

Release the attached sequence source, if any.

FeatureSource owns the sequence_source field and __exit__ calls close(), but nothing in the chain ever released it – so a source opened as a context manager leaked its sequence handle. Closing it here is what the field’s ownership already implied.

file_path: str#
get_all_records()[source]#

Return every unconverted record in the source file.

Returns:

Every record in the file.

Return type:

list[R]

Raises:
  • NotImplementedError – If the adaptor cannot parse a whole file at once. Re-raised with the adaptor named, which the bare error from the parser does not say.

  • FileNotFoundError – If the file does not exist. Allowed to propagate: its message already names the path.

A library reports what went wrong and lets its caller decide what to do about it. These both used to call sys.exit(1), which ended the process from underneath any caller – including a test, and including a runner that had a better answer than dying.

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

Return unconverted records from an indexed region query.

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 records the query reads, empty when the region is unreadable.

Return type:

list[R]

iter_all_records()[source]#

Yield every unconverted record in the source file.

Return type:

Iterator[R]

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

Yield unconverted records from an indexed region query.

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 records the query reads, in file order.

Return type:

Iterator[R]

source_type: SourceType#