forked from Ianiusha/Uselfuls_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_hess.py
59 lines (42 loc) · 1.05 KB
/
add_hess.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
#!/usr/bin/python
# Anna Tomberg
# 06/08/2014
# To add hess section to end of GAMEES-US input file
# importing modules
import sys
import os
import re
# display greating
print ("\n ~~~~ ADD HESSIAN ~~~~\n")
print ("\n >>> Enter INP file then DAT file\n")
# Verify input
if len(sys.argv) <= 2:
path = raw_input(">>> Enter path to inp file: ")
else:
path = sys.argv[1]
dat_name = sys.argv[2]
if not os.path.isfile(path):
sys.exit(">>> This file does not exist.Bye!")
# Open corresponding dat file
if not os.path.isfile(dat_name):
sys.exit(">>> Can't find .dat file. Bye!")
else:
print (">>> Found .dat file.\n")
fo = open("hess_temp.txt", "w")
for line in reversed(open(dat_name).readlines()):
if line.startswith(" $HESS"):
fo.write(line)
break
else:
fo.write(line)
fo.close()
print ">>> Got the $HESS group from the .dat file.\n"
fo = open("hess.txt", "w")
for line in reversed(open("hess_temp.txt").readlines()):
print line
fo.write(line)
fo.close()
#fo = open(path, "a")
#fo.write(HESS_group)
#fo.close()
os.remove("hess_temp.txt")