-
Notifications
You must be signed in to change notification settings - Fork 0
/
gt-xyz2com.py
43 lines (33 loc) · 1021 Bytes
/
gt-xyz2com.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
#!/usr/bin/env python
# Usage: gt-xyz2com.py file1.xyz file2.xyz ...
import sys, os
nprocs = "32" # number of processors
mem = "48GB" # memory threshold
method = "#B97D3/6-311++G(d,p) opt " # method
chargemult = "0 1" # charge and multiplicity
#==============
def fn ( inp, filename ):
fd = open ( "%s.com"%filename, 'w' )
print("%%NProcShared=%s"%nprocs, file=fd)
print("%%Mem=%s"%mem, file=fd)
print("%%chk=%s"%filename, file=fd)
print("%s \n"%method, file=fd)
print("Generated by gt-xyz2com.py \n", file=fd)
print("%s "%chargemult, file=fd)
for line in inp[2:]:
cline = line.strip()
print (cline, file=fd)
print ("\n\n", file=fd)
#=============
files = sys.argv[1:]
argc = len(sys.argv)
if not files:
string = sys.stdin
fn ( string )
elif argc >= 2:
for file in files:
filename = str(os.path.splitext(file)[0])
string = open ( file, 'r' ).readlines()
fn ( string, filename )
else:
print("Usage: %s [file]" % command )