def maskSequence(sequence, regions, mask_char="N"):
    """mask sequence with regions."""
    nmasked = 0
    v = array.array('c')
    v.fromstring(sequence)
    errors = []
    for start, end in regions:

        if start < 0 or end > len(sequence):
            errors.append("out of bounds: %i-%i" % (start, end))
            continue

        for x in range(start, end):
            if v[x] != mask_char:
                v[x] = mask_char
                nmasked += 1

    return v.tostring(), nmasked, errors
dataset/ETHPy150Open CGATOxford/cgat/scripts/mask_fasta.py/maskSequence/original