

def union(record_list, min_distance=0, interval_func=attrgetter('start', 'stop')):
    '\n    >>> from operator import itemgetter\n    >>> ifunc = itemgetter(0,1)\n\n    >>> l1 = [(0,1),(1,2),(2,3),(3,4),(4,5)]\n    >>> l2 = [(1,2),(3,4)]\n    >>> for start, stop, vals in union([l1,l2], 0, ifunc):\n    ...     print start, stop, vals\n    0 1 [[(0, 1)], []]\n    1 2 [[(1, 2)], [(1, 2)]]\n    2 3 [[(2, 3)], []]\n    3 4 [[(3, 4)], [(3, 4)]]\n    4 5 [[(4, 5)], []]\n\n    >>> for start, stop, vals in union([l1,l2], 1, ifunc):\n    ...     print start, stop, vals\n    0 5 [[(0, 1), (1, 2), (2, 3), (3, 4), (4, 5)], [(1, 2), (3, 4)]]\n\n    >>> l1 = [(0,5),(10,15),(20,25)]\n    >>> l2 = [(5,11),(21,21)]\n    >>> for start, stop, vals in union([l1,l2], 0, ifunc):\n    ...     print start, stop, vals\n    0 5 [[(0, 5)], []]\n    5 15 [[(10, 15)], [(5, 11)]]\n    20 25 [[(20, 25)], [(21, 21)]]\n\n    >>> l1 = [(0,5),(10,15),(20,25)]\n    >>> for start, stop, vals in union([l1, []], 0, ifunc):\n    ...     print start, stop, vals\n    0 5 [[(0, 5)], []]\n    10 15 [[(10, 15)], []]\n    20 25 [[(20, 25)], []]\n\n    >>> for start, stop, vals in union([[], l1], 0, ifunc):\n    ...     print start, stop, vals\n    0 5 [[], [(0, 5)]]\n    10 15 [[], [(10, 15)]]\n    20 25 [[], [(20, 25)]]\n    '
    n = len(record_list)
    start = stop = 0
    records = []
    for (i, rec) in iter_merge(rec_start, key=interval_func):
        (rec_start, rec_stop) = interval_func(rec)
        if ((not records) or (min_distance <= (rec_start - stop))):
            if records:
                (yield (start, stop, demultiplex_records(n, records)))
                records = []
            (start, stop) = (rec_start, rec_stop)
        assert (rec_start >= start)
        records.append((i, rec))
        stop = max(stop, rec_stop)
    if records:
        (yield (start, stop, demultiplex_records(n, records)))

dataset/ETHPy150Open bioinformed/vgraph/vgraph/intervals.py union/VarMisuse@52/772 `record_list`->`rec_start`