Le Tue, 15 Mar 2005 23:21:02 -0800, Michael Spencer a écrit :
> Jacob Lee wrote:
>> On Tue, 15 Mar 2005 21:38:48 -0800, Michael Spencer wrote:
>>
>> Good call.
>>
>>
>
> How about this then:
>
> basetable = string.maketrans('ACBDGHKMNSRUTWVYacbdghkmnsrutwvy',
> 'TGVHCDMKNSYAAWBRTGVHCDMKNSYAAWBR')
>
> from collections import deque
> from itertools import islice
>
> def output(seq, linelength = 60):
> if seq:
> iterseq = iter(seq)
> while iterseq:
> print "".join(islice(iterseq,linelength))
I suppose you mean :
print "".join( str(item) for item in islice(iterseq, linelength) )
# using python 2.4 genexp
>
> def revcomp(input = sys.stdin):
> seqlines = deque()
> for line in input:
> if line[0] in ">;":
> output(seqlines)
> print line,
> seqlines.clear()
> else:
> seqlines.extendleft(line.translate(basetable, "\n\r"))
> output(seqlines)
>
>
> It would be nice to inline the output function, and re-arrange the iteration
> so
> that EOF triggers the same suite as line[0] in ">;"
>
> Michael
>
--
http://mail.python.org/mailman/listinfo/python-list