Interval#

class alphagenome.data.genome.Interval(chromosome, start, end, strand='.', name='', info=<factory>)[source]#

Represents a genomic interval.

A genomic interval is a region on a chromosome defined by a start and end position. This class provides methods for manipulating and comparing intervals, and for calculating coverage and overlap.

chromosome#

The chromosome name (e.g., ‘chr1’, ‘1’).

start#

The 0-based start position.

end#

The 0-based end position (must be greater than or equal to start).

strand#

The strand of the interval (‘+’, ‘-’, or ‘.’). Defaults to ‘.’ (unstranded).

name#

An optional name for the interval.

info#

An optional dictionary to store additional information.

negative_strand#

True if the interval is on the negative strand, False otherwise.

width#

The width of the interval (end - start).

Methods

as_unstranded()

Returns an unstranded copy of the interval.

binary_mask(intervals[, bin_size])

Boolean mask True if any interval overlaps the bin: coverage > 0.

binary_mask_stranded(intervals[, bin_size])

Stranded boolean mask that is True where any interval overlaps the bin.

boundary_shift([start_offset, end_offset, ...])

Extends or shrinks the interval by adjusting the positions with padding.

center([use_strand])

Computes the center of the interval.

contains(interval)

Checks if this interval completely contains another interval.

copy()

Returns a deep copy of the interval.

coverage(intervals, *[, bin_size])

Computes coverage track from sequence of intervals overlapping interval.

coverage_stranded(intervals, *[, bin_size])

Computes a coverage track from intervals overlapping this interval.

from_interval_dict(interval)

Creates an Interval from a dictionary.

from_str(string)

Creates an Interval from a string (e.g., 'chr1:100-200:+').

intersect(interval)

Returns the intersection of this interval with another interval.

overlap_ranges(intervals)

Returns overlapping ranges from intervals overlapping this interval.

overlaps(interval)

Checks if this interval overlaps with another interval.

pad(start_pad, end_pad, *[, use_strand])

Pads the interval by adding the specified padding to the start and end.

resize(width[, use_strand])

Resizes the interval to a new width, centered around the original center.

shift(offset[, use_strand])

Shifts the interval by the given offset.

swap_strand()

Swaps the strand of the interval.

to_interval_dict()

Converts the interval to a dictionary.

truncate([reference_length])

Truncates the interval to fit within the valid reference range.

within_reference([reference_length])

Checks if the interval is within the valid reference range.