Loop from 'aaaa' to 'tttt' ?
Alexander Schmolck
a.schmolck at gmx.net
Tue Jun 17 11:47:38 EDT 2003
Alex Martelli <aleax at aleax.it> writes:
Just a small correction (since one of the typos is a bit confusing):
> def codonStrings(lenghtOfStrings, codons='acgt'):
def codonStrings(lengthOfStrings, codons='acgt'):
> base = len(codons)-1
> result = lengthOfStrings * [codons[0]]
result = lengthOfStrings * [0]
> while 1:
> curindex = lenghtOfStrings - 1
curindex = lengthOfStrings - 1
> while curindex >= 0 and result[curindex] >= base:
> result[curindex] = 0
> curindex -= 1
> if curindex < 0:
> break
> result[curindex] += 1
> yield ''.join( [codons[i] for i in result] )
'as
More information about the Python-list
mailing list