Hung Jung Lu wrote:
... expand = lambda t: reduce(lambda r, s: [x+y for x in r
>for y in alphabet[s]], t, [''])
print expand('ATSGS')
Or, for a more verbose version:
multis = dict(W='AT', M='AC', R='AG', Y='TC', K='TG', S='CG',
H='ATC', D='ATG'
alphabet = {
'A': 'A',
'T': 'T',
'C': 'C',
'G': 'G',
'W': 'AT',
'M': 'AC',
'R': 'AG',
'Y': 'TC',
'K': 'TG',
'S': 'CG',
'H': 'ATC',
'D': 'ATG',
'V': 'AGC',
'B': 'CTG',
'N': 'ATCG'
David Siedband wrote:
> The problem I'm solving is to take a sequence like 'ATSGS' and make all
> the DNA sequences it represents. The A, T, and G are fine but the S
> represents C or G. I want to take this input:
>
> [ [ 'A' ] , [ 'T' ] , [ 'C' , 'G' ], [ 'G' ] , [ 'C' , 'G' ] ]
>
> and make
David Siedband wrote:
> [...]
> Is there a better way to do this?
> [...]
Take a look at Biopython: http://biopython.org/
Your problem may be solved there already.
--
http://mail.python.org/mailman/listinfo/python-list
The problem I'm solving is to take a sequence like 'ATSGS' and make all
the DNA sequences it represents. The A, T, and G are fine but the S
represents C or G. I want to take this input:
[ [ 'A' ] , [ 'T' ] , [ 'C' , 'G' ], [ 'G' ] , [ 'C' , 'G' ] ]
and make the list:
[ 'ATCGC' , 'ATCGG' , 'ATG