Generate all combinations of nucleotide k-mers between range(i, j)

Viewed 1242

I need to generate a list of all possible nucleotide combination of length between 5-15.

nucleotides = ['A', 'T', 'G', 'C']

Expected results:

AAAAA
AAAAT
AAAAC
AAAAG
AAATA
AAATT
...
AAAAAAAAAAAAAAA
AAAAAAAAAAAAAAT
etc.

I tried:

for i in range(5,16):
    for j in itertools.permutations(nucleotides, i):
        print j

But this doesn't work if len(nucleotides) < i.

Thanks in advance!

3 Answers
Related