Loop from 'aaaa' to 'tttt' ?

Glauco glauco at sferacarta.com
Tue Jun 17 16:46:02 CEST 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?
> 
> Lars

seq = ( 'a' , 'c' , 'g' , 't' )
for x1 in seq:
     for x2 in seq:
           for x3 in seq:
               forx4 in seq:
                  print "%s%s%s%s" % (x1, x2, x3, x4 )

something like this ?
Glauco





More information about the Python-list mailing list