intersect_intervals

intersect_intervals#

alphagenome.data.genome.intersect_intervals(lhs, rhs, *, result_strand='.')[source]#

Generates the intersection of two interval sets.

Point ranges (width == 0) are considered to intersect any range which contains them.

In these examples, the intersection is a point range (2, 2):

  1  2  3  4
..|..|..|..|..
      <>        (start=2, end=2)
------->        (..., end=2)

  1  2  3  4
..|..|..|..|..
      <>        (start=2, end=2)
      <-------  (start=2, end=...)

For consistency, this means that the following results in a point intersection:

  1  2  3  4
..|..|..|..|..
------->        (start=..., end=2)
      <-------  (start=2, end=...)
Parameters:
  • lhs (Iterable[Interval]) – A set of intervals.

  • rhs (Iterable[Interval]) – A set of intervals.

  • result_strand (str (default: '.')) – The strand for the resulting intervals.

Yields:
The intersection of intervals. Overlapping intervals within either lhs

or rhs are implicitly unioned.

Return type:

Iterator[Interval]