def n_intervals(sequence, N='N'):
    """
	Given a sequence, yield all intervals containing only N characters as
	tuples (start, stop). If the sequence is a bytes/bytearray object,
	set N=ord(b'N')

	>>> list(n_intervals('ACGTnNAC'))
	[(4, 6)]
	>>> list(n_intervals(b'ACGTnNAC', N=ord(b'N')))
	[(4, 6)]
	"""
    sequence = sequence.upper()
    start = sequence.find(N)
    while start >= 0:
        stop = start + 1
        while stop < len(sequence) and sequence[stop] == N:
            stop += 1
        yield start, stop
        start = sequence.find(N, stop)
