-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvmd_tcl_script_bl_ba_generator.py
167 lines (163 loc) · 9.79 KB
/
vmd_tcl_script_bl_ba_generator.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
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 13 15:17:09 2020
@author: ashraya
"""
'''
#infile=open("/home/ashraya/RMap_Work/2vb1_simulation/2vb1_one_fs/2vb1_1_fs_nowater.gro","r")
infile=open("/home/ashraya/RMap_Work/rmap_dynamics/2vb1_charmm/2vb1_no_water.gro","r")
opfile=open("/home/ashraya/RMap_Work/rmap_dynamics/2vb1_charmm/2vb1_vmd_ba_script.tcl","w")
prev_res=1
atoms_to_consider=['C','CA','CB','HN','N','O','HA']
atom_index=dict()
for line in infile:
resno=int(line[0:5])
resname=line[5:8].strip()
if resno==prev_res:
atom_name=line[10:15].strip()
if atom_name in atoms_to_consider:
atom_index[atom_name]=int(line[15:20])-1
prev_res=resno
prev_resname=resname
elif resno!=prev_res:
print resno
atom_name=line[10:15].strip()
if atom_name=="N":
atom_index["N2"]=int(line[15:20])-1
opfile.write('set output [open "'+str(prev_res)+'_N_CA_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["N"])+' '+str(atom_index["CA"])+'} first 1]\n')
opfile.write('close $output\n')
if prev_res!=1 and prev_resname!="PRO":
opfile.write('set output [open "'+str(prev_res)+'_N_H_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["N"])+' '+str(atom_index["HN"])+'} first 1]\n')
opfile.write('close $output\n')
if prev_resname!="GLY":
opfile.write('set output [open "'+str(prev_res)+'_CA_CB_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["CA"])+' '+str(atom_index["CB"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CA_HA_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["CA"])+' '+str(atom_index["HA"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CA_C_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["CA"])+' '+str(atom_index["C"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_C_O_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["C"])+' '+str(atom_index["O"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_C_N_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["C"])+' '+str(atom_index["N2"])+'} first 1]\n')
opfile.write('close $output\n')
if prev_res!=1 and prev_resname!="PRO":
opfile.write('set output [open "'+str(prev_res)+'_H_N_CA_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["HN"])+' '+str(atom_index["N"])+' '+str(atom_index["CA"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_N_CA_C_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["N"])+' '+str(atom_index["CA"])+' '+str(atom_index["C"])+'} first 1]\n')
opfile.write('close $output\n')
if prev_resname!="GLY":
opfile.write('set output [open "'+str(prev_res)+'_N_CA_CB_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["N"])+' '+str(atom_index["CA"])+' '+str(atom_index["CB"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CB_CA_HA_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["CB"])+' '+str(atom_index["CA"])+' '+str(atom_index["HA"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_N_CA_HA_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["N"])+' '+str(atom_index["CA"])+' '+str(atom_index["HA"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CB_CA_C_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["CB"])+' '+str(atom_index["CA"])+' '+str(atom_index["C"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_HA_CA_C_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["HA"])+' '+str(atom_index["CA"])+' '+str(atom_index["C"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CA_C_O_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["CA"])+' '+str(atom_index["C"])+' '+str(atom_index["O"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CA_C_N_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["CA"])+' '+str(atom_index["C"])+' '+str(atom_index["N2"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_O_C_N_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["O"])+' '+str(atom_index["C"])+' '+str(atom_index["N2"])+'} first 1]\n')
opfile.write('close $output\n')
atom_index=dict()
if atom_name in atoms_to_consider:
atom_index[atom_name]=int(line[15:20])-1
prev_res=resno
prev_resname=resname
infile.close()
opfile.write('set output [open "'+str(prev_res)+'_N_CA_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["N"])+' '+str(atom_index["CA"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_N_H_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["N"])+' '+str(atom_index["HN"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CA_CB_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["CA"])+' '+str(atom_index["CB"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CA_HA_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["CA"])+' '+str(atom_index["HA"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CA_C_bond.txt" w]\n')
opfile.write('puts $output [measure bond {'+str(atom_index["CA"])+' '+str(atom_index["C"])+'} first 1]\n')
opfile.write('close $output\n')
if prev_res!=1 and prev_resname!="PRO":
opfile.write('set output [open "'+str(prev_res)+'_H_N_CA_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["HN"])+' '+str(atom_index["N"])+' '+str(atom_index["CA"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_N_CA_C_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["N"])+' '+str(atom_index["CA"])+' '+str(atom_index["C"])+'} first 1]\n')
opfile.write('close $output\n')
if prev_resname!="GLY":
opfile.write('set output [open "'+str(prev_res)+'_N_CA_CB_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["N"])+' '+str(atom_index["CA"])+' '+str(atom_index["CB"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CB_CA_HA_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["CB"])+' '+str(atom_index["CA"])+' '+str(atom_index["HA"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_N_CA_HA_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["N"])+' '+str(atom_index["CA"])+' '+str(atom_index["HA"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_CB_CA_C_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["CB"])+' '+str(atom_index["CA"])+' '+str(atom_index["C"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.write('set output [open "'+str(prev_res)+'_HA_CA_C_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["HA"])+' '+str(atom_index["CA"])+' '+str(atom_index["C"])+'} first 1]\n')
opfile.write('close $output\n')
opfile.close()
'''
#'''
#infile=open("/home/ashraya/RMap_Work/2vb1_simulation/2vb1_one_fs/2vb1_1_fs_nowater.gro","r")
infile=open("/home/ashraya/RMap_Work/rmap_dynamics/2vb1_charmm/2vb1_no_water.gro","r")
opfile=open("/home/ashraya/RMap_Work/rmap_dynamics/2vb1_charmm/2vb1_vmd_ba_remaining_script.tcl","w")
atom_index=dict()
first=True
resnum=1
resname="LYS"
for line in infile:
cur_resnum=int(line[0:5])
cur_resname=line[5:8].strip()
atom_name=line[10:15].strip()
if atom_name=="C":
if first:
first=False
atom_index[atom_name]=int(line[15:20])-1
continue
else:
print resnum
opfile.write('set output [open "'+str(resnum)+'_C_N_CA_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["C"])+' '+str(atom_index["N"])+' '+str(atom_index["CA"])+'} first 1]\n')
opfile.write('close $output\n')
if cur_resname!="PRO":
opfile.write('set output [open "'+str(resnum)+'_C_N_H_angle.txt" w]\n')
opfile.write('puts $output [measure angle {'+str(atom_index["C"])+' '+str(atom_index["N"])+' '+str(atom_index["HN"])+'} first 1]\n')
opfile.write('close $output\n')
atom_index=dict()
resnum=cur_resnum
resname=cur_resname
atom_index[atom_name]=int(line[15:20])-1
elif atom_name in ["N","CA","HN"]:
if cur_resnum==resnum+1:
atom_index[atom_name]=int(line[15:20])-1
infile.close()
opfile.close()
#'''