parse codon nucleotide positions in range start -> end, wrt strand

def parse_codons(ref, start, end, strand):
    """
    parse codon nucleotide positions in range start -> end, wrt strand
    """
    codon = []
    c = cycle([1, 2, 3])
    ref = ref[start - 1:end]
    if strand == -1:
        ref = rc_stats(ref)
    for pos in ref:
        n = next(c)
        codon.append(pos)
        if n == 3:
            yield codon
            codon = []