-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodonSwap.py
More file actions
98 lines (87 loc) · 3.79 KB
/
CodonSwap.py
File metadata and controls
98 lines (87 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/python
#Copyright (c) 2015, Justin R. Klesmith
#All rights reserved.
#CodonSwap: Swap codons for synonymous mutations
import argparse
import os
#Set the author information
__author__ = "Justin R. Klesmith"
__copyright__ = "Copyright 2015, Justin R. Klesmith"
__credits__ = ["Justin R. Klesmith", "Timothy A. Whitehead"]
__license__ = "BSD-3"
__version__ = "0.2, Build: 20151006"
__maintainer__ = "Justin R. Klesmith"
__email__ = ["klesmit3@msu.edu", "justinklesmith@gmail.com", "justinklesmith@evodyn.com"]
#Get commandline arguments
parser = argparse.ArgumentParser(description='CodonSwap '+__version__+' for swapping codons to synomymous mutations')
parser.add_argument('-w', dest='wildtype', action='store', nargs='?', const=1, default='./WTSeq', help='File with the wild-type DNA sequence. Default = ./WTSeq')
args = parser.parse_args()
if os.path.isfile(args.wildtype):
with open(args.wildtype, 'r') as infile: #Open the file with the wild-type DNA sequence
WTSeq = infile.readline() #Read the first line of the WT sequence file
else:
print "Missing the wild-type DNA sequence file. Flag: -w or a file named WTSeq in the ./ directory. ...exit"
quit()
AA_Table = '*ACDEFGHIKLMNPQRSTVWY'
Codon_Table = {'TTT':'F', 'TCT':'S', 'TAT':'Y', 'TGT':'C',
'TTC':'F', 'TCC':'S', 'TAC':'Y', 'TGC':'C',
'TTA':'L', 'TCA':'S', 'TAA':'*', 'TGA':'*',
'TTG':'L', 'TCG':'S', 'TAG':'*', 'TGG':'W',
'CTT':'L', 'CCT':'P', 'CAT':'H', 'CGT':'R',
'CTC':'L', 'CCC':'P', 'CAC':'H', 'CGC':'R',
'CTA':'L', 'CCA':'P', 'CAA':'Q', 'CGA':'R',
'CTG':'L', 'CCG':'P', 'CAG':'Q', 'CGG':'R',
'ATT':'I', 'ACT':'T', 'AAT':'N', 'AGT':'S',
'ATC':'I', 'ACC':'T', 'AAC':'N', 'AGC':'S',
'ATA':'I', 'ACA':'T', 'AAA':'K', 'AGA':'R',
'ATG':'M', 'ACG':'T', 'AAG':'K', 'AGG':'R',
'GTT':'V', 'GCT':'A', 'GAT':'D', 'GGT':'G',
'GTC':'V', 'GCC':'A', 'GAC':'D', 'GGC':'G',
'GTA':'V', 'GCA':'A', 'GAA':'E', 'GGA':'G',
'GTG':'V', 'GCG':'A', 'GAG':'E', 'GGG':'G'}
EColi_Table = {'TTT':'TTC', 'TCT':'AGC', 'TAT':'TAC', 'TGT':'TGC',
'TTC':'TTT', 'TCC':'AGC', 'TAC':'TAT', 'TGC':'TGT',
'TTA':'CTG', 'TCA':'AGC', 'TAA':'TAA', 'TGA':'TAA',
'TTG':'CTG', 'TCG':'AGC', 'TAG':'TGA', 'TGG':'TGG',
'CTT':'CTG', 'CCT':'CCG', 'CAT':'CAC', 'CGT':'CGC',
'CTC':'CTG', 'CCC':'CCG', 'CAC':'CAT', 'CGC':'CGT',
'CTA':'CTG', 'CCA':'CCG', 'CAA':'CAG', 'CGA':'CGT',
'CTG':'CTG', 'CCG':'CCA', 'CAG':'CAA', 'CGG':'CGC',
'ATT':'ATC', 'ACT':'ACC', 'AAT':'AAC', 'AGT':'AGC',
'ATC':'ATT', 'ACC':'ACG', 'AAC':'AAT', 'AGC':'TCT',
'ATA':'ATT', 'ACA':'ACC', 'AAA':'AAA', 'AGA':'CGT',
'ATG':'ATG', 'ACG':'ACC', 'AAG':'AAA', 'AGG':'CGC',
'GTT':'GTG', 'GCT':'GCG', 'GAT':'GAC', 'GGT':'GGC',
'GTC':'GTA', 'GCC':'GCG', 'GAC':'GAT', 'GGC':'GGT',
'GTA':'GTC', 'GCA':'GCG', 'GAA':'GAG', 'GGA':'GGC',
'GTG':'GTT', 'GCG':'GCC', 'GAG':'GAA', 'GGG':'GGT',}
def main():
#Write out preamble
print "CodonSwap - Swap codons to synonymous codons (optimized for E.coli codon usage)"
print "Author: "+__author__
print "Contact: "+__email__[0]+", "+__email__[1]+", "+__email__[2]
print __copyright__
print "Version: "+__version__
print "License: "+__license__
print "Credits: "+__credits__[0]+", "+__credits__[1]
print ""
print "Please cite:"
print "Github [user: JKlesmith] (www.github.com)"
print ""
WTASeq = ""
NewDNASeq = ""
NewAASeq = ""
for i in xrange(0,(len(WTSeq)/3)):
WTASeq = WTASeq + str(Codon_Table[WTSeq[i*3:i*3+3]])
NewDNASeq = NewDNASeq + str(EColi_Table[WTSeq[i*3:i*3+3]])
NewAASeq = NewAASeq + str(Codon_Table[EColi_Table[WTSeq[i*3:i*3+3]]])
print "Wild-type DNA sequence"
print WTSeq.rstrip('\r\n')
print "Codon swapped DNA sequence"
print NewDNASeq
print "Wild-type amino acid sequence"
print WTASeq
print "Codon swapped amino acid sequence"
print NewAASeq
if __name__ == '__main__':
main()