-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.py
209 lines (188 loc) · 8.17 KB
/
app.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
# from data.single_pred_tasks.tasks import _TASKS
import task_datasets as data
import benchmark.groups as benchmark_groups
import benchmark.leaderboards as benchmark_leaderboards
from flask import Flask, flash, redirect, render_template, request, session, url_for
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/start', strict_slashes=False)
def start():
return render_template('start.html')
@app.route('/overview', strict_slashes=False)
def overview():
return render_template('overview/index.html')
@app.route("/news", strict_slashes=False)
def news():
return render_template('news.html')
@app.route("/team", strict_slashes=False)
def team():
return render_template('team.html')
@app.route('/single_pred_tasks/overview', strict_slashes=False)
def single_pred_tasks():
vars = {
"items": data.single_pred_tasks.tasks,
"data": [(endpt, label, data.single_pred_tasks.datasets[endpt]) for endpt, label, _ in data.single_pred_tasks.tasks[1:]] # skip adme
}
return render_template('single_pred_tasks/index.html', **vars)
@app.route("/single_pred_tasks/<task>", strict_slashes=False)
def single_pred_tasks_data(task):
if task == "adme":
return render_template("single_pred_tasks/adme.html")
if task.lower() == "mpc":
return render_template("single_pred_tasks/MPC.html")
elif task in data.single_pred_tasks.datasets:
datasets = []
for var in data.single_pred_tasks.datasets[task]:
if var in data.single_pred_tasks.meta:
if len(data.single_pred_tasks.meta[var]) != 10:
raise Exception(var, len(data.single_pred_tasks.meta[var]))
datasets.append([var] + data.single_pred_tasks.meta[var])
desc = data.single_pred_tasks.desc[task]
args = {
"datasets": datasets,
"task": task,
"desc_id": desc[0],
"desc_title": desc[1],
"desc_desc": desc[2],
"desc_impact": desc[3],
"desc_gen": desc[4],
"desc_product": desc[5],
"desc_pipeline": desc[6],
}
return render_template("single_pred_tasks/task.html", **args)
return redirect("/single_pred_tasks/overview")
@app.route("/multi_pred_tasks/overview", strict_slashes=False)
def multi_pred_tasks():
vars = {
"items": data.multi_pred_tasks.tasks,
"data": [(endpt, label, data.multi_pred_tasks.datasets[endpt]) for endpt, label, _ in data.multi_pred_tasks.tasks]
}
return render_template("multi_pred_tasks/index.html", **vars)
@app.route("/multi_pred_tasks/<task>", strict_slashes=False)
def multi_pred_task_data(task):
if task == "catalyst":
return render_template("multi_pred_tasks/catalyst.html")
elif task == "ddi":
return render_template("multi_pred_tasks/ddi.html")
elif task == "drugres":
return render_template("multi_pred_tasks/drugres.html")
elif task == "dti":
return render_template("multi_pred_tasks/dti.html")
elif task == "mti":
return render_template("multi_pred_tasks/mti.html")
elif task == "ppi":
return render_template("multi_pred_tasks/ppi.html")
elif task == "proteinpeptide":
return render_template("multi_pred_tasks/proteinpeptide.html")
elif task == "tcrepitope":
return render_template("multi_pred_tasks/tcrepitope.html")
elif task == "antibodyaff":
return render_template("multi_pred_tasks/antibodyaff.html")
elif task == "trialoutcome":
return render_template("multi_pred_tasks/trialoutcome.html")
elif task == "scdti":
return render_template("multi_pred_tasks/scdti.html")
elif task == "counterfactual":
return render_template("multi_pred_tasks/counterfactual.html")
elif task in data.multi_pred_tasks.datasets:
datasets = []
for var in data.multi_pred_tasks.datasets[task]:
if var in data.multi_pred_tasks.meta:
if len(data.multi_pred_tasks.meta[var]) != 10:
raise Exception(var, len(data.multi_pred_tasks.meta[var]))
datasets.append([var] + data.multi_pred_tasks.meta[var])
desc = data.multi_pred_tasks.desc[task]
args = {
"datasets": datasets,
"task": task,
"desc_id": desc[0],
"desc_title": desc[1],
"desc_desc": desc[2],
"desc_impact": desc[3],
"desc_gen": desc[4],
"desc_product": desc[5],
"desc_pipeline": desc[6],
}
return render_template("multi_pred_tasks/task.html", **args)
else:
return redirect("/multi_pred_tasks/overview")
@app.route("/generation_tasks/overview", strict_slashes=False)
def generation_tasks():
return render_template("generation_tasks/index.html")
@app.route("/generation_tasks/<task>", strict_slashes=False)
def generation_tasks_data(task):
if task == "molgen":
return render_template("generation_tasks/molgen.html")
elif task == "reaction":
return render_template("generation_tasks/reaction.html")
elif task == "retrosyn":
return render_template("generation_tasks/retrosyn.html")
elif task == "sbdd":
return render_template("generation_tasks/sbdd.html")
else:
return redirect("/generation_tasks/overview")
@app.route("/fct_overview", strict_slashes=False)
def fct_overview():
return render_template("/fct_overview.html")
@app.route("/functions/<section>", strict_slashes=False)
def function_page(section):
if section == "oracles":
return render_template("/functions/oracles.html")
elif section == "data_evaluation":
return render_template("/functions/data_evaluation.html")
elif section == "data_process":
return render_template("/functions/data_process.html")
elif section == "data_split":
return render_template("/functions/data_split.html")
else:
return redirect("/fct_overview")
@app.route("/benchmark", strict_slashes=False)
def benchmark():
return render_template("/benchmark/index.html")
@app.route("/benchmark/overview", strict_slashes=False)
def benchmark_overview():
return render_template("/benchmark/index.html")
@app.route("/benchmark/<group>/<leaderboard>", strict_slashes=False)
def benchmark_leaderboard_overview(group, leaderboard):
leads = benchmark_groups._GROUP_MEMBERSHIP[group]
if leaderboard == "overview":
if group != "clinical_trial":
group = '_'.join(group.split("_")[:-1])
s = "/benchmark/{}.html".format(group)
else:
s = "/benchmark/clinical_trial.html"
args = {
"leaderboards": leads
}
return render_template(s, **args)
elif leaderboard == "DrugComb_CSS" and group == "drugcombo_group":
return render_template("/benchmark/drugcomb_css.html")
elif leaderboard == "DRD3" and group == "docking_group":
return render_template("/benchmark/drd3.html")
elif leaderboard == "scperturb_drug_SrivatsanTrapnell2020_sciplex2" and group == "counterfactual_group":
return render_template("/benchmark/scperturb_drug_SrivatsanTrapnell2020_sciplex2.html")
else:
lb = benchmark_leaderboards._LEADERBOARDS[leaderboard]
order, entries, scores = lb[2], lb[3], lb[4]
if len(entries) != len(scores):
raise ValueError("length of lb entries {} does not match length of provided scores {} for lb {}".format(len(entries), len(scores), leaderboard))
increasing = order == "incr"
sidxs = sorted([i for i in range(len(entries))], key=lambda idx: entries[idx][-1] if increasing else -entries[idx][-1])
lb[3] = [entries[i] for i in sidxs]
lb[4] = [scores[i] for i in sidxs]
args = {
"entries": entries,
"scores": scores,
"group": group,
"leaderboard": leaderboard,
"style": lb[0],
"cols": lb[1],
"extra_vals": lb[-1],
"extra_cols": lb[-2],
"leaderboards": leads,
}
return render_template("/benchmark/leaderboard.html", **args)
if __name__ == '__main__':
app.run(debug=True) # debug=True for development mode