mask (make lower case) regions of sequence found in gaps between model alignments

def mask_sequence(seq, gaps):
    """
    mask (make lower case) regions of sequence found in gaps between model alignments
    """
    seq = [i.upper() for i in seq]
    for gap in gaps:
        for i in range(gap[0] - 1, gap[1]):
            seq[i] = seq[i].lower()
    return ''.join(seq)