[Shootout-list] Python Reverse Complement
Isaac Gouy
igouy2@yahoo.com
Tue, 15 Mar 2005 11:37:10 -0800 (PST)
There are some more comments on reverse complement here:
http://groups-beta.google.com/group/comp.lang.tcl/browse_thread/thread/1a72f10772a8d256/c011a715b6d6974e#c011a715b6d6974e
--- Daniel Skiles <dskiles@gmail.com> wrote:
> Hey all,
> If I understand the reverse complement benchmark properly, I think
> that I have one to fill in the Python slot. Let me know if it isn't
> what you want.
>
> Daniel
> > import sys
>
> comps = {'A':"T", 'C':"G", 'G':"C", 'T':"A",
> 'B':"V", 'D':"H", 'H':"D", 'K':"M",
> 'M':"K", 'R':"Y", 'V':"B", 'Y':"R",
> 'W':'W', 'N':'N', 'S':'S'}
>
> def flip(line):
> if line[0] == ">":
> return line
> else:
> return ''.join([comps[x] for x in line.upper()])
>
> f = file('fastaOut.txt', 'w')
> sys.stdout.writelines(["%s\n" % (flip(x.strip())) for x in sys.stdin])
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/