File size: 15,671 Bytes
b78ff28
 
 
 
 
 
 
 
 
 
 
 
 
49442cb
 
 
 
 
 
 
 
 
b78ff28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
580f4e5
 
 
 
b78ff28
 
 
5cc7fac
b78ff28
 
64f5800
b78ff28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49442cb
b78ff28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49442cb
 
 
 
b78ff28
 
 
 
 
 
 
2d55f13
b78ff28
 
 
49442cb
 
 
 
 
 
b78ff28
49442cb
b78ff28
 
49442cb
 
b78ff28
7362b7c
 
 
 
 
 
b78ff28
 
2d55f13
b78ff28
49442cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b78ff28
49442cb
 
b78ff28
 
 
 
 
 
 
 
 
49442cb
 
 
 
2026d3e
 
 
 
 
 
49442cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b78ff28
 
 
 
 
49442cb
 
b78ff28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49442cb
 
 
 
 
580f4e5
 
 
49442cb
 
 
 
b78ff28
 
 
 
 
 
ab2340e
 
b78ff28
64f5800
b78ff28
 
 
 
 
 
580f4e5
 
 
 
 
b78ff28
 
 
 
 
afe62bb
 
b78ff28
 
49442cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b78ff28
 
 
 
 
49442cb
 
 
b78ff28
 
 
 
 
 
 
2d55f13
b78ff28
 
49442cb
 
b78ff28
 
 
 
 
 
 
 
 
 
 
 
 
49442cb
 
b78ff28
 
 
 
49442cb
b78ff28
 
 
 
 
 
 
 
 
 
 
 
49442cb
 
b78ff28
 
 
49442cb
b78ff28
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
"""Configuration for the PLUG challenge Hugging Face Space.

Everything challenge-specific that is *presentation* lives here: the phase
switch, the rate limit, the external links, and the page-content markdown. The
benchmarks themselves β€” names, schemas, metrics, which file goes in the bundle β€”
come from ``plug_challenge.benchmarks``, which both this Space and the scorer
import, so the Space can never describe a benchmark differently from how it is
scored.

"""

import os

from plug_challenge.benchmarks import (
    BENCHMARKS,
    GO_ASPECTS,
    ID_COLUMN,
    SHS27K_MODES,
    TRACK_DESCRIPTIONS,
    TRACK_LABELS,
    TRACKS,
)
from plug_challenge.store import PRIVATE_REPO, PUBLIC_REPO

# ------------------------------- Challenge state --------------------------------------

# Updated manually to control what the Space shows.
#   0: Pre-challenge β€” leaderboard and submission portal show placeholders
#   1: Open β€” submissions accepted, live leaderboard
#   2: Closed β€” submissions rejected, leaderboard frozen as the final standings
CURRENT_PHASE = int(os.environ.get("CURRENT_PHASE", "0"))

# Minimum gap between two submissions from one Hugging Face account. PLUG scores
# synchronously against held-back labels, so without a cooldown a participant
# could tune against the test set by resubmitting in a loop.
HOURS_BETWEEN_SUBMISSIONS = 12

# Bootstrap resamples used for the per-metric standard deviation shown on the
# leaderboard. Scoring runs inside the submission request, so this is 0 (point
# estimates only) by default; the organisers' `plug-challenge score --bootstrap`
# computes intervals offline. cafa5's Fmax never bootstraps β€” see scoring.py.
BOOTSTRAP_SAMPLES = int(os.environ.get("BOOTSTRAP_SAMPLES", "0"))

# Partial bundles are accepted: a benchmark left out counts as chance (0) in the PLUG
# Score, so the overall board is not inflated, and the entry still ranks on the tab of
# every benchmark it did cover. Set True to require all eleven files.
REQUIRE_COMPLETE_BUNDLE = False

# ------------------------------- Links ------------------------------------------------

CHALLENGE_ANNOUNCEMENT_LINK = "https://thestacks.org/publications/plug-benchmark"
DATASET_DOWNLOAD_LINK = f"https://huggingface.co/datasets/{PUBLIC_REPO}"
TUTORIAL_LINK = "https://github.com/PrismScienceOrg/plug-baselines"
PLUG_REPO_LINK = "https://github.com/prism-science/plug"
COMMUNITY_LINK = ""

PAGE_TITLE = "PLUG Challenge"

# ------------------------------- Derived benchmark copy -------------------------------

BENCHMARK_COUNT = len(BENCHMARKS)


def _benchmark_table_md() -> str:
    """Build the benchmark overview table from the specs."""
    rows = [
        "| Benchmark | Scored unit | Primary metric | Submission file |",
        "| :--- | :--- | :--- | :--- |",
    ]
    for spec in BENCHMARKS:
        rows.append(
            f"| **{spec.label}** | one {spec.unit} | {spec.primary.label} | "
            f"`{spec.filename}` |"
        )
    return "\n".join(rows)


def _schema_table_md(spec) -> str:
    """Build one benchmark's submission column table."""
    rows = [
        "| Column | Type | Description |",
        "| :--- | :--- | :--- |",
        f"| `{ID_COLUMN}` | string | The row's id, copied from the manifest |",
    ]
    if spec.long_form:
        rows.append("| `aspect` | string | GO branch: `bp`, `mf` or `cc` |")
        rows.append("| `term` | string | The GO term you are predicting, e.g. `GO:0005515` |")
    for column in spec.pred_columns:
        bound = (
            f" in [{spec.score_range[0]}, {spec.score_range[1]}]"
            if spec.score_range
            else ""
        )
        rows.append(f"| `{column}` | float | Your prediction{bound} |")
    return "\n".join(rows)


BENCHMARK_TABLE_MD = _benchmark_table_md()

SUBMISSION_SCHEMAS_MD = "\n\n".join(
    f"##### `{spec.filename}` β€” {spec.label}\n\n{spec.description}\n\n{_schema_table_md(spec)}"
    for spec in BENCHMARKS
)

TRACKS_MD = "\n".join(
    f"- **{TRACK_LABELS[track]}** β€” {TRACK_DESCRIPTIONS[track]}" for track in TRACKS
)

BUNDLE_TREE_MD = "\n".join(
    ["```", "plug_submission.zip", *[f"β”œβ”€β”€ {spec.filename}" for spec in BENCHMARKS[:-1]],
     f"└── {BENCHMARKS[-1].filename}", "```"]
)

# ------------------------------- Page content -----------------------------------------

HEADER_MARKDOWN = f"""## PLUG Challenge
**Protein Leakage-free evaluation for Unbiased Generators of function.**

Conventional protein benchmarks let the same protein appear in train and in test,
which inflates apparent performance. PLUG splits {BENCHMARK_COUNT} protein-function
benchmarks with Lo-Hi's balanced vertex k-cut over one similarity graph pooled across all
of them, so no test protein has a homolog in *any* benchmark's training set.

This challenge tracks how well models predict protein function under those splits, on
two leaderboards:

{TRACKS_MD}

Go to the **Leaderboard** for the current standings, or the **Submit** tab to enter.
Every number on the leaderboard was computed here against held-back labels, never
self-reported, and every entry links the method that produced it.

This is an untimed, open-ended challenge: you may submit multiple models and evaluations are 
based on the honor system (i.e., please do not use test labels to train or tune your unsupervised 
models). This project was developed and funded by the PRISM Science project at the Astera Institue 
and the Hugging Face challenge is maintained in conjunction with Project Protostar β€” an open science
initiative for AI-ready scientific data.

"""

HOW_TO_PARTICIPATE_MD = f"""## How to participate

1. **Get the data.** The [challenge dataset]({DATASET_DOWNLOAD_LINK}) holds, per benchmark,
   a `manifest` (every row's `datapoint_id`, its row index in plug's loader, the protein
   id(s) it is about, and its Lo-Hi split) and `proteins.csv` (protein id β†’ split). It
   carries **no labels**: fetch each benchmark from its original source with the download
   scripts and loaders in the [PLUG repository]({PLUG_REPO_LINK}), and join on the row
   index.
2. **Pick a track.** *Supervised*: train on the `train`/`val` rows, predict the `test`
   rows. *Unsupervised*: predict every row of every benchmark, without fitting to any of
   these labels.
3. **Build your model.** Pretrained weights, external data and ensembles are all fine.
   The [PLUG baselines]({TUTORIAL_LINK}) give zero-shot, linear-probe and fine-tuned
   reference numbers to beat.
4. **Make a bundle.** One file per benchmark, zipped. `plug-challenge template ./out
   --track supervised` writes the skeleton with that track's ids already in place.
5. **Validate it locally.** `plug-challenge validate plug_submission.zip --track
   supervised` runs exactly the checks this Space runs, so you find problems before
   uploading.
6. **Submit.** Choose the track and upload the zip on the **Submit** tab, with a link
   describing your method β€” the link is required. Scoring is immediate: you get your
   {BENCHMARK_COUNT} metrics and your PLUG Score back in the response.
7. **Disclose.** Flag proprietary training data and open code. Both are shown on the
   leaderboard beside your method link.

---"""

ABOUT_MD = f"""
# The PLUG Challenge

## Why leakage-free splits

The claim PLUG tests is that conventional benchmark splits inflate apparent performance
because the same or similar proteins appear in train and in test. A random split of
*measurements* leaks by design; similarity-penalising splitters make leakage merely
unlikely. PLUG makes it impossible. Proteins (and, separately, ligands) are nodes in one
graph pooled across all {BENCHMARK_COUNT} benchmarks, joined by an edge when they are too
alike to separate: MMseqs2 identity >0.3 over >0.8 of either sequence,
Foldseek TM-score >0.7, or ECFP4 Tanimoto >0.5. Lo-Hi's balanced vertex minimum k-cut then
assigns nodes to train/val/test so that no edge joins two splits, dropping as few datapoints
as it can and keeping every benchmark near 80/10/10. A datapoint is kept only when
everything it is about agrees on a split β€” both partners of an interaction, or the protein
*and* the ligand of an affinity measurement.

Because the graph is pooled, a test protein of one benchmark is never in another
benchmark's training set either, so the splits hold for transfer across benchmarks. See the
[PLUG repository]({PLUG_REPO_LINK}) for the method.

---

## Two tracks

{TRACKS_MD}

The unsupervised track is scored on every row, including the rows the Lo-Hi k-cut drops,
so it measures a method that never saw these labels on the full datasets. Train and val
labels are available from the original sources, so this track relies on the method link
every entry carries: a method fitted to these labels belongs in the supervised track.

---

## The {BENCHMARK_COUNT} benchmarks

Each contributes one file to your submission bundle and gets its own leaderboard tab in
both tracks.

{BENCHMARK_TABLE_MD}

Every residue number in every benchmark β€” mutation positions, allosteric sites β€” counts
along that benchmark's own `sequence`, starting at 1, and every per-residue vector is
exactly as long as the sequence beside it.

---

## Scoring

Each benchmark is scored with the metric its own literature uses, computed by the same
code as the [PLUG baselines]({TUTORIAL_LINK}) so a leaderboard number and a published
baseline number mean the same thing:

- **Rank correlation** (Spearman's ρ) for the ΔΔG, DMS fitness, affinity and RMSF
  benchmarks. DMS is scored *per assay* and averaged, because assay scores share no
  common scale.
- **AUROC** for the PPI and allosteric-site benchmarks, and **macro AUROC** over the
  seven STRING modes for SHS27k.
- **CAFA target-centric Fmax**, per GO branch and macro-averaged, for CAFA5.

### The PLUG Score

The headline number: the improvement over random chance, averaged over the
{BENCHMARK_COUNT} benchmarks. Each benchmark's primary metric is normalised so that chance
is 0 and perfect is 1 β€” Spearman's ρ as |ρ|, AUROC as 2 Γ— (AUROC βˆ’ 0.5), Fmax as is β€” and
the PLUG Score is their mean. A correlation is taken by its magnitude because its sign is a
convention of which way a label was written: a ρ of βˆ’0.99 is a very predictive model once
reversed. Nothing is clipped, so an AUROC below 0.5 counts against you. A benchmark you
leave out counts as chance (0), so the overall board rewards coverage; sort by a
benchmark's own tab to compare methods built for that one task.

It depends only on your own predictions, so it does not move as other entries arrive and is
safe to quote. `Mean rank` is shown beside it as the relative view. Each benchmark's tab
ranks by that benchmark's normalised score.

---

{HOW_TO_PARTICIPATE_MD if CURRENT_PHASE == 1 else ""}

## Acknowledgements
Authors: A. Clay Richard, Brian Cheung, and Stephanie A. Wankowicz

Every benchmark here is redistributed from its original authors under its own licence;
PLUG contributes the leakage-free splits, not the labels/measurements.
"""

_COMPLETENESS_ANSWER = (
    f"Yes β€” a bundle must carry all {BENCHMARK_COUNT} files. This keeps the PLUG Score "
    "an apples-to-apples comparison between complete methods."
    if REQUIRE_COMPLETE_BUNDLE
    else "No β€” submit only the benchmarks your method covers. Each one you leave out "
    "counts as chance (0) in your PLUG Score, so the overall board is not inflated, but "
    "you are ranked on the tab of every benchmark you did submit, and the Benchmarks "
    "column shows how many you covered. Only your latest submission per track is "
    "ranked, so a later partial bundle replaces an earlier complete one."
)

FAQ_MD = f"""
### Frequently asked questions

**For inquiries, recommendations, and discussion, email alan.richard@astera.org**

**What am I predicting?**
All {BENCHMARK_COUNT} benchmarks at once. One submission is a single `.zip` with one file
per benchmark; each file predicts every row of that benchmark's manifest in your track β€”
the `test` rows for the supervised track, every row for the unsupervised track.

**Which track should I enter?**
Supervised if your method is trained or tuned on any of these benchmarks' labels β€” then
use only the Lo-Hi `train` and `val` rows. Unsupervised if it never sees them (a zero-shot
or self-supervised score, for instance). You may enter both; each has its own leaderboard
and its own cooldown.

**Why is there no label data in the challenge dataset?**
Not every benchmark's licence allows redistributing it β€” LP-PDBBind's does not β€” so the
challenge publishes only row ids, protein ids and splits. The rows themselves come from
each benchmark's original source through plug's loaders; `row_index` is the row's position
in that loader.

**Do I have to link my method?**
Yes. Every submission needs a reachable `https://` link describing how the predictions were
made β€” a report, preprint or repository. It is shown on the leaderboard.

**Do I have to enter every benchmark?**
{_COMPLETENESS_ANSWER}

**Is the test set blinded?**
No. The splits are public β€” you need them to know what to predict. The labels the Space
scores against live in a private repo that only this Space reads, so a leaderboard number
cannot be self-reported.

**Can I use external data, pretrained models, or structures?**
Yes, all of it. That is the point: the split, not the training data, is what PLUG
controls. Flag proprietary (non-publicly-available) training data at submission time β€” it
is shown on the leaderboard.

**I want to enter with colleagues.**
Submit under one Hugging Face account representing the lab or team, preferably.

**How is the overall ranking computed?**
Mean of the {BENCHMARK_COUNT} primary metrics, each normalised so that random chance is 0
and perfect is 1 β€” the PLUG Score. See **About β†’ Scoring**.

**Why is my Spearman/AUROC blank for a benchmark?**
A rank metric is undefined when a prediction column is constant, or when a group has one
member. Constant columns are rejected at validation for those benchmarks, so a blank cell
means that benchmark had no scorable group.

**What exactly does a submission file look like?**

Your bundle:

{BUNDLE_TREE_MD}

Each file may be `.csv` or `.parquet`. Every file needs the `{ID_COLUMN}` column copied
from that benchmark's manifest, plus its prediction columns. Extra columns (such as the
`row_index` the template writes) are ignored:

{SUBMISSION_SCHEMAS_MD}

*Rules:*
1. One row per {ID_COLUMN} in your track β€” no duplicates, nothing outside it.
   (`cafa5.csv` is the exception: one row per predicted GO term, so proteins you decline
   to annotate are simply absent.)
2. Column names are case-sensitive.
3. Predictions must be finite numbers β€” no `NaN`, no `inf`, no blanks.
4. A constant prediction column is rejected for the ten rank-scored benchmarks β€” Spearman
   and AUROC are undefined without variance. `cafa5` is exempt: Fmax sweeps a confidence
   threshold, so predicting every term at `1.0` is a legitimate submission.
5. `shs27k.csv` needs all seven mode columns: {", ".join(f"`pred_{m}`" for m in SHS27K_MODES)}.
6. `cafa5.csv` needs an `aspect` of {", ".join(f"`{a}`" for a in GO_ASPECTS)} and a `score`
   in `[0, 1]`.

**Where do the scores and submissions live?**
Bundles, scores, labels and the leaderboard are in the private `{PRIVATE_REPO}` dataset;
the ids and splits participants download are in the public `{PUBLIC_REPO}` dataset.

**My submission failed validation.**
The error message names the benchmark and the problem for every file at once. Run
`plug-challenge validate --track <track>` locally on the same zip to iterate quickly.
"""