def replace_variant(ref, variant, start, stop=None):
    """Take a string, ref. Insert a string variant that replaces the bases
    in ref from start to stop, inclusive.
    start and stop are 0-based Pythonic coordinates
    if stop is None, the variant will simply be inserted before the start base
    """
    if stop == None:
        stop = start
    assert stop >= start
    assert start > 0 and stop > 0
    assert start <= len(ref)
    assert stop <= len(ref)
    return ref[:start] + variant + ref[stop:]