-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathall_formula_prop_table.py
42 lines (39 loc) · 2.03 KB
/
all_formula_prop_table.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
"""
This script generates multiple statistal analysis tables for fitting all charges using all 16 formulas and all 9 properties.
Output is a LaTex formatted table, which you can directly copy to LaTex editor.
"""
import modules as mod
from tabulate import tabulate
import pandas as pd
from contextlib import suppress
import time
import os
start = time.perf_counter()
file_name = f"csv/ions.csv"
formula_list = ["Q1R1", "Q1R2", "Q2R1", "Q2R2", "Q3R1","Q3R2", "Q4R1", "Q4R2", "Q5R1", "Q5R2", "Q6R1","Q6R2", "Q7R1", "Q7R2", "Q8R1", "Q8R2"]
property_list = ["dG", "dH", "viscosity", "diffusion", "gfet", "dlcst", "sn2", "activity", "lysozyme"]
save_dir_path = "tables"
if __name__ == "__main__":
if not os.path.exists(save_dir_path):
os.makedirs(save_dir_path)
for per, property in enumerate(property_list):
stats_list = []
aicc_list = []
for each, formula in enumerate(formula_list):
formula_func = getattr(mod.formulas, formula)
df = mod.read_data(file_name, property, formula, by_charge=False)
with suppress(TypeError, ZeroDivisionError):
prop, fit_data, parameters, SE = mod.fit_parameters(formula, formula_func, property, df)
mean_abs_err, rmse, loocv, aicc = mod.get_errors(prop, fit_data, parameters)
aicc_list.append(aicc)
stats_df = mod.print_stats(formula, parameters, SE, mean_abs_err, rmse, loocv, aicc)
stats_list.append(stats_df)
stats_result = pd.concat(stats_list, axis=1)
stats_result = mod.replace_aicc(aicc_list, stats_result)
stats_result = stats_result.fillna("-")
with open(f"{save_dir_path}/all_{property}.txt", "w", encoding="utf-8") as f:
f.write(f"All Charges\n")
f.write(tabulate(stats_result, headers="keys", stralign="center", tablefmt='fancy_grid'))
print(f"Finished with {property}..")
end = time.perf_counter()
print(f'Finished in {round(end-start,2)} seconds') # 11.14 s on gpu desktop.