-
Notifications
You must be signed in to change notification settings - Fork 8
/
makeParm.py
executable file
·128 lines (105 loc) · 3.77 KB
/
makeParm.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
#!/usr/bin/env python
#######################################################################
# #
# This script will create an amber prmtop taking command-line options #
# using tleap. More options will be added as they're needed. #
# #
# Written by Jason Swails (last updated 12-19-2009) #
# #
#######################################################################
import sys, utilities, os
def printusage():
print "Usage: makeParm.py -ff frc_fld \\ (Default leaprc.ff99SB)"
print " -ci 0,1,or 2\\ (Counterions, default 0)"
print " -sol dist \\ (Solvate shell distance," \
+ " Default 0)"
print " -cph \\ (Turns on constant pH setup)"
print " -pdb pdbfile\\ (no default)"
print " -run \\ (Runs tleap after script written)"
print " -radii option \\ (Default \"\")"
print "Last option asks whether to run tleap automatically, " + \
"or just create the leap.in script."
if len(sys.argv) == 1:
printusage()
sys.exit()
if "-help" in sys.argv[1].lower():
printusage()
sys.exit()
frc_fld = "leaprc.ff99SB"
ci = 0
sol = 0
cph = "no"
run = "no"
pdb = ""
radii = ""
infiles = False
try:
for x in range(len(sys.argv)):
if sys.argv[x].lower() == "-ff":
frc_fld = sys.argv[x+1]
elif sys.argv[x].lower() == "-ci":
ci = int(sys.argv[x+1])
elif sys.argv[x].lower() == "-sol":
sol = float(sys.argv[x+1])
elif sys.argv[x].lower() == "-run":
run = "yes"
elif sys.argv[x].lower() == "-pdb":
pdb = sys.argv[x+1]
elif sys.argv[x].lower() == "-cph":
cph = "yes"
except IndexError:
print >> sys.stderr, "Error: Command line error!"
sys.exit()
except ValueError:
print >> sys.stderr, "Error: Command line error!"
sys.exit()
print "Removing py_leap.in"
os.system("rm -f py_leap.in")
leapfile = open("py_leap.in","w")
leapfile.write("source " + frc_fld + "\n")
#### BEGIN INPUT FILE TYPES ####
if pdb != "":
if utilities.fileexists(pdb) == -1:
leapfile.close()
os.system("rm -f py_leap.in")
sys.exit()
leapfile.write("l = loadpdb " + pdb + "\n")
infiles = True
#### END INPUT FILE TYPES ####
if not infiles:
print "Error: You have not specified any structures!"
leapfile.close()
os.system("rm -f py_leap.in")
sys.exit()
if ci == 1:
leapfile.write("addIons l Na+\n")
elif ci == 2:
if pdb != "":
residue_decmp = utilities.getresdecmp_pdb(pdb)
if len(residue_decmp) == 0:
print "Not ready yet..."
leapfile.close()
os.system("rm -f py_leap.in")
sys.exit()
leapfile.write("addIons l Na+ " + str(residue_decmp[21]) + \
" Cl- " + str(residue_decmp[20]) + "\n")
if sol > 0:
leapfile.write("solvateOct l TIP3PBOX " + str(sol) + "\n")
if radii != "" and cph == "no":
leapfile.write("set default PBRadii " + radii + "\n")
if cph == "yes":
if sol > 0:
print "Error: constant pH and explicit solvent are incompatible!"
leapfile.close()
os.system("rm -f py_leap.in")
sys.exit()
if radii != "mbondi2" and radii != "":
print "Warning: Reference energies calculated with mbondi2. " + \
" MBONDI2 radii will be used!"
leapfile.write("set default PBRadii mbondi2\n")
leapfile.write("loadOFF constph.lib\n")
leapfile.write("loadAmberParams frcmod.constph\n")
leapfile.write("saveAmberParm l prmtop inpcrd\nquit\n")
leapfile.close()
if run == "yes":
os.system("sleap -f py_leap.in")