Friday, October 9, 2015

Determine Whether Two Regions Overlap

Say we have two genomic regions (x1,x2) and (y1,y2) from the same chromosome. The simplest way to check whether the two regions overlap is perhaps testing:
x1 <= y2 && y1 <= x2
assuming x1 <= x2 and y1 <= y2.

Reference:
http://stackoverflow.com/questions/3269434/whats-the-most-efficient-way-to-test-two-integer-ranges-for-overlap

No comments: