[Shootout-list] Python Reverse Complement
Daniel Skiles
Daniel Skiles <dskiles@gmail.com>
Tue, 15 Mar 2005 12:33:40 -0500
------=_Part_474_10427698.1110908020324
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
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
------=_Part_474_10427698.1110908020324
Content-Type: text/plain; name="reverseComp.py"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="reverseComp.py"
import sys
comps =3D {'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] =3D=3D ">":
return line
else:
return ''.join([comps[x] for x in line.upper()])
f =3D file('fastaOut.txt', 'w')
sys.stdout.writelines(["%s\n" % (flip(x.strip())) for x in sys.stdin])
------=_Part_474_10427698.1110908020324--