As part of a larger analysis, I need to evaluate pairs of genomic regions (regionsA
and regionsB
) and perform different calculations for each pair depending on whether:
- They're completely separate (no overlap)
regionsB
partially overlapsregionsA
(start or end ofregionsB
does not overlap; both are handled separately)regionsB
is fully contained inregionsA
At this time, regionsA
and regionsB
are represented as Pandas DataFrames. Likewise, I'm doing all possible combinations:
if (region_b.start < region_a.start and
region_b.end < region_b.start):
[...]
elif (region_b.start < region_a.start and
(region_b.end > region_a.start
and region_b.end < region_a.end )):
Given that there are many conditions I check for, this makes the code long, a little hard to read, and too verbose. Is there anything I can use (without making the code harder to read) to make these checks simpler, something like PyRanges (or PyRanges itself, although I don't think there's API for it)?
If not, I'll just live with what I have.