-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graphic_user_interface.py
160 lines (133 loc) · 4.81 KB
/
Graphic_user_interface.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
import tkinter as tk
from with_gui_fitting_fstat import run_fitting
import warnings
warnings.filterwarnings("ignore", category=RuntimeWarning)
# Wrapper function to get input from GUI and run the actual function
def run_function():
my_file_value = my_file.get()
my_sheet_value = sheet_name.get()
x_name_value = x_name.get()
y_name_value = y_name.get()
# Use eval to convert the string to a tuple
bounds_A_value = eval(bounds_A.get())
guess_A_value = eval(guess_A.get())
bounds_B_value = eval(bounds_B.get())
guess_B_value = eval(guess_B.get())
bounds_C_value = eval(bounds_C.get())
guess_C_value = eval(guess_C.get())
bounds_D_value = eval(bounds_D.get())
guess_D_value = eval(guess_D.get())
bounds_E_value = eval(bounds_E.get())
guess_E_value = eval(guess_E.get())
p_value = eval( p_value_significance.get() )
mc_runs_value = eval( mc_runs.get() )
n_hop_value = eval( n_hop.get() )
temp_value = eval( temp.get() )
verbosity_value = eval( verbosity.get() )
# Call the actual fitting function
result = run_fitting(
my_file=my_file_value,
sheet_name = my_sheet_value,
x_name = x_name_value,
y_name = y_name_value,
bounds_A = bounds_A_value,
guess_A = guess_A_value,
bounds_B = bounds_B_value,
guess_B = guess_B_value,
bounds_C = bounds_C_value,
guess_C = guess_C_value,
bounds_D = bounds_D_value,
guess_D = guess_D_value,
bounds_E = bounds_E_value,
guess_E = guess_E_value,
mc_runs = mc_runs_value,
n_hopping = n_hop_value,
T_hopping = temp_value,
p_for_significance = p_value,
verbose = verbosity_value,
)
return result
root = tk.Tk()
root.title("Graphic User Interface - Leave None if unknown")
# Define labels and entry widgets for parameters
tk.Label(root, text="Name of Excel file").pack()
my_file = tk.Entry(root)
my_file.pack()
my_file.insert(0, "Binding_curve_values.xlsx") # Default value
tk.Label(root, text="Name of Excel sheet").pack()
sheet_name = tk.Entry(root)
sheet_name.pack()
sheet_name.insert(0, "P2 ancestor - IgM cells only") # Default value
tk.Label(root, text="Name of X values column").pack()
x_name = tk.Entry(root)
x_name.pack()
x_name.insert(0, "X - IgM") # Default value
tk.Label(root, text="Name of Y values column").pack()
y_name = tk.Entry(root)
y_name.pack()
y_name.insert(0, "Y - binding signal") # Default value
tk.Label(root, text="Bounds for A value").pack()
bounds_A = tk.Entry(root)
bounds_A.pack()
bounds_A.insert(0, "(0, 10**3)") # Default value
tk.Label(root, text="Initial gues for A value").pack()
guess_A = tk.Entry(root)
guess_A.pack()
guess_A.insert(0, "None") # Default value
tk.Label(root, text="Bounds for B value").pack()
bounds_B = tk.Entry(root)
bounds_B.pack()
bounds_B.insert(0, "(0, 5 * 10**4)") # Default value
tk.Label(root, text="Initial gues for B value").pack()
guess_B = tk.Entry(root)
guess_B.pack()
guess_B.insert(0, "None") # Default value
tk.Label(root, text="Bounds for C value").pack()
bounds_C = tk.Entry(root)
bounds_C.pack()
bounds_C.insert(0, "(10**(-9), 1.0)" ) # Default value
tk.Label(root, text="Initial gues for C value").pack()
guess_C = tk.Entry(root)
guess_C.pack()
guess_C.insert(0, "None") # Default value
tk.Label(root, text="Bounds for D value").pack()
bounds_D = tk.Entry(root)
bounds_D.pack()
bounds_D.insert(0, "(1, 25)") # Default value
tk.Label(root, text="Initial guess for D value").pack()
guess_D = tk.Entry(root)
guess_D.pack()
guess_D.insert(0, "None") # Default value
tk.Label(root, text="Bounds for E value").pack()
bounds_E = tk.Entry(root)
bounds_E.pack()
bounds_E.insert(0, "(10**(-9), 1)") # Default value
tk.Label(root, text="Initial guess for E value").pack()
guess_E = tk.Entry(root)
guess_E.pack()
guess_E.insert(0, "None") # Default value
tk.Label(root, text="p value chosen for statistical significance wrt no signal hypothesis").pack()
p_value_significance = tk.Entry(root)
p_value_significance.pack()
p_value_significance.insert(0, "0.01") # Default value
tk.Label(root, text="Number of independent Monte Carlo runs").pack()
mc_runs = tk.Entry(root)
mc_runs.pack()
mc_runs.insert(0, "None") # Default value
tk.Label(root, text="Number of hopping steps x Monte Carlo run").pack()
n_hop = tk.Entry(root)
n_hop.pack()
n_hop.insert(0, "None") # Default value
tk.Label(root, text="Temperature for Monte Carlo basin hopping").pack()
temp = tk.Entry(root)
temp.pack()
temp.insert(0, "None") # Default value
tk.Label(root, text="Maximum verbosity of output?").pack()
verbosity = tk.Entry(root)
verbosity.pack()
verbosity.insert(0, "False") # Default value
# Button to run the function
run_button = tk.Button(root, text="Run Function", command=run_function)
run_button.pack()
# Start the GUI event loop
root.mainloop()