-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInputParser.py
523 lines (493 loc) · 29 KB
/
InputParser.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
import pyBrellaSampling.utils as utils
import argparse as ap
### Aim to use case insensitive variables for the end user, especially in the input files.
### Use ".casefold()" when comparing strings and ensure new variables are not differing by case...
### To add a new variable, add the variable name and default value to the relevant array first,
### Then add the variable to the arg_parse function, specifying the default to the dictionary.
### Argument priority: Commandline > Input file > default
### Final inputs are all combined into the "args" variable which is a argparse namespace.
def VariableParser(sysargs, JT="Umbrella"):
if JT == "Umbrella":
JobDict = JobInput("./Job.conf")
WorkDir = JobDict["WorkDir"]
ComputeDict = ComputeInput(f"{WorkDir}Compute.conf")
MMDict = MMInput(f"{WorkDir}MM.conf")
QMDict = QMInput(f"{WorkDir}QM.conf")
UmbrellaDict = UmbrellaInput(f"{WorkDir}Umbrella.conf")
HPCDict = HPCInput(f"{WorkDir}HPC.conf")
StandaloneDict = StandaloneJobInput(f"{WorkDir}Standalone.conf")
if JobDict["JobType"].casefold() == "umbrella":
FileDict = {**JobDict, **ComputeDict, **MMDict, **QMDict,
**HPCDict, **StandaloneDict,**UmbrellaDict}
elif JobDict["JobType"].casefold() == "Inpfile":
FileDict = {**JobDict, **ComputeDict, **MMDict, **QMDict, **UmbrellaDict, **HPCDict, **StandaloneDict}
elif JobDict["JobType"].casefold() == "mm" or JobDict["JobType"].casefold() == "qmmm":
FileDict = {**JobDict, **ComputeDict, **MMDict, **QMDict, **UmbrellaDict, **HPCDict,**StandaloneDict}
else:
FileDict = {**JobDict, **ComputeDict, **MMDict, **QMDict, **UmbrellaDict, **HPCDict,**StandaloneDict}
args = arg_parse_Umbrella(FileDict,sysargs)
if args.JobType.casefold() == "inpfile":
InputFileGen(args, JobType="Umbrella")
if args.Verbosity >= 2:
print(vars(args))
return args
elif JT == "Standalone":
JobDict = JobInput("./Job.conf")
WorkDir = JobDict["WorkDir"]
ComputeDict = ComputeInput(f"{WorkDir}Compute.conf")
MMDict = MMInput(f"{WorkDir}MM.conf")
QMDict = QMInput(f"{WorkDir}QM.conf")
HPCDict = HPCInput(f"{WorkDir}HPC.conf")
StandaloneDict = StandaloneJobInput(f"{WorkDir}Standalone.conf")
FileDict = {**JobDict, **ComputeDict, **MMDict, **QMDict, **HPCDict, **StandaloneDict}
args = arg_parse_Standalone(FileDict,sysargs)
if args.JobType.casefold() == "inpfile":
InputFileGen(args, JobType="Standalone")
if args.Verbosity >= 2:
print(vars(args))
return args
def InputFileGen(args, JobType="Umbrella"):
argsDict = vars(args)
JobDict = JobInput(f"{args.WorkDir}Job.conf")
with open(f"{args.WorkDir}Job.conf", "w") as f:
for i in JobDict.keys():
print(f"{i}={argsDict[i]}", file=f)
ComputeDict = ComputeInput(f"{args.WorkDir}Compute.conf")
with open(f"{args.WorkDir}Compute.conf", "w") as f:
for i in ComputeDict.keys():
print(f"{i}={argsDict[i]}", file=f)
MMDict = MMInput(f"{args.WorkDir}MM.conf")
with open(f"{args.WorkDir}MM.conf", "w") as f:
for i in MMDict.keys():
print(f"{i}={argsDict[i]}", file=f)
QMDict = QMInput(f"{args.WorkDir}QM.conf")
with open(f"{args.WorkDir}QM.conf", "w") as f:
for i in QMDict.keys():
print(f"{i}={argsDict[i]}", file=f)
if JobType == "Umbrella":
UmbrellaDict = UmbrellaInput(f"{args.WorkDir}Umbrella.conf")
with open(f"{args.WorkDir}Umbrella.conf", "w") as f:
for i in UmbrellaDict.keys():
print(f"{i}={argsDict[i]}", file=f)
HPCDict = HPCInput(f"{args.WorkDir}HPC.conf")
with open(f"{args.WorkDir}HPC.conf", "w") as f:
for i in HPCDict.keys():
print(f"{i}={argsDict[i]}", file=f)
if JobType == "Standalone":
StandaloneDict = StandaloneJobInput(f"{args.WorkDir}Standalone.conf")
with open(f"{args.WorkDir}Standalone.conf", "w") as f:
for i in StandaloneDict.keys():
print(f"{i}={argsDict[i]}", file=f)
def arg_parse_Umbrella(dict, sysargs):
parser = ap.ArgumentParser(description=f"""Commandline arguments. This method of calculation input is being deprecated. Please do not use.
It is recommended to use -jt inpfile to generate input file templates with default values that you can then edit.""")
### Core Job arguments
Core = parser.add_argument_group("Core Job Arguments")
Core.add_argument('-wd', '--WorkDir', type=str,
help="Home location for the calculations", default=dict["WorkDir"])
Core.add_argument('-jt', '--JobType', type=str,
help="Type of calculation to run", default=dict["JobType"])
Core.add_argument('-v', '--Verbosity', type=int,
help="Verbosity: 0 = none, 1 = info", default=dict["Verbosity"])
Core.add_argument('-dr', '--DryRun', type=str,
help="Indicates whether programs are executed or not", default=dict["DryRun"])
Compute = parser.add_argument_group("Compute Arguments")
### Compute Arguments
Compute.add_argument('-cores', '--CoresPerJob', type=int,
help="Number of cores per individual calculation", default=dict["CoresPerJob"])
Compute.add_argument('-mem','--MemoryPerJob', type=int,
help="Gb of memory per individual calculation", default=dict["MemoryPerJob"])
Compute.add_argument('-MaxCalc', '--MaxStepsPerCalc', type=int,
help="The maximum number of steps per calculation. splits jobs into sub-steps. useful for short wall times. 0 == No cap.",
default=dict["MaxStepsPerCalc"])
### MM Arguments
MM = parser.add_argument_group("Molecular Dynamics Arguments")
MM.add_argument('-MDcpu', '--MDCPUPath', type=str,
help="Path to NAMD CPU executable", default=dict["MDCPUPath"])
MM.add_argument('-MDgpu', '--MDGPUPath', type=str,
help="Path to NAMD GPU executable", default=dict["MDGPUPath"])
### QM Arguments
QM = parser.add_argument_group("QM Arguments")
QM.add_argument('-qp', '--QmPath', type=str,
help="Path to QM software", default=dict["QmPath"])
QM.add_argument('-qsel', '--QmSelection', type=str,
help="Selection algebra for QM atoms", default=dict["QmSelection"])
QM.add_argument('-qc', '--QmCharge', type=int,
help="Charge of QM region", default=dict["QmCharge"])
QM.add_argument('-qspin', '--QmSpin', type=int,
help="Spin of QM region", default=dict["QmSpin"])
QM.add_argument('-qm', '--QmMethod', type=str,
help="Qm method", default=dict["QmMethod"])
QM.add_argument('-qb', '--QmBasis', type=str,
help="QM basis set", default=dict["QmBasis"])
QM.add_argument('-qargs', '--QmArgs', type=str, help="Extra arguments for ORCA calculation", default=dict["QmArgs"])
### Umbrella Arguments
Umbrella = parser.add_argument_group("Umbrella Sampling arguments")
Umbrella.add_argument('-min', '--UmbrellaMin', type=float,
help="Minimum Umbrella distance", default=dict["UmbrellaMin"])
Umbrella.add_argument('-width', '--UmbrellaWidth', type=float,
help="Umbrella bin width in Angstroms or degrees", default=dict["UmbrellaWidth"])
Umbrella.add_argument('-bins', '--UmbrellaBins', type=int,
help="Number of umbrella bins", default=dict["UmbrellaBins"])
Umbrella.add_argument('-pf', '--PullForce', type=float,
help="Force for pulls in KCal A-2", default=dict["PullForce"])
Umbrella.add_argument('-f', '--ConstForce', type=float,
help="Force for standard Umbrella runs", default=dict["ConstForce"]) ### NAMD uses 1/2 k rather than just k
Umbrella.add_argument('-sd', '--StartDistance', type=float,
help="Distance of initial simulation", default=dict["StartDistance"])
Umbrella.add_argument('-mask', '--AtomMask', type=str,
help="Mask for the restrained atoms.", default=dict["AtomMask"])
Umbrella.add_argument('-stg', '--Stage', type=str,
help="Stage of ummbrella simulation", default=dict["Stage"])
Umbrella.add_argument('-wf', '--WhamFile', type=str,
help="Name prefix of wham data.(XXX.i.colvars.traj", default=dict["WhamFile"])
Umbrella.add_argument("--StartFile", default=dict["StartFile"], type=str, help="Initial coordinate file if not starting from \"start.rst7\"")
Umbrella.add_argument("-exclude", "--WhamExclude", type=str, help="Comma delimited list of umbrella windows to exclude from Wham calculations",
default=dict["WhamExclude"])
### HPC Arguments
HPC = parser.add_argument_group("HPC/SLURM arguments")
HPC.add_argument("-MaxTime", "--MaxWallTime", type=int,
help="Maximum wall time (Hours) for your jobs (either leave as node max, or set as job length)",
default=dict["MaxWallTime"])
HPC.add_argument("-Host", "--HostName", type=str,
help="HostName of the HPC", default=dict["HostName"])
HPC.add_argument("--Partition", type=str, help="Calculation partition name",
default=dict["Partition"])
HPC.add_argument("--MaxCores", type=int,
help="Maximum number of cores available to a node (For array splitting)", default=dict["MaxCores"])
HPC.add_argument("-QoS", "--QualityofService", type=str,
help="Slurm QoS, set to None if not relevant.", default=dict["QualityofService"])
HPC.add_argument("--Account", type=str,
help="Slurm account, (Not username), Set to None if not relevant", default=dict["Account"])
HPC.add_argument("-Software", "--SoftwareLines", type=str,
help="List of commands like \"module load XXX\" to load software. Keep each line surrounded by quotes.",
default=dict["SoftwareLines"], nargs="*")
# Standalone = parser.add_argument_group("Standalone Job arguments")
# Standalone.add_argument("--Name", type=str,
# default=dict["Name"], help="Name for the calculation")
# Standalone.add_argument("--Ensemble", type=str,
# choices=["min", "heat", "NVT", "NPT"],
# help="Ensemble for Calculation", default=dict["Ensemble"])
# Standalone.add_argument("--QM", type=str, choices=["True", "False"],
# default=dict["QM"], help="Whether this is a QMMM calculation or not.")
# Standalone.add_argument("-st", "--Steps", type=int,
# default=dict["Steps"], help="Number of simulation steps.")
# Standalone.add_argument("-dt", "--TimeStep", type=float,
# default=dict["TimeStep"], help="Time step for the simulation. We recommend 2 for MM, 0.5 for QMMM")
# Standalone.add_argument("--ParmFile", type=str,
# default=dict["ParmFile"], help="Parameter file name")
# Standalone.add_argument("--AmberCoordinates", type=str,
# default=dict["AmberCoordinates"], help="Amber coordinate file name that relates to the parameter file")
# # Standalone.add_argument("--StartFile", type=str, default=dict["StartFile"], help="Either Amber coordinates or NAMD coordinates. These are the coordinates that it starts from.")
# Standalone.add_argument("--RestartOut", type=int, default=dict["RestartOut"], help="Frequency to generate a restart file")
# Standalone.add_argument("--TrajOut", type=int, default=dict["TrajOut"], help="Frequency to add to the trajectory file")
# Standalone.add_argument("--SMD", type=str, choices=["off", "on"], default=dict["SMD"], help="Wheter to use steered molecular dynamics")
# Standalone.add_argument("--Force", type=float, default=dict["Force"], help="Force for Steered MD")
# Standalone.add_argument("--StartValue", type=float, default=dict["StartValue"], help="Start value for SMD")
# Standalone.add_argument("--EndValue", type=float, default=dict["EndValue"], help="End value for SMD. MAKE == Start if wanting constant.")
# Standalone.add_argument("", type=, default=dict[""], help="")
### Parse commandline arguments
args = parser.parse_args(sysargs)
# print(vars(args))
return args
def arg_parse_Standalone(dict, sysargs):
parser = ap.ArgumentParser(description=f"""Commandline arguments. This method of calculation input is being deprecated. Please do not use.
It is recommended to use -jt inpfile to generate input file templates with default values that you can then edit.""")
### Core Job arguments
Core = parser.add_argument_group("Core Job Arguments")
Core.add_argument('-wd', '--WorkDir', type=str,
help="Home location for the calculations", default=dict["WorkDir"])
Core.add_argument('-jt', '--JobType', type=str,
help="Type of calculation to run", default=dict["JobType"])
Core.add_argument('-v', '--Verbosity', type=int,
help="Verbosity: 0 = none, 1 = info", default=dict["Verbosity"])
Core.add_argument('-dr', '--DryRun', type=str,
help="Indicates whether programs are executed or not", default=dict["DryRun"])
Compute = parser.add_argument_group("Compute Arguments")
### Compute Arguments
Compute.add_argument('-cores', '--CoresPerJob', type=int,
help="Number of cores per individual calculation", default=dict["CoresPerJob"])
Compute.add_argument('-mem','--MemoryPerJob', type=int,
help="Gb of memory per individual calculation", default=dict["MemoryPerJob"])
Compute.add_argument('-MaxCalc', '--MaxStepsPerCalc', type=int,
help="The maximum number of steps per calculation. splits jobs into sub-steps. useful for short wall times. 0 == No cap.",
default=dict["MaxStepsPerCalc"])
### MM Arguments
MM = parser.add_argument_group("Molecular Dynamics Arguments")
MM.add_argument('-MDcpu', '--MDCPUPath', type=str,
help="Path to NAMD CPU executable", default=dict["MDCPUPath"])
MM.add_argument('-MDgpu', '--MDGPUPath', type=str,
help="Path to NAMD GPU executable", default=dict["MDGPUPath"])
### QM Arguments
QM = parser.add_argument_group("QM Arguments")
QM.add_argument('-qp', '--QmPath', type=str,
help="Path to QM software", default=dict["QmPath"])
QM.add_argument('-qsel', '--QmSelection', type=str,
help="Selection algebra for QM atoms", default=dict["QmSelection"])
QM.add_argument('-qc', '--QmCharge', type=int,
help="Charge of QM region", default=dict["QmCharge"])
QM.add_argument('-qspin', '--QmSpin', type=int,
help="Spin of QM region", default=dict["QmSpin"])
QM.add_argument('-qm', '--QmMethod', type=str,
help="Qm method", default=dict["QmMethod"])
QM.add_argument('-qb', '--QmBasis', type=str,
help="QM basis set", default=dict["QmBasis"])
QM.add_argument('-qargs', '--QmArgs', type=str, help="Extra arguments for ORCA calculation", default=dict["QmArgs"])
### HPC Arguments
HPC = parser.add_argument_group("HPC/SLURM arguments")
HPC.add_argument("-MaxTime", "--MaxWallTime", type=int,
help="Maximum wall time (Hours) for your jobs (either leave as node max, or set as job length)",
default=dict["MaxWallTime"])
HPC.add_argument("-Host", "--HostName", type=str,
help="HostName of the HPC", default=dict["HostName"])
HPC.add_argument("--Partition", type=str, help="Calculation partition name",
default=dict["Partition"])
HPC.add_argument("--MaxCores", type=int,
help="Maximum number of cores available to a node (For array splitting)", default=dict["MaxCores"])
HPC.add_argument("-QoS", "--QualityofService", type=str,
help="Slurm QoS, set to None if not relevant.", default=dict["QualityofService"])
HPC.add_argument("--Account", type=str,
help="Slurm account, (Not username), Set to None if not relevant", default=dict["Account"])
HPC.add_argument("-Software", "--SoftwareLines", type=str,
help="List of commands like \"module load XXX\" to load software. Keep each line surrounded by quotes.",
default=dict["SoftwareLines"], nargs="*")
Standalone = parser.add_argument_group("Standalone Job arguments")
Standalone.add_argument("--Name", type=str,
default=dict["Name"], help="Name for the calculation")
Standalone.add_argument("--Ensemble", type=str,
choices=["min", "heat", "NVT", "NPT"],
help="Ensemble for Calculation", default=dict["Ensemble"])
Standalone.add_argument("--QM", type=str, choices=["True", "False"],
default=dict["QM"], help="Whether this is a QMMM calculation or not.")
Standalone.add_argument("-st", "--Steps", type=int,
default=dict["Steps"], help="Number of simulation steps.")
Standalone.add_argument("-dt", "--TimeStep", type=float,
default=dict["TimeStep"], help="Time step for the simulation. We recommend 2 for MM, 0.5 for QMMM")
Standalone.add_argument("--ParmFile", type=str,
default=dict["ParmFile"], help="Parameter file name")
Standalone.add_argument("--AmberCoordinates", type=str,
default=dict["AmberCoordinates"], help="Amber coordinate file name that relates to the parameter file")
Standalone.add_argument("--StartFile", type=str, default=dict["StartFile"], help="Either Amber coordinates or NAMD coordinates. These are the coordinates that it starts from.")
Standalone.add_argument("--RestartOut", type=int, default=dict["RestartOut"], help="Frequency to generate a restart file")
Standalone.add_argument("--TrajOut", type=int, default=dict["TrajOut"], help="Frequency to add to the trajectory file")
Standalone.add_argument("--SMD", type=str, choices=["off", "on"], default=dict["SMD"], help="Wheter to use steered molecular dynamics")
Standalone.add_argument("--Force", type=float, default=dict["Force"], help="Force for Steered MD")
Standalone.add_argument("--StartValue", type=float, default=dict["StartValue"], help="Start value for SMD")
Standalone.add_argument("--EndValue", type=float, default=dict["EndValue"], help="End value for SMD. MAKE == Start if wanting constant.")
Standalone.add_argument('-mask', '--AtomMask', type=str,
help="Mask for the restrained atoms.", default=dict["AtomMask"])
### Parse commandline arguments
args = parser.parse_args(sysargs)
# print(vars(args))
return args
def JobInput(path):
InpVars = ["WorkDir", "JobType", "Verbosity", "DryRun"]
InpValues = ["./", "inpfile", 0, "True"]
assert len(InpVars) == len(InpValues)
try:
lines = utils.file_read(path)
except FileNotFoundError:
print("WARNING, No config found for Job input, This is a bad idea... Using defaults.")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = str(InpValues[i])
return Dict
for line in lines:
words = line.split("=")
for i in range(len(InpVars)):
if words[0].casefold() == InpVars[i].casefold():
InpValues[i] = words[1].replace("\n","")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = InpValues[i]
return Dict
def ComputeInput(path):
InpVars = ["CoresPerJob", "MemoryPerJob", "MaxStepsPerCalc"]
InpValues = [10, 10, 1000]
assert len(InpVars) == len(InpValues)
try:
lines = utils.file_read(path)
except FileNotFoundError:
print("WARNING, No config found for Compute input, Using defaults.")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = str(InpValues[i])
return Dict
for line in lines:
words = line.split("=")
for i in range(len(InpVars)):
if words[0].casefold() == InpVars[i].casefold():
InpValues[i] = words[1].replace("\n","")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = InpValues[i]
return Dict
def MMInput(path):
InpVars = ["MDCPUPath", "MDGPUPath"]
InpValues = ["/work/e280/e280-Hirst/pcyra2/Software/NAMD_3.0b3_Linux-x86_64-multicore/namd3", "/home/pcyra2/Software/NAMD/NAMD_3.0b4_Linux-x86_64-multicore-CUDA/namd3"]
assert len(InpVars) == len(InpValues)
try:
lines = utils.file_read(path)
except FileNotFoundError:
print("WARNING, No config found for MM input, Using defaults.")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = str(InpValues[i])
return Dict
for line in lines:
words = line.split("=")
for i in range(len(InpVars)):
if words[0].casefold() == InpVars[i].casefold():
InpValues[i] = words[1].replace("\n","")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = InpValues[i]
return Dict
def QMInput(path):
InpVars = ["QmPath", "QmSelection", "QmCharge", "QmSpin", "QmMethod", "QmBasis", "QmArgs"]
InpValues = ["/work/y07/shared/apps/core/orca/5.0.3/orca", "resname CTN POP MG", 3, 1, "PBE", "6-31G*", "D3BJ TightSCF CFLOAT "]
assert len(InpVars) == len(InpValues)
try:
lines = utils.file_read(path)
except FileNotFoundError:
print("WARNING, No config found for QM input, Using defaults.")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = str(InpValues[i])
return Dict
for line in lines:
words = line.split("=")
for i in range(len(InpVars)):
if words[0].casefold() == InpVars[i].casefold():
InpValues[i] = words[1].replace("\n","")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = InpValues[i]
return Dict
def UmbrellaInput(path):
InpVars = ["UmbrellaMin", "UmbrellaWidth", "UmbrellaBins", "PullForce", "ConstForce", "StartDistance", "AtomMask", "Stage", "WhamFile", "StartFile", "WhamExclude"]
InpValues = [1.3, 0.05, 54, 5000, 300, 1.4, "0,0,0,0", "Setup", "prod", "start.rst7",""]
assert len(InpVars) == len(InpValues)
try:
lines = utils.file_read(path)
except FileNotFoundError:
print("WARNING, No config found for Umbrella input, Using defaults.")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = str(InpValues[i])
return Dict
for line in lines:
words = line.split("=")
for i in range(len(InpVars)):
if words[0].casefold() == InpVars[i].casefold():
InpValues[i] = words[1].replace("\n","")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = InpValues[i]
return Dict
def HPCInput(path):
InpVars = ["MaxWallTime", "HostName","Partition", "MaxCores", "QualityofService", "Account", "SoftwareLines"]
InpValues = [24, "login.archer2.ac.uk", "standard", 128, None, None, "module load ORCA", ]
InpVars2 = []
InpValues2 = []
assert len(InpVars) == len(InpValues)
try:
lines = utils.file_read(path)
except FileNotFoundError:
print("WARNING, No config found for HPC input, Using defaults.")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = str(InpValues[i])
return Dict
for i in range(len(lines)):
words = lines[i].split("=",1)
for j in range(len(InpVars)):
if words[0].casefold() == InpVars[j].casefold():
InpValues2.append(words[1].replace("\n",""))
InpVars2.append(words[0])
Dict = {}
for i in range(len(InpVars2)):
if Dict.get(InpVars2[i]) == None:
Dict[InpVars2[i]] = InpValues2[i]
# print(Dict.get(InpVars2[i]))
else: ### This allows for multiple iof the same word keyword (i.e. Multiple software lines)
Vals = Dict.get(InpVars2[i])
if type(Vals) == str:
Dict[InpVars2[i]] = [Vals, InpValues2[i]]
else:
Vals.append(InpValues2[i])
Dict[InpVars2[i]] = Vals
# print(Vals)
return Dict
def StandaloneJobInput(path):
InpVars = ["Name", "ParmFile", "AmberCoordinates", "StartFile", "Ensemble",
"QM", "Steps", "TimeStep", "RestartOut", "TrajOut", "SMD", "Force", "StartValue", "EndValue", "AtomMask"]
InpValues = ["QMMM_Job","complex.parm7", "start.rst7", "Start.rst7" ,"min",
"true", 1000, 0.05, 10, 50, "off", 1, 1, 2, "0,0,0,0"]
assert len(InpVars) == len(InpValues)
try:
lines = utils.file_read(path)
except FileNotFoundError:
print("WARNING, No config found for Standalone Job input, Using defaults.")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = str(InpValues[i])
return Dict
for line in lines:
words = line.split("=")
for i in range(len(InpVars)):
if words[0].casefold() == InpVars[i].casefold():
InpValues[i] = words[1].replace("\n","")
Dict = {}
for i in range(len(InpVars)):
Dict[InpVars[i]] = InpValues[i]
return Dict
def BondsInput(path, Labels):
try:
data = utils.file_read(path)
except FileNotFoundError:
print("No bond information file found...")
return Labels
for lines in data:
variables = lines.split()
if "name" in variables[0].casefold():
pass
else:
Labels.add_bond(selection=f"{variables[1]},{variables[2]}", name=variables[0], thresh=float(variables[3]))
return Labels
def DihedralInput(path, Labels):
try:
data = utils.file_read(path)
except FileNotFoundError:
print("No dihedral information file found...")
return Labels
for lines in data:
variables = lines.split()
if "name" in variables[0].casefold():
pass
else:
Labels.add_dihedral(selection=f"{variables[1]},{variables[2]},{variables[3]},{variables[4]}",
name=variables[0], target1=float(variables[6]), t1name=variables[5],
target2=float(variables[8]), t2name=variables[7])
return Labels
def Benchmark_input(sysargs):
parser = ap.ArgumentParser(description=f"""CLI interface for running a QM benchmark in ORCA""")
gen = parser.add_argument_group("Generic Inputs")
gen.add_argument("-v", "--verbosity", type=int, help="Control the verbosity of the job", choices=[0,1,2], default=1)
gen.add_argument("-wd","--WorkDir", type=str, help="Working directory path", default="./")
gen.add_argument("-c", "--Cores", type=int, help="The number of CPU cores to give each ORCA Job.", default=10)
gen.add_argument("-dr", "--DryRun", type=str, help="Should the calculation be performed?", default="False")
gen.add_argument("-stg", "--Stage", type=str, help="The stage of the calculation",choices=["init", "calc", "analysis",], default="analysis")
bench = parser.add_argument_group("Benchmark Inputs")
bench.add_argument("-type", "--BenchmarkType", type=str, help="Define the type of benchmark to perform", choices=["Energy", "Gradient", "Structure"], default="Energy")
bench.add_argument("-cd", "--CoordinateLoc", type=str, help="Location for the structures to perform the benchmark on", default="./Coordinates")
bench.add_argument("-reactions", "--ReactionList", type=str, help="Name of the file containing the list of reaction steps. This must be line delimited single step reactions with the name of the structure being identical of that to the file in the coordinates folder.", default="reactions.dat")
qm = parser.add_argument_group("ORCA specific inputs")
qm.add_argument("--Path", type=str, help="Path to ORCA executable", default="/home/pcyra2/Software/ORCA/5.0.4/orca")
qm.add_argument("--SCF",type=str, help="The orca scf convergence setting", choices=["NORMALSCF", "TIGHTSCF", "VERYTIGHTSCF", "EXTREMESCF"], default="TIGHTSCF")
qm.add_argument("--Grid", type=str, help="Specify the orca integration grid", choices=["DEFGRID1", "DEFGRID2", "DEFGRID3"], default="DEFGRID3")
qm.add_argument("--Restart", type=str, help="Togle whether to use a restart file or not", choices=["AUTOSTART", "NOAUTOSTART"], default="NOAUTOSTART")
qm.add_argument("--Convergence", type=str, help="Chose th orca convergence stratergy", choices=["EasyConv", "NormalConv", "SlowConv", "VerySlowConv", "ForceConv"], default="EasyConv")
qm.add_argument("--Extras", type=str, help="Extra ORCA commands to use for all calculations (default is \"MINIPRINT\")", default="MINIPRINT")
args = parser.parse_args(sysargs)
return args