def recombine_region(genome, region, min_homology_arm_length, op,
    new_fragment_dict):
    """
    Recombines on a given region. Returns recombination cassette location, how
    many base pairs removed, how many base pairs added, new fragment id.
    new_fragment_dict is a dictionary that indicates if the region.fragment_id is already
    a newly created fragment.
    """
    region_start = region.start
    region_end = region.end
    cassette = region.cassette
    new_fragment_id = None
    is_new_fragment = region.fragment_id not in new_fragment_dict
    with genome.update_fragment_by_fragment_id(region.fragment_id,
        new_fragment=is_new_fragment) as f:
        new_fragment_dict[f.id] = 1
        replaced = 0
        if region_start < region_end:
            f.replace_bases(region_start, region_end - region_start + 1,
                cassette)
            replaced = region_end - region_start + 1
        else:
            assert f.circular is True
            f.replace_bases(region_start, f.length - region_start + 1, cassette
                )
            replaced = f.length - region_start + 1
            f.remove_bases(1, region_end)
            replaced += region_end
            region_start -= region_end
        new_fragment_id = f.id
    return region_start, replaced, len(cassette), new_fragment_id
