vampire.anno.pp.read_indexed_bed

vampire.anno.pp.read_indexed_bed#

vampire.anno.pp.read_indexed_bed(bed_file, chrom, start=0, end=1000000000.0, columns={'blockCount': Int64, 'blockSizes': String, 'blockStarts': String, 'chrom': String, 'end': Int64, 'itemRgb': String, 'name': String, 'score': Float64, 'start': Int64, 'strand': String, 'thickEnd': Int64, 'thickStart': Int64})[source]#

Read a indexed BED.GZ file using pysam and polars.

This function returns a polars.LazyFrame and does not read or parse the file immediately. The file will only be read when the lazy query is executed (e.g. via collect()).

The input file is assumed to be in BED format with at least three columns:

  • chrom (chromosome name)

  • start (0-based start position)

  • end (end position, exclusive)

Any additional columns present in the file are preserved and automatically assigned standard BED column names when possible.

Parameters:
  • bed_file (str) – Path to the input BED.GZ file.

  • chrom (str) – Chromosome (sequence name) to read.

  • start (int) – Start coordinate of a region to read. Default is 0.

  • end (int) – End coordinate of a region to read. Default is 1e9.

  • columns (dict[str, DataType]) – Column names and data types to read.

Returns:

A lazily-evaluated Polars LazyFrame representing the BED file contents.

Return type:

LazyFrame

Raises:

FileNotFoundError – If the specified BED file does not exist.