INNER CODE UNIT · Python
parse_intervals
cbg-ethz/V-pipe · workflow/scripts/alignmentIntervals.py:144
def parse_intervals(
input_file,
union_intervals,
intersection_intervals,
shorah,
reference_file,
window_len,
window_shift,
):
def merge_regions(intervals_new, intervals_old):
"""
Merge intervals by:
(1) sorting the intervals in decreasing order, and
(2) iterate through intervals, comparing the current interval with the
last one. If the interval overlap, merge both intervals into one
"""
intervals = intervals_old + intervals_new
intervals_sorted = sorted(intervals, key=lambda tup: tup[0])