def get_chunks(lo, hi, size, overlap=500):
    """
    Divides a range into chunks of maximum size size. Returns a list of
    2-tuples (slice_range, process_range), each a 2-tuple (start, end).
    process_range has zero overlap and should be given to process_chromosome
    as-is, and slice_range is overlapped and should be used to slice the
    data (using get_window) to be given to process_chromosome.
    """
    chunks = []
    for start_index in range(lo, hi, size):
        process_start = start_index
        # Don't go over upper bound
        process_end = min(start_index + size, hi)
        # Don't go under lower bound
        slice_start = max(process_start - overlap, lo)
        # Don't go over upper bound
        slice_end = min(process_end + overlap, hi)
        chunks.append(((slice_start, slice_end), (process_start, process_end)))
    return chunks