def get_merged_agp_coordinates(agp_iterable):
    """
    merges on an iterator on directly adjacent AGP entries and returns a new
    iterator with start and end coordinates inside a tuple
    assumes AGP entries have been converted to 0-based coordinates and assume
    AGP regions are sorted based on start coordinates
    """
    current_row = next(agp_iterable)
    for agp_row in agp_iterable:
        if current_row:
            if current_row['object_end'] >= agp_row['object_beg']:
                current_row['object_end'] = agp_row['object_end']
            else:
                yield current_row['object_beg'], current_row['object_end']
                current_row = agp_row
    if current_row:
        yield current_row['object_beg'], current_row['object_end']
