cgeorgiaw HF Staff commited on
Commit
775cc65
·
1 Parent(s): a60d40d

change column names

Browse files
Files changed (1) hide show
  1. app.py +69 -65
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import os
2
- import datetime as dt
3
  from typing import List
4
 
5
  import gradio as gr
@@ -12,29 +11,26 @@ CONFIGS = {'antibody':'Antibody–Antigen', 'ligand':'Allosteric–Orthosteric',
12
  # Column schemas per tab (used to create empty frames and to order columns)
13
  COLUMNS = {
14
  "antibody": [
15
- "timestamp",
16
- "user",
17
- "model_name",
18
- "antibody_id",
19
- "antigen_id",
20
- "predicted_affinity",
21
- "notes",
22
  ],
23
  "ligand": [
24
- "timestamp",
25
- "user",
26
- "model_name",
27
- "protein_id",
28
- "ligand_type",
29
- "predicted_kd",
30
- "notes",
31
  ],
32
  "final": [
33
- "timestamp",
34
- "team_name",
35
- "archive_url",
36
- "results_summary",
37
- "contact_email",
38
  ],
39
  }
40
 
@@ -83,19 +79,20 @@ def push_df(config: str, df: pd.DataFrame) -> None:
83
  # --- Tab logic --------------------------------------------------------------
84
  # Antibody–Antigen
85
 
86
- def submit_antibody(user, model_name, antibody_id, antigen_id, predicted_affinity, notes):
87
  config = CONFIGS["antibody"]
88
  cols = COLUMNS["antibody"]
89
  df = load_df(config, cols)
90
  row = {
91
- "timestamp": dt.datetime.now(dt.timezone.utc).isoformat(),
92
- "user": user or "",
93
- "model_name": model_name or "",
94
- "antibody_id": antibody_id or "",
95
- "antigen_id": antigen_id or "",
96
- "predicted_affinity": float(predicted_affinity) if predicted_affinity is not None else None,
97
- "notes": notes or "",
98
  }
 
 
 
99
  df = pd.concat([df, pd.DataFrame([row])], ignore_index=True)
100
  push_df(config, df)
101
  # Re-load to ensure what we show is exactly what's on the Hub
@@ -108,19 +105,21 @@ def refresh_antibody():
108
 
109
  # Allosteric–Orthosteric
110
 
111
- def submit_ligand(user, model_name, protein_id, ligand_type, predicted_kd, notes):
112
  config = CONFIGS["ligand"]
113
  cols = COLUMNS["ligand"]
114
  df = load_df(config, cols)
115
  row = {
116
- "timestamp": dt.datetime.now(dt.timezone.utc).isoformat(),
117
- "user": user or "",
118
- "model_name": model_name or "",
119
- "protein_id": protein_id or "",
120
- "ligand_type": ligand_type or "",
121
- "predicted_kd": float(predicted_kd) if predicted_kd is not None else None,
122
- "notes": notes or "",
123
  }
 
 
 
124
  df = pd.concat([df, pd.DataFrame([row])], ignore_index=True)
125
  push_df(config, df)
126
  return load_df(config, cols)
@@ -132,17 +131,20 @@ def refresh_ligand():
132
 
133
  # Final Submission
134
 
135
- def submit_final(team_name, archive_url, results_summary, contact_email):
136
  config = CONFIGS["final"]
137
  cols = COLUMNS["final"]
138
  df = load_df(config, cols)
139
  row = {
140
- "timestamp": dt.datetime.now(dt.timezone.utc).isoformat(),
141
- "team_name": team_name or "",
142
- "archive_url": archive_url or "",
143
- "results_summary": results_summary or "",
144
- "contact_email": contact_email or "",
145
  }
 
 
 
146
  df = pd.concat([df, pd.DataFrame([row])], ignore_index=True)
147
  push_df(config, df)
148
  return load_df(config, cols)
@@ -161,18 +163,16 @@ with gr.Blocks(title="Binding Challenges") as app:
161
  # Antibody-Antigen Binding Challenge
162
  The goal of this challenge is to improve Boltz-2 accuracy for predicting the correct poses of a VHH binding to an antigen.\n
163
  Accuracy will be measured through the Capri-Q docking assessment classification scores and the final winner will be determined based on the number of successful top-1 predictions on our *internal* test set. However, you are encouraged to submit results on the training set during the hack to see where you stack up.\n
164
- A prediction is deemed successful if the Capri-Q classification is either high”, medium”, or acceptable”.
165
- If multiple entries reach the same number of successful predictions, ties are broken by looking at the number of predictions with High classification, then with Medium classification and finally with Acceptable classification.
166
  If there is still a tie then, we will look at the mean RMSD across all successful predictions.
167
  """)
 
168
  with gr.Row():
169
- aa_user = gr.Textbox(label="User / Team", placeholder="Your name or team")
170
- aa_model = gr.Textbox(label="Model Name")
171
- with gr.Row():
172
- aa_antibody = gr.Textbox(label="Antibody ID")
173
- aa_antigen = gr.Textbox(label="Antigen ID")
174
- aa_aff = gr.Number(label="Predicted affinity (nM)")
175
- aa_notes = gr.Textbox(label="Notes", lines=3)
176
  with gr.Row():
177
  aa_submit = gr.Button("Submit")
178
  aa_refresh = gr.Button("Refresh table")
@@ -184,7 +184,7 @@ with gr.Blocks(title="Binding Challenges") as app:
184
  )
185
  aa_submit.click(
186
  submit_antibody,
187
- inputs=[aa_user, aa_model, aa_antibody, aa_antigen, aa_aff, aa_notes],
188
  outputs=aa_df,
189
  )
190
  aa_refresh.click(refresh_antibody, outputs=aa_df)
@@ -192,17 +192,17 @@ with gr.Blocks(title="Binding Challenges") as app:
192
  with gr.Tab("Allosteric–Orthosteric Ligand Binding Challenge"):
193
  gr.Markdown("""
194
  # Allosteric-Orthosteric Ligand Binding Challenge
195
- The goal of this challenge is to improve Boltz-2 accuracy for predicting the binding poses of either allosteric or orthosteric ligands.\n
196
  The winner will be determined by accuracy measured on our *internal* test set by calculating the RMSD between the top-1 prediction and the experimental pose. However, submit your intermediate results here to see where you stack up!
197
  """)
 
198
  with gr.Row():
199
- li_user = gr.Textbox(label="User / Team")
200
- li_model = gr.Textbox(label="Model Name")
 
201
  with gr.Row():
202
- li_protein = gr.Textbox(label="Protein ID")
203
- li_type = gr.Radio(["allosteric", "orthosteric"], label="Ligand type")
204
- li_kd = gr.Number(label="Predicted Kd (nM)")
205
- li_notes = gr.Textbox(label="Notes", lines=3)
206
  with gr.Row():
207
  li_submit = gr.Button("Submit")
208
  li_refresh = gr.Button("Refresh table")
@@ -214,16 +214,20 @@ with gr.Blocks(title="Binding Challenges") as app:
214
  )
215
  li_submit.click(
216
  submit_ligand,
217
- inputs=[li_user, li_model, li_protein, li_type, li_kd, li_notes],
218
  outputs=li_df,
219
  )
220
  li_refresh.click(refresh_ligand, outputs=li_df)
221
 
222
  with gr.Tab("3) Final Submission"):
223
- fs_team = gr.Textbox(label="Team name")
224
- fs_archive = gr.Textbox(label="Archive URL (e.g., model artifacts)")
225
- fs_summary = gr.Textbox(label="Results summary", lines=4)
226
- fs_email = gr.Textbox(label="Contact email")
 
 
 
 
227
  with gr.Row():
228
  fs_submit = gr.Button("Submit")
229
  fs_refresh = gr.Button("Refresh table")
@@ -235,7 +239,7 @@ with gr.Blocks(title="Binding Challenges") as app:
235
  )
236
  fs_submit.click(
237
  submit_final,
238
- inputs=[fs_team, fs_archive, fs_summary, fs_email],
239
  outputs=fs_df,
240
  )
241
  fs_refresh.click(refresh_final, outputs=fs_df)
 
1
  import os
 
2
  from typing import List
3
 
4
  import gradio as gr
 
11
  # Column schemas per tab (used to create empty frames and to order columns)
12
  COLUMNS = {
13
  "antibody": [
14
+ "group_name",
15
+ "successful",
16
+ "high",
17
+ "medium",
18
+ "acceptable",
 
 
19
  ],
20
  "ligand": [
21
+ "group_name",
22
+ "rmsd_top1_all",
23
+ "rmsd_top1_allosteric",
24
+ "rmsd_top1_orthosteric",
25
+ "rmsd_top5_all",
26
+ "structures_under_2a",
 
27
  ],
28
  "final": [
29
+ "group_name",
30
+ "repository_url",
31
+ "commit_sha",
32
+ "challenge_type",
33
+ "description_link",
34
  ],
35
  }
36
 
 
79
  # --- Tab logic --------------------------------------------------------------
80
  # Antibody–Antigen
81
 
82
+ def submit_antibody(group_name, successful, high, medium, acceptable):
83
  config = CONFIGS["antibody"]
84
  cols = COLUMNS["antibody"]
85
  df = load_df(config, cols)
86
  row = {
87
+ "group_name": group_name or "",
88
+ "successful": int(successful) if successful is not None else 0,
89
+ "high": int(high) if high is not None else 0,
90
+ "medium": int(medium) if medium is not None else 0,
91
+ "acceptable": int(acceptable) if acceptable is not None else 0,
 
 
92
  }
93
+ # Overwrite if group_name already exists
94
+ if group_name and not df.empty:
95
+ df = df[df["group_name"] != group_name]
96
  df = pd.concat([df, pd.DataFrame([row])], ignore_index=True)
97
  push_df(config, df)
98
  # Re-load to ensure what we show is exactly what's on the Hub
 
105
 
106
  # Allosteric–Orthosteric
107
 
108
+ def submit_ligand(group_name, rmsd_top1_all, rmsd_top1_allosteric, rmsd_top1_orthosteric, rmsd_top5_all, structures_under_2a):
109
  config = CONFIGS["ligand"]
110
  cols = COLUMNS["ligand"]
111
  df = load_df(config, cols)
112
  row = {
113
+ "group_name": group_name or "",
114
+ "rmsd_top1_all": float(rmsd_top1_all) if rmsd_top1_all is not None else None,
115
+ "rmsd_top1_allosteric": float(rmsd_top1_allosteric) if rmsd_top1_allosteric is not None else None,
116
+ "rmsd_top1_orthosteric": float(rmsd_top1_orthosteric) if rmsd_top1_orthosteric is not None else None,
117
+ "rmsd_top5_all": float(rmsd_top5_all) if rmsd_top5_all is not None else None,
118
+ "structures_under_2a": int(structures_under_2a) if structures_under_2a is not None else 0,
 
119
  }
120
+ # Overwrite if group_name already exists
121
+ if group_name and not df.empty:
122
+ df = df[df["group_name"] != group_name]
123
  df = pd.concat([df, pd.DataFrame([row])], ignore_index=True)
124
  push_df(config, df)
125
  return load_df(config, cols)
 
131
 
132
  # Final Submission
133
 
134
+ def submit_final(group_name, repository_url, commit_sha, challenge_type, description_link):
135
  config = CONFIGS["final"]
136
  cols = COLUMNS["final"]
137
  df = load_df(config, cols)
138
  row = {
139
+ "group_name": group_name or "",
140
+ "repository_url": repository_url or "",
141
+ "commit_sha": commit_sha or "",
142
+ "challenge_type": challenge_type or "",
143
+ "description_link": description_link or "",
144
  }
145
+ # Overwrite if group_name already exists
146
+ if group_name and not df.empty:
147
+ df = df[df["group_name"] != group_name]
148
  df = pd.concat([df, pd.DataFrame([row])], ignore_index=True)
149
  push_df(config, df)
150
  return load_df(config, cols)
 
163
  # Antibody-Antigen Binding Challenge
164
  The goal of this challenge is to improve Boltz-2 accuracy for predicting the correct poses of a VHH binding to an antigen.\n
165
  Accuracy will be measured through the Capri-Q docking assessment classification scores and the final winner will be determined based on the number of successful top-1 predictions on our *internal* test set. However, you are encouraged to submit results on the training set during the hack to see where you stack up.\n
166
+ A prediction is deemed successful if the Capri-Q classification is either "high", "medium", or "acceptable".
167
+ If multiple entries reach the same number of successful predictions, ties are broken by looking at the number of predictions with "High" classification, then with "Medium" classification and finally with "Acceptable" classification.
168
  If there is still a tie then, we will look at the mean RMSD across all successful predictions.
169
  """)
170
+ aa_group = gr.Textbox(label="Group Name", placeholder="Your group name")
171
  with gr.Row():
172
+ aa_successful = gr.Number(label="#Successful", value=0, precision=0)
173
+ aa_high = gr.Number(label="#High", value=0, precision=0)
174
+ aa_medium = gr.Number(label="#Medium", value=0, precision=0)
175
+ aa_acceptable = gr.Number(label="#Acceptable", value=0, precision=0)
 
 
 
176
  with gr.Row():
177
  aa_submit = gr.Button("Submit")
178
  aa_refresh = gr.Button("Refresh table")
 
184
  )
185
  aa_submit.click(
186
  submit_antibody,
187
+ inputs=[aa_group, aa_successful, aa_high, aa_medium, aa_acceptable],
188
  outputs=aa_df,
189
  )
190
  aa_refresh.click(refresh_antibody, outputs=aa_df)
 
192
  with gr.Tab("Allosteric–Orthosteric Ligand Binding Challenge"):
193
  gr.Markdown("""
194
  # Allosteric-Orthosteric Ligand Binding Challenge
195
+ The goal of this challenge is to improve Boltz-2 accuracy for predicting the binding poses of either allosteric or orthosteric ligands.\n
196
  The winner will be determined by accuracy measured on our *internal* test set by calculating the RMSD between the top-1 prediction and the experimental pose. However, submit your intermediate results here to see where you stack up!
197
  """)
198
+ li_group = gr.Textbox(label="Group Name", placeholder="Your group name")
199
  with gr.Row():
200
+ li_rmsd_top1_all = gr.Number(label="RMSD top-1 (all structures)")
201
+ li_rmsd_top1_allosteric = gr.Number(label="RMSD top-1 (allosteric)")
202
+ li_rmsd_top1_orthosteric = gr.Number(label="RMSD top-1 (orthosteric)")
203
  with gr.Row():
204
+ li_rmsd_top5_all = gr.Number(label="RMSD top-5 (all structures)")
205
+ li_structures_under_2a = gr.Number(label="#structures with RMSD < 2A", value=0, precision=0)
 
 
206
  with gr.Row():
207
  li_submit = gr.Button("Submit")
208
  li_refresh = gr.Button("Refresh table")
 
214
  )
215
  li_submit.click(
216
  submit_ligand,
217
+ inputs=[li_group, li_rmsd_top1_all, li_rmsd_top1_allosteric, li_rmsd_top1_orthosteric, li_rmsd_top5_all, li_structures_under_2a],
218
  outputs=li_df,
219
  )
220
  li_refresh.click(refresh_ligand, outputs=li_df)
221
 
222
  with gr.Tab("3) Final Submission"):
223
+ fs_group = gr.Textbox(label="Group Name", placeholder="Your group name")
224
+ fs_repo_url = gr.Textbox(label="Repository URL")
225
+ fs_commit_sha = gr.Textbox(label="Commit SHA")
226
+ fs_challenge_type = gr.Radio(
227
+ ["allosteric-orthosteric binding", "antibody-antigen binding"],
228
+ label="Challenge Type"
229
+ )
230
+ fs_description_link = gr.Textbox(label="Link to Markdown Description", placeholder="Link to a markdown page in your repo")
231
  with gr.Row():
232
  fs_submit = gr.Button("Submit")
233
  fs_refresh = gr.Button("Refresh table")
 
239
  )
240
  fs_submit.click(
241
  submit_final,
242
+ inputs=[fs_group, fs_repo_url, fs_commit_sha, fs_challenge_type, fs_description_link],
243
  outputs=fs_df,
244
  )
245
  fs_refresh.click(refresh_final, outputs=fs_df)