-
Notifications
You must be signed in to change notification settings - Fork 0
/
avf.py
executable file
·244 lines (209 loc) · 6.4 KB
/
avf.py
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/usr/bin/env python
# **************************************************
# ..................................................
# Assemble variant files
# ..................................................
# **************************************************
# DESCRIPTION:
# The variant structure files are being assembled
# from sequence files. Each sequence file contains the
# data of one side chain and every mutant has a
# fragment file.
# This script writes the BASH script which assembles
# the final mutant structure file(s).
# The variants are entered at the end of the script.
# CALLING SEQUENCE:
# $ python asv.py {1,3} -> seq.sh
# $ bash seq.sh
# PARAMETERS (search for by <<PARAM>>):
# - Reactant [= '1'] or product [= '3'] state files:
import sys
state=sys.argv[1]
# Available backbone sequence fragements.
chain =\
['seq-v37',\
'seq-p38',\
'seq-g39',\
'seq-t40',\
'seq-g41',\
'seq-t42',\
'seq-t43',\
'seq-g44',\
'seq-p45',\
'seq-q46',\
'seq-s47',\
'seq-f48',\
'seq-d49',\
'seq-s50',\
'seq-l102',\
'seq-t103',\
'seq-w104',\
'seq-s105',\
'seq-q106',\
'seq-f131',\
'seq-a132',\
'seq-p133',\
'seq-d134',\
'seq-y135',\
'seq-v139',\
'seq-l140',\
'seq-a141',\
'seq-q156',\
'seq-q157',\
'seq-t158',\
'seq-t186',\
'seq-d187',\
'seq-e188',\
'seq-i189',\
'seq-v190',\
'seq-q191',\
'seq-p192',\
'seq-f220',\
'seq-v221',\
'seq-i222',\
'seq-d223',\
'seq-h224',\
'seq-a225',\
'seq-g226',\
'seq-l277',\
'seq-l278',\
'seq-a279',\
'seq-p280',\
'seq-a281',\
'seq-a282',\
'seq-a283',\
'seq-a284',\
'seq-i285',\
'seq-v286',\
'seq-a287',\
'seq-x500',
'seq-x550']
def writeCatSeq(variant):
# Convenience list of variants, replacing the '+'.
varlist = variant.split('+')
# Initialization of the bash script
# Escaping BASH syntax.
# Resetting content of mutant structure file.
numOfMutations = len(variant.split('+'))
# <<PARAM>>:
# - Reactant or product state file: '?-res'
# - Initial file or optimization job file: '-opt'.
writeSeq =\
'# ' + '*'*50 + '\n' +\
'# ' + '-'.join(variant.split('+')) + '\n' +\
'# ' + str(numOfMutations) + '-fold mutant.\n' +\
'# Resetting mutant file content.\n' +\
'echo ' + '%'*50 + '\n'\
'echo "Generating variant structure file of mutant:"\n' +\
'echo ' + variant + '\n' +\
'echo ' + '-'*50 + '\n'\
'echo ' + '\n' +\
'echo ' + '\n' +\
'cat /dev/null > %s-res-' % state + '-'.join(varlist) + '-ste-ini.pdb\n' +\
'for i in\\\n' +\
' {'
# Defining a list which contains only the numbers of the
# residues that will be mutated.
# First recast from 'G39A+L278A' form to ['G39A', 'L278A'],
# then generate a list with only numbers ['39', '278'].
varTmp = variant.split('+')
varNum = [i[1:-1] for i in varTmp]
for s in chain:
# Checking if the number of the residue is in the ones
# to be mutated, if so, then the write sequence is
# adjusted.
if s[5:] in varNum:
# Locate the index of the side chain which needs
# to be mutated, then choose the corresponding index
# in the varTmp list.
ind=varNum.index(s[5:])
writeSeq += 'frag-' + variant.split('+')[ind].lower() + ',\\\n'
else:
# Appending of the WT backbone.
writeSeq += s + ',\\\n'
# <<PARAM>>:
# - Reactant or product state file: '?-res'
# - Initial file or optimization job file: '-opt'.
writeSeq += '}\n' +\
'do\n' +\
' cat $i-%s.pdb >> %s-res-' % (state, state) + '-'.join(varlist) + '-ste-ini.pdb\n' +\
'done\n' +\
'grep -v \'END\' ' + '%s-res-' % state + '-'.join(varlist) + '-ste-ini.pdb > tmp.pdb\n' +\
'mv tmp.pdb ' + '%s-res-' % state + '-'.join(varlist) + '-ste-ini.pdb\n\n\n'
return writeSeq
if __name__ == '__main__':
# **************************************************
# Variant library.
# Sorted by charge.
# 'charge=-4':
vars=[
#'G39A',
#'T103G',
#'W104F',
#'W104Y',
#'W104Q',
#'I189Q',
#'I189N',
#'G39A+T103G',
#'G39A+W104F',
#'G39A+W104Y',
#'G39A+W104Q',
#'G39A+L278G',
#'G39A+L278A',
#'T103G+W104F',
#'T103G+W104Y',
#'T103G+W104Q',
#'W104F+L278A',
#'W104Y+L278A',
#'W104Q+L278A',
#
#'G39A+T103G+W104F',
#'G39A+T103G+W104Y',
#'G39A+T103G+W104Q',
#'G39A+W104F+L278A',
#'G39A+W104Y+L278A',
#'G39A+W104Q+L278A',
#'G39A+W104F+L278G',
#'G39A+W104Y+L278G',
#'G39A+W104Q+L278G',
#'T103G+W104F+L278A',
#'T103G+W104Y+L278A',
#'T103G+W104Q+L278A',
#'W104F+A225K+L278A',
#'T103G+W104F+L278G',
#'T103G+W104Y+L278G',
#'T103G+W104Q+L278G',
#'G39A+T103G+W104F+L278A',
#'G39A+T103G+W104Y+L278A',
#'G39A+T103G+W104Q+L278A',
#'G39A+W104F+A225K+L278A',
#'G39A+T103G+W104F+L278G',
#'G39A+T103G+W104Y+L278G',
#'G39A+T103G+W104Q+L278G',
#'G39A+W104F+T103G+L140Q+A141N+I189N',
#'G39A+W104F+T103G+L140Q+A141N+I189Q',
#'G39A+W104F+T103G+L140Q+A141Q+I189N',
#'G39A+W104F+T103G+L140Q+A141Q+I189Q',
#'G39A+W104F+T103G+L140N+A141N+I189N',
#'G39A+W104F+T103G+L140N+A141N+I189Q',
#'G39A+W104F+T103G+L140N+A141Q+I189N',
#'G39A+W104F+T103G+L140N+A141Q+I189Q',
'G39A+W104F+D223N+A225I+L278A',
#'L278G+W104F+A225M+Q157V+I189A+D134A',
#'T40G+L278G+W104F+A225M+Q157V+I189A+D134A'
]
#---------------------------------------------------
#***********************
# Reset the sequence script.
seqFile = open('seq.sh', 'w')
seqFile.close()
seqFile = open('seq.sh', 'a')
#-----------------------
#***********************
# Generating the 'seq.sh' script
for variant in vars:
seqFile.write(writeCatSeq(variant))
seqFile.close()
#-----------------------
# EOF
#------------------------------------------------------