def parse_masked(seq, min_len):
    """
    parse masked sequence into non-masked and masked regions
    """
    nm, masked = [[]], [[]]
    prev = None
    for base in seq[1]:
        if base.isupper():
            nm[-1].append(base)
            if masked != [[]] and len(masked[-1]) < min_len:
                nm.extend(masked[-1])
                del masked[-1]
            prev = False
        elif base.islower():
            if prev is False:
                masked.append([])
                nm.append([])
            masked[-1].append(base)
            prev = True
    return nm, masked
