[Shootout-list] reverse-complement (new) benchmark: Python program
Tim Rowe
tim at digitig.co.uk
Sun Apr 23 22:54:52 UTC 2006
Here is a rudimentary stab at this (is this the right way to submit?)
Tested under Python 2.4, but should work under any reasonably recent version.
------------------------------- snip -------------------------------
from string import maketrans, translate, join
from sys import stdin
trans = maketrans("acgttumrwsykvhdbnACGTTUMRWSYKVHDBN", "TGCAAAKYWSRMBDHVNTGCAAAKYWSRMBDHVN")
linelength = 60
def printRevBlock(block):
blockList = list(block)
blockList.reverse()
blockList = join(blockList, "")
while len(blockList) > linelength:
print blockList[:linelength]
blockList = blockList[linelength:]
if blockList:
print blockList
infile = open("comp_in.txt")
block = ""
for line in stdin.readlines():
if line[0] == ">":
if block:
printRevBlock(block)
block = ""
print line.strip()
else:
block += translate(line.strip(), trans)
if block:
printRevBlock(block)
------------------------------- snip -------------------------------
Regards,
Tim
ICQ#: 14895139
IMPORTANT - ANTI-DISCLAIMER - This email is not and cannot, by its nature, be confidential. En route from me to you, it will pass across the public Internet, easily readable by any number of system
administrators along the way. If you have received this message by mistake, it would be ridiculous for me to tell you not to read it or copy to anyone else, because, let's face it, if it's a message revealing
confidential information or that could embarrass me intensely, that's precisely what you'll do. Who wouldn't? Likewise, it is superfluous for me to claim copyright in the contents, because I own that anyway,
even if you print out a hard copy or disseminate this message all over the known universe. I don't know why so many corporate mail servers feel impelled to attach a disclaimer to the bottom of every email
message saying otherwise. If you don't know either, why not email your corporate lawyers and system administrators and ask them why they insist on contributing so much to the waste of bandwidth.
More information about the Shootout-list
mailing list