-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
282 lines (256 loc) · 9.81 KB
/
main.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
"""Menu Interface"""
import sys, os
import utils, trj_int, trj_ana, trj_pru, trj_qst, pro_pru, con_gen
import neb_vis, nei_fin, out_sum
import molecule as mol
__VERSION__ = '1.0'
def main():
utils.header(__VERSION__)
print("""
1) Trajectory Manipulation
2) PDB Tools
3) Others
4) Molecular properties and vibrations
q) Exit
""")
choice = input("\nSelection:\t")
if choice == "1":
data_manipulation()
elif choice == "2":
analysis()
elif choice == "3":
input_generation()
elif choice == "4":
molecule_interface()
elif choice == "q":
sys.exit()
def data_manipulation():
"""Trajectory Manipulation"""
utils.header(__VERSION__)
print("""
1) Resizer (TRJ/GENERAL/ORCA)
2) Analyzer/Freezer (TRJ/GENERAL)
3) Slicer (TRJ/GENERAL)
4) TRJ 2 Synchronous Transit-Guided Quasi-Newton (TRJ/Gaussian)
b) Back to Main Menu
q) Exit
""")
choice = input("\nSelection:\t")
if choice == "1":
trj_int.main()
elif choice == "2":
trj_ana.main()
elif choice == "3":
trj_pru.main()
elif choice == "4":
trj_qst.main()
elif choice == "b":
main()
elif choice == "q":
sys.exit()
def analysis():
"""PDB Tools menu"""
utils.header(__VERSION__)
print("""
1) Proximity Analysis (PDB)
2) Catalytic Pocket Selector (PDB)
b) Back to Main Menu
q) Exit
""")
choice = input("\nSelection:\t")
if choice == "1":
nei_fin.main()
elif choice == "2":
pro_pru.main()
elif choice == "b":
main()
elif choice == "q":
sys.exit()
def input_generation():
"""Others menu"""
utils.header(__VERSION__)
print("""
1) Constraints Generator (XYZ/GENERAL)
b) Back to Main Menu
q) Exit
""")
choice = input("\nSelection:\t")
if choice == "1":
con_gen.main()
elif choice == "b":
main()
elif choice == "q":
sys.exit()
def molecule_interface():
"""Molecule class menu"""
def ask_ID():
ID = int(input("Select the molecule ID (from 1 to " + str(len(MOL_LIST)) + "):\t"))
if ID < 1 and ID > len(MOL_LIST):
print("ERROR: The selected ID does not exist")
molecule_interface()
print("Selected ID: " + str(ID) + "\tMolecule name: " + str(MOL_LIST[ID-1].name) + "\n")
return ID
def list_molecules():
print("\n LIST OF LOADED MOLECULES")
print("------------------------------------------------\n")
print("ID\tNAME\n")
for i, myclass in enumerate(MOL_LIST):
print(str(i+1) + "\t" + myclass.name)
utils.header(__VERSION__)
print("""
1) Load molecule from .xyz file
2) Load vibrational data from .hess file (ORCA)
3) Plot IR spectra
4) Compute properties
5) Linear transit
l) List loaded molecules
b) Back to Main Menu
q) Exit
""")
choice = input("\nSelection:\t")
if choice == "1":
utils.header(__VERSION__)
path = input("\nSelect the path of the .xyz file:\t")
MOL_LIST.append(mol.MOL(path))
print("\nMolecule saved with the ID:\t" + str(len(MOL_LIST)))
input("\nPress enter to return to the menu ... ")
molecule_interface()
elif choice == "2":
utils.header(__VERSION__)
path = input("\nSelect the path of the .hess file:\t")
ID = ask_ID()
MOL_LIST[ID-1].load_hess_file(path, verbose=True)
input("\nPress enter to return to the menu ... ")
molecule_interface()
elif choice == "3":
utils.clear()
print("================================================")
print(" VIBRATIONAL SPECTRUM")
print("================================================\n")
ID = ask_ID()
type_of_plot = input("Select the type of plot (gaussian, lorentzian, bar):\t")
if type_of_plot == "gaussian" or type_of_plot == "lorentzian":
width = input("Select the amplitude parameter (in cm^-1): ")
mol.plot_ir_spectrum(MOL_LIST[ID-1], width, style=type_of_plot)
save_state = input("\nDo you want to save the plot (y/n):\t")
if save_state == "y":
path = input("Select the path to the destination folder:\t")
mol.plot_ir_spectrum(MOL_LIST[ID-1], width, style=type_of_plot, path=path, show=False)
else:
mol.plot_ir_spectrum(MOL_LIST[ID-1], style=type_of_plot)
save_state = input("\nDo you want to save the plot (y/n):\t")
if save_state == "y":
path = input("Select the path to the destination folder:\t")
mol.plot_ir_spectrum(MOL_LIST[ID-1], style=type_of_plot, path=path, show=False)
molecule_interface()
elif choice == "4":
utils.clear()
print("================================================")
print(" MOLECULAR PROPERTIES COMPUTATION")
print("================================================\n")
print("""
1) General informations
b) Back
q) Exit
""")
calculation_choice = input("\nSelection:\t")
if calculation_choice == "1":
utils.clear()
print("================================================")
print(" GENERAL PROPERTIES")
print("================================================")
list_molecules()
print("\n================================================")
molecule_selection = input("""
Select the ID of the molecules divided by comma
(type "all" if you want all the entries):\t""")
if molecule_selection == "all":
molecule_selection = list(range(0, len(MOL_LIST)))
else:
molecule_selection = [int(i) for i in molecule_selection.split(",")]
utils.clear()
print("================================================")
print(" GENERAL PROPERTIES")
print("================================================")
print("\nSelected molecules: ", molecule_selection)
for myID in molecule_selection:
myMol = MOL_LIST[myID-1]
print("\n Molecule: " + myMol.name + "\t(ID: " + str(myID) + ")" )
print("------------------------------------------------\n")
print("Composition:")
comp_list = myMol.composition()
print("ATOM\tN\t%MASS")
for line in comp_list:
print(str(line[0]) + "\t" + str(line[1]) + "\t" + str(line[2]))
print("\n")
print("Center of mass (Angstrom):")
print("\tx:\t" + str(myMol.rcm()[0]))
print("\ty:\t" + str(myMol.rcm()[1]))
print("\tz:\t" + str(myMol.rcm()[2]))
print("\nMoment of Inertia (amu*Angstrom**2):")
inert = myMol.inertia_tensor()
print("\t{:.3e}\t{:.3e}\t{:.3e}".format(inert[0][0][0], inert[0][0][1], inert[0][0][2]))
print("\t{:.3e}\t{:.3e}\t{:.3e}".format(inert[0][1][0], inert[0][1][1], inert[0][1][2]))
print("\t{:.3e}\t{:.3e}\t{:.3e}".format(inert[0][2][0], inert[0][2][1], inert[0][2][2]))
print("\nEigenvalues:")
print("\t{:.3e}\t{:.3e}\t{:.3e}".format(inert[1][0], inert[1][1], inert[1][2]))
print("\nRotor type: {}".format(inert[2]))
input("\nPress enter to return to the menu ... ")
molecule_interface()
elif calculation_choice == "b":
molecule_interface()
elif calculation_choice == "q":
sys.exit()
elif choice == "5":
utils.clear()
print("================================================")
print(" LINEAR TRANSIT MODULE")
print("================================================")
print("Select the ID for the start and end structures\n")
ID_start = ask_ID()
ID_end = ask_ID()
n_steps = int(input("Select the number of intermediate structures:\t"))
path = input("Select the destination path (without final extension):\t")
print('\n')
mol.rigid_linear_transit(MOL_LIST[ID_start-1], MOL_LIST[ID_end-1], n_steps, path)
molecule_interface()
elif choice == "l":
utils.header(__VERSION__)
list_molecules()
input("\nPress enter to return to the menu ... ")
molecule_interface()
elif choice == "b":
main()
elif choice == "q":
sys.exit()
MOL_LIST = []
if len(sys.argv) == 1:
main()
else:
utils.header(__VERSION__)
if sys.argv[1].split(".")[-1] == "interp":
print("\nQUICK MODE:\tDetected .interp file. Opening as fast as I can...")
neb_vis.main(sys.argv[1])
elif sys.argv[1].split(".")[-1] == "out":
print("\nQUICK MODE:\tDetected .out file. Opening as fast as I can...")
out_sum.main(sys.argv[1])
elif sys.argv[1] == "load":
print("\nQUICK MODE:\tDetected load instruction.\nLoading .xyz files...")
print("------------------------------------------------")
for i, argument in enumerate(sys.argv):
if i > 1 and argument.split(".")[-1] == "xyz":
MOL_LIST.append(mol.MOL(argument))
print("Molecule saved with the ID:\t" + str(len(MOL_LIST)))
print("------------------------------------------------")
print("Loading DONE. " + str(len(MOL_LIST)) + " files loaded succesfully")
input("\nPress enter to continue ... ")
main()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("Interrupted by user")
try:
sys.exit(0)
except SystemExit:
os._exit(0)