def extend_realign_region(row, read_cigar):
    """
    This part is separated from the original modify_realign_region.

    Because minimap use bonus strategy on the splice site, There might be a long deletion or insertion beside the
    splice site. In case to make sure that the realign start do not begin with a deletion or the realign end do not
    end with a insertion and deletion, we need to extend the boundary of the realign region when the case happen.

    Shown as follows:

    Deletion:
    Start:  ... End:
      # @         @ #
    ATGCA       GCTTC
    AT--A       GC--C
        @           @

    Insertion:
    Start:  ... End:
        @           @
    AT--A       GC--C
    ATGCA       GCTTC
      # @         @ #

    The symbol '@' means the original position of ref_start/end (above the sequence) and query_start/end (below the
    sequence); The symbol '#' means the position after modification.
    """
    try:
        left_slice_group = read_cigar.cslice(end_ci=row['realign_start_ci'])[-1
            ]
        if left_slice_group[1] in {'D', 'I'}:
            if left_slice_group[1] == 'D':
                row['realign_start'] -= left_slice_group[0]
            else:
                row['realign_start_rdp'] -= left_slice_group[0]
            if row['realign_start_ci'][1] == 0:
                row['realign_start_ci'] = row['realign_start_ci'][0] - 1, 0
            else:
                row['realign_start_ci'] = row['realign_start_ci'][0], 0
    except IndexError:
        pass
    try:
        right_slice_group = read_cigar.cslice(start_ci=row['realign_end_ci'])[0
            ]
        if right_slice_group[1] in {'D', 'I'}:
            if right_slice_group[1] == 'D':
                row['realign_end'] += right_slice_group[0]
            else:
                row['realign_end_rdp'] += right_slice_group[0]
            row['realign_end_ci'] = row['realign_end_ci'][0] + 1, 0
    except IndexError:
        pass
    return row
