gnomad.utils.intervals

gnomad.utils.intervals.sort_intervals(intervals)

Sort an array of intervals by start contig, then start position, then end contig, then end position.

gnomad.utils.intervals.union_intervals(intervals)

Generate a list with the union of all intervals in the input list by merging overlapping intervals.

gnomad.utils.intervals.interval_length(interval)

Return the total number of bases in an Interval.

gnomad.utils.intervals.pad_intervals(...)

Add padding to interval(s).

gnomad.utils.intervals.sort_intervals(intervals)[source]

Sort an array of intervals by start contig, then start position, then end contig, then end position.

Parameters:

intervals (List[Interval]) – Intervals to sort

Returns:

Sorted interval list

gnomad.utils.intervals.union_intervals(intervals, is_sorted=False)[source]

Generate a list with the union of all intervals in the input list by merging overlapping intervals.

Parameters:
  • intervals (List[Interval]) – Intervals to merge

  • is_sorted (bool) – If set, assumes intervals are already sorted, otherwise will sort.

Returns:

List of merged intervals

gnomad.utils.intervals.interval_length(interval)[source]

Return the total number of bases in an Interval.

Parameters:

interval (Interval) – Input interval

Return type:

int

Returns:

Total length of the interval

gnomad.utils.intervals.pad_intervals(intervals, padding_bp)[source]

Add padding to interval(s).

Parameters:
  • intervals (Union[IntervalExpression, Interval, List[Interval]]) – Interval(s) to add padding to. This can be a single Interval, a list of Intervals, or an IntervalExpression.

  • padding_bp (int) – Number of base pairs to add to each side of the interval.

Return type:

Union[IntervalExpression, List[IntervalExpression]]

Returns:

Interval(s) with padding added.