Loop from 'aaaa' to 'tttt' ?
rzed
Dick.Zantow at lexisnexis.com
Mon Jun 16 13:31:16 EDT 2003
Lars Schaps wrote:
> Hello.
>
> In my program in need a loop from 'aaaa' over
> 'aaac', 'aaag', 'aaat', 'aaca' to 'tttt'.
> (Possible characters 'a', 'c', 'g' and 't')
>
> One idea i had is to take a number n with the base of
> 4 and use
>
> t= string.translate( '0123', 'acgt')
> string.translate( n, t)
>
> But i don't know how to convert from base10 to base4.
>
> Has anyone a idea?
>
I'm not sure if this is at like what you had in mind, but:
ltrs = 'acgt'
for a in ltrs:
for c in ltrs:
for g in ltrs:
for t in ltrs:
print '%s%s%s%s' % (a,c,g,t)
--
rzed
More information about the Python-list
mailing list