-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysBuilder.py
66 lines (58 loc) · 2.17 KB
/
sysBuilder.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
from shutil import copyfile, rmtree
from os import mkdir, chdir, getcwd
import subprocess
import sys
''' Class to run MD system builders on cage models '''
##------------------------------------------------------------------------------------------------------------
class sysBuilder:
# st is a list that contains a structure and its name
# path should be the desmond working directory
# constructor
def __init__(self, st, path):
self.st = st
self.path = path
self.jobName = self.st[1] + "_setup"
self.bashCommand = '"${SCHRODINGER}/utilities/multisim" -JOBNAME ' + self.jobName + ' -m ' \
+ self.jobName + '.msj ' + self.jobName + '.mae -o ' + self.jobName + \
"-out.cms -HOST localhost -TMPLAUNCHDIR -ATTACHED"
# generate new folder
self.dst = self.path + self.st[1] + "_setup/" + self.st[1] + "_setup" + ".mae"
try:
mkdir(self.path + self.st[1] + "_setup/")
except:
rmtree(self.path + self.st[1] + "_setup/")
mkdir(self.path + self.st[1] + "_setup/")
##------------------------------------------------------------------------------------------------------------
# method to move mae to job folder
def moveMAE(self):
copyfile(self.st[0], self.dst)
##------------------------------------------------------------------------------------------------------------
# method to write .msj
def writeMSJ(self):
msg = '''task {
task = "desmond:auto"
}
build_geometry {
add_counterion = {
ion = Na
number = neutralize_system
}
box = {
shape = cubic
size = 15.0
size_type = buffer
}
override_forcefield = OPLS3e
rezero_system = false
solvent = SPC
}
assign_forcefield {
forcefield = OPLS3e
}'''
msj = open(self.path + self.st[1] + "_setup/" + self.st[1] + "_setup.msj", "w")
msj.write(msg)
msj.close()
##------------------------------------------------------------------------------------------------------------
# method to run system builder
def run(self):
subprocess.Popen(self.bashCommand, shell=True, cwd=self.path + self.st[1] + "_setup")