forked from chinthakanadun/compchem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGaussianPrep.py
executable file
·180 lines (145 loc) · 5.41 KB
/
GaussianPrep.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
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/python
### ### ### ### ###
### ### ### ### ###
#####b. ####b. ###### .d##b. #####b. ### ####b. #####b. ###
### ### "##b "##b ### d##""##b ### "##b ### "##b ### "##b ###
### ### ### .d###### ### ### ### ### ### ### .d###### ### ###
### ### d##P ### ### Y##b. Y##..##P ### ### ### ### ### ### d##P ###
### #####P" "Y###### "Y### "Y##P" ### ### ### "Y###### #####P" ###
###
###
###############################################################
# Gaussianprep.py #
# #
# To create new *com file #
# #
# Use the following keywords (case insensitive) #
# Append - text appended to filename #
# Link0 - name of checkpoint file (default filename.chk) #
# Route - desired calculation type #
# Mem - Max allowed RAM #
# Nproc - Number of CPUs #
# Route - desired calculation type #
# Title - self-explanatory (default filename) #
# Charge - self-explanatory (defaults to 0) #
# Mult - multiplicity (defaults to 1) #
# Freeze - frozen coordinate #
# Link1 - Route section for Link1 #
# Radii - radii defining solvent-accessible surface #
# More to come... #
###############################################################
#Python Libraries
import sys, os
#Chemistry Libraries
from ChemUtils import *
from ccWrite import *
from ccParse import *
#Parse job specificiation
class getGinput:
def __init__(self,file,job):
def getAppend(self, job):
for keyword in job:
if 'APPEND' in keyword[0].upper():
self.Append = keyword[1]
if not hasattr(self, "Append"):
self.Append = "new"
def getLink0(self, file, job,append):
for keyword in job:
if 'LINK0' in keyword[0].upper():
if keyword[1].find(".chk") == -1:
self.Link0 = keyword[1]+".chk"
else: self.Link0 = keyword[1]
if not hasattr(self, "Link0"):
self.Link0 = file+"_"+append+".chk"
def getLink1(self, file, job):
for keyword in job:
if 'LINK1' in keyword[0].upper():
self.Link1 = keyword[1]
def getRoute(self,job):
for keyword in job:
if 'ROUTE' in keyword[0].upper():
self.Route = keyword[1]
if not hasattr(self, "Route"):
print "\nFATAL ERROR: no Route section specified"
sys.exit()
def getTitle(self,file, job):
for keyword in job:
if 'TITLE' in keyword[0].upper():
self.Title = keyword[1]
if not hasattr(self, "Title"):
self.Title = file
def getMem(self, job):
for keyword in job:
if 'MEM' in keyword[0].upper():
self.Mem = keyword[1]
def getNproc(self, job):
for keyword in job:
if 'NPROC' in keyword[0].upper():
self.Nproc = keyword[1]
def getLinda(self, job):
for keyword in job:
if 'LINDA' in keyword[0].upper():
self.Linda = keyword[1]
def getFreeze(self,job):
self.Freeze = []
for keyword in job:
if 'FREEZE' in keyword[0].upper():
self.Freeze.append(keyword[1])
def getRadii(self,job):
for keyword in job:
if 'RADII' in keyword[0].upper():
self.Radii = keyword[1]
def getOptional(self,job):
self.Optional = []
for keyword in job:
if 'OPTIONAL' in keyword[0].upper():
self.Optional.append(keyword[1])
getAppend(self, job)
getLink0(self, file, job, self.Append)
getRoute(self,job)
getMem(self,job)
getNproc(self,job)
getLinda(self,job)
getTitle(self, file, job)
getFreeze(self,job)
getRadii(self,job)
getOptional(self,job)
getLink1(self, file, job)
if __name__ == "__main__":
#job specifications
job = []
#input file(s)
outfiles = []
infiles = []
print sys.argv
# Takes arguments: (1) input file(s) (*out) (2) new job parameters
if len(sys.argv) > 1:
for i in range(1,len(sys.argv)):
if sys.argv[i][0:1] == "-" and sys.argv[i][0:3] != "--L":
if any(sys.argv[i+1]):
job.append([sys.argv[i],sys.argv[i+1]])
else:
if any(sys.argv[i-1]):
if sys.argv[i-1][0:1] != "-":
if len(sys.argv[1].split("."))>1:
print sys.argv[1]
if sys.argv[i].split(".")[1]=="out":
outfiles.append(sys.argv[i].split(".")[0])
if sys.argv[i].split(".")[1]=="log":
outfiles.append(sys.argv[i].split(".")[0])
if sys.argv[i].split(".")[1]=="com":
infiles.append(sys.argv[i].split(".")[0])
else:
print "\nWrong number of arguments used. Correct format: GaussianPrep file [new job parameters]\n"
sys.exit()
for file in outfiles:
Ginput = getGinput(file, job)
MolSpec = getoutData(file)
#MolSpec.MULT=4
Gwrite = writeGinput(file, Ginput, MolSpec)
for file in infiles:
Ginput = getGinput(file, job)
MolSpec = getinData(file)
MolSpec.MULT=1
MolSpec.CHARGE=0
Gwrite = writeGinput(file, Ginput, MolSpec)