-
Notifications
You must be signed in to change notification settings - Fork 5
/
movie.py
executable file
·163 lines (148 loc) · 6.78 KB
/
movie.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
#!/usr/bin/env python
import os
import argparse
import sys
from time import sleep
import subprocess
# import imp
from small_script.myFunctions import shrinkage
import fileinput
parser = argparse.ArgumentParser(description="written by Wei Lu.")
parser.add_argument("protein", help="The name of the protein")
parser.add_argument("-p", "--plot", help="only plot mode",
action="store_true")
# parser.add_argument("-d", "--debug", action="store_true", default=False)
parser.add_argument("-d", "--dump", default="dump.lammpstrj")
parser.add_argument("-l", "--last", action="store_true", default=False)
parser.add_argument("-m", "--mode",
type=int, default=2)
parser.add_argument("-s", "--submode",
type=int, default=-1)
parser.add_argument("-c", "--membraneCenter",
type=int, default=0)
parser.add_argument("--fix", help="convert pdb period box, number of chain", type=int, default=-1)
parser.add_argument("--mem", help="show membrane",
action="store_true")
parser.add_argument("--cys", help="show Cys",
action="store_true")
parser.add_argument("-v", "--visual", default="movie.tcl")
args = parser.parse_args()
# render Tachyon frame450.dat '/Applications/VMD 1.9.2.app/Contents/vmd/tachyon_MACOSXX86' -aasamples 12 %s -format TARGA -o frame450.tga -res 2000 2000
# print(args.dump)
do = os.system
cd = os.chdir
def replace(TARGET, FROM, TO):
os.system("sed -i.bak 's@{}@{}@g' {}".format(FROM,TO,TARGET))
def replace_v2(TARGET, FROM, TO):
with fileinput.FileInput(TARGET, inplace=True) as file:
for line in file:
tmp = line.replace(FROM, TO)
print(tmp, end='')
if args.fix >= 0:
do(f"python ~/opt/small_script/PBC_fixer.py -n {args.fix}")
if args.mode == 4 or args.mode == 5 or args.mode == 6:
# add the native as initial frames.
if args.submode == 1:
for i in range(5):
do("cat native.pdb >> tmp.pdb")
do("cat movie.pdb >> tmp.pdb")
do("mv tmp.pdb movie.pdb")
do("python ~/openmmawsem/helperFunctions/convertOpenmmTrajectoryToStandardMovie.py movie.pdb")
do("cp ~/opt/plot_scripts/movie.tcl .")
do("cp ~/opt/plot_scripts/with_membrane.tcl .")
# do("/Applications/VMD\ 1.9.3.app/Contents/MacOS/startup.command -e movie.tcl")
replace("with_membrane.tcl", "MEMUP", str(args.membraneCenter+15))
replace("with_membrane.tcl", "MEMDOWN", str(args.membraneCenter-15))
if args.mem:
plot_script = "with_membrane.tcl"
else:
plot_script = "movie.tcl"
if args.cys:
showCYS = '''\
mol selection resname CYS and type CB
mol color ColorID 0
mol addrep top
mol modstyle 1 0 VDW 1 12
mol smoothrep 0 1 5
'''
replace_v2(plot_script, "#CYS", showCYS)
if args.mode == 5:
exit()
if args.mode == 6:
do("/Applications/VMD\ 1.9.3.app/Contents/MacOS/startup.command -e ../../visual_with_ligands.vmd")
exit()
if args.visual != "movie.tcl":
plot_script = args.visual
do(f"/Applications/VMD\ 1.9.3.app/Contents/MacOS/startup.command -e {plot_script}")
protein_name = args.protein.split('.')[0]
if args.mode == 3:
# do("python3 ~/opt/small_script/delete_lammps_frame.py")
if args.submode == -1:
shrinkage(shrink_size=6, max_frame=2000,fileName=f"{args.dump}")
else:
shrinkage(shrink_size=6, max_frame=2000,fileName=f"{args.dump}.{args.submode}")
# shrinkage()
do("cp ../{}.seq .".format(protein_name))
do("python2 ~/opt/script/BuildAllAtomsFromLammps_seq.py small.lammpstrj movie "+protein_name+".seq")
do("cp ~/opt/plot_scripts/2xov_movie_bicelle.tcl .")
do("cp ~/opt/plot_scripts/movie_bicelle_no_smooth.tcl .")
do("cp ~/opt/plot_scripts/movie.tcl .")
if args.plot:
do("/Applications/VMD\ 1.9.3.app/Contents/MacOS/startup.command -e 2xov_movie_bicelle.tcl")
if args.mode == 1:
# do("python3 ~/opt/small_script/delete_lammps_frame.py")
shrinkage(shrink_size=1, max_frame=1000,fileName=f"{args.dump}")
# shrinkage()
do("cp ../{}.seq .".format(protein_name))
do("python2 ~/opt/script/BuildAllAtomsFromLammps_seq.py small.lammpstrj movie "+protein_name+".seq")
do("cp ~/opt/plot_scripts/2xov_movie_bicelle.tcl .")
do("cp ~/opt/plot_scripts/movie_bicelle_no_smooth.tcl .")
do("cp ~/opt/plot_scripts/movie.tcl .")
if args.plot:
do("/Applications/VMD\ 1.9.3.app/Contents/MacOS/startup.command -e 2xov_movie_bicelle.tcl")
if args.mode == 2:
if not args.last:
fail = do("cp ../{}.seq .".format(protein_name))
print(fail)
if fail > 0:
do(f"cp ../crystal.seq {protein_name}.seq")
if args.submode == -1:
do(f"python2 ~/opt/script/BuildAllAtomsFromLammps_seq.py {args.dump} movie "+protein_name+".seq")
else:
do(f"python2 ~/opt/script/BuildAllAtomsFromLammps_seq.py {args.dump}.{args.submode} movie "+protein_name+".seq")
# do("cp ~/opt/plot_scripts/2xov_movie_bicelle.tcl .")
# do("cp ~/opt/plot_scripts/movie_bicelle_no_smooth.tcl .")
# do("cp ~/opt/plot_scripts/2xov_movie_bicelle_no_smooth.tcl .")
# do(f"cp ~/opt/plot_scripts/{protein_name}.tcl .")
# do(f"cp ~/opt/plot_scripts/{protein_name}_no_smooth.tcl .")
do(f"cp ~/opt/plot_scripts/{protein_name}* .")
do("cp ~/opt/plot_scripts/movie.tcl .")
else:
x = os.listdir()
y = [int(int(f.split(".")[1])/1000) for f in os.listdir() if f.startswith("restart.")]
last_frame = max(y)
print("last Frame: {}".format(last_frame))
do(f"python2 ~/opt/script/BuildAllAtomsFromLammps_seq.py {args.dump} last "+protein_name+f".seq {last_frame}")
do("cp ~/opt/plot_scripts/last_frame.pml .")
do("pymol last_frame.pml")
if args.plot:
# do("/Applications/VMD\ 1.9.3.app/Contents/MacOS/startup.command -e 2xov_movie_bicelle.tcl")
if not os.path.exists(f"{protein_name}.tcl"):
do("/Applications/VMD\ 1.9.3.app/Contents/MacOS/startup.command -e movie.tcl")
else:
do(f"/Applications/VMD\ 1.9.3.app/Contents/MacOS/startup.command -e {protein_name}.tcl")
# if(args.number == -1):
# # do("cp ~/opt/pulling/2xov.seq .")
# if(not args.plot):
# os.system("python2 ~/opt/script/BuildAllAtomsFromLammps_seq.py dump.lammpstrj movie "+protein_name+".seq")
# # os.system(
# # "python2 ~/opt/script/BuildAllAtomsFromLammps.py \
# # dump.lammpstrj movie")
# else:
# os.system("ghead -n 399648 dump.lammpstrj > part_dump")
# if(not args.plot):
# os.system("python2 ~/opt/script/BuildAllAtomsFromLammps_seq.py dump.lammpstrj movie "+protein_name+".seq")
# # os.system(
# # "python2 ~/opt/script/BuildAllAtomsFromLammps.py \
# # part_dump movie")
# os.system("cp ~/opt/plot_scripts/*.tcl .")