-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_em.py
65 lines (54 loc) · 1.8 KB
/
run_em.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
import subprocess as sp
# Give initial filenames
initial_filename = "conf.gro"
top_filename = "topol.top"
energy_minim_filename = "minim.mdp"
gromppRun1 = sp.run(["gmx",
"grompp",
"-f", energy_minim_filename,
"-c", initial_filename,
"-p", top_filename,
"-o", "em1.tpr"],
capture_output=True)
MDRun1 = sp.run(["gmx",
"mdrun",
"-deffnm", "em1",
"-v"],
capture_output=True)
MDout1 = MDRun1.stderr
output1 = MDout1.splitlines()
disp1 = output1[-7:-3]
PE1 = float(disp1[1][-14:])
msg_start = '-----------------------EM Run 1-----------------------'
sp.run(["echo", msg_start])
for line in disp1:
sp.run(["echo", line])
for i in range(2, 1000):
filename = "em" + str(i - 1) + ".gro"
out = "em" + str(i) + ".tpr"
outname = "em" + str(i)
gromppRun2 = sp.run(["gmx",
"grompp",
"-f", energy_minim_filename,
"-c", filename,
"-p", top_filename,
"-o", out],
capture_output=True)
MDRun2 = sp.run(["gmx",
"mdrun",
"-deffnm", outname,
"-v"],
capture_output=True)
MDout2 = MDRun2.stderr
output2 = MDout2.splitlines()
disp2 = output2[-7:-3]
PE2 = float(disp2[1][-14:])
msg_start = '-----------------------EM Run' + \
' ' + str(i) + '-----------------------'
sp.run(["echo", msg_start])
for line in disp2:
sp.run(["echo", line])
if PE2 == PE1:
sp.run(["echo", "-------------------------Done!-------------------------"])
break
PE1 = PE2