-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindeptool_abstractInfo.py
129 lines (107 loc) · 3.28 KB
/
indeptool_abstractInfo.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
import copy
import sys
filename = sys.argv[1]
spctag = "[species]"
spcRevtag = "[speciesrev]"
fmlRevtag = "[formularev]"
TrajLen = 0
N_smiles = 0
R_Flag =""
spcDic = {}
fmlDic = {}
def prtspcDicOrigin():
time = [ i*0.2 for i in range(TrajLen)]
# print species record:
for rec in spcDic:
fileName = "S_"+rec+"_spec.data"
fileData = open(fileName,"w")
for i in range(TrajLen):
pass
fileData.write(f' {time[i]:.3f}{spcDic[rec][2][i]:10d}\n')
fileData.close()
# print formula record:
for rec in fmlDic:
fileName = "F_"+rec+"_formula.data"
fileData = open(fileName,"w")
for i in range(TrajLen):
fileData.write(f' {time[i]:.3f}{fmlDic[rec][i]:10d}\n' )
fileData.close()
# Read result file
with open(filename, "r") as f:
while True:
line = f.readline()
if not line:
break
line = line.strip()
if(len(line) == 0 ): continue
if(line[0] =="#"): continue
if("[species]" in line):
R_Flag = "SPCINFO"
continue
if("[speciesrev]" in line):
R_Flag = "SPCREV"
continue
if("[formularev]" in line):
R_Flag = "FMLREV"
continue
if("_end]" in line):
R_Flag = ""
continue
# Read species information in
# SMILES:[Formula,abd,[rev]]
if(R_Flag == "SPCINFO"):
Sline = line.split()
smiles = Sline[0].strip()
formula = Sline[2]
Abundance = Sline[3]
spcDic[smiles] = [formula,Abundance]
# Read species revolution information in
if(R_Flag == "SPCREV"):
Sline = line.split()
N_smiles = int(Sline[0])
TrajLen = int(Sline[1])
R_Flag = "SMILEreading_SPCREV"
continue
if(R_Flag == "SMILEreading_SPCREV"):
SMILES = line
R_Flag = "Valuereading_SPCREV"
icount = 0
value = []
continue
# Read value
if(R_Flag == "Valuereading_SPCREV"):
Sline = line.split()
for num in (Sline):
icount += 1
value.append(int(num))
if(icount == TrajLen ):
icount = 0
R_Flag = "SMILEreading_SPCREV"
spcDic[SMILES].append(value)
continue
# Read formula revolution information in
if(R_Flag == "FMLREV"):
Sline = line.split()
N_formula = int(Sline[0])
TrajLen = int(Sline[1])
R_Flag = "FORMULAreading_FMLREV"
continue
if(R_Flag == "FORMULAreading_FMLREV"):
formula = line
R_Flag = "Valuereading_FMLREV"
icount = 0
value = []
continue
# Read value
if(R_Flag == "Valuereading_FMLREV"):
Sline = line.split()
for num in (Sline):
icount += 1
value.append(int(num))
if(icount == TrajLen ):
icount = 0
R_Flag = "FORMULAreading_FMLREV"
fmlDic[formula] = value
continue
# print for origin.
prtspcDicOrigin()