File size: 14,590 Bytes
6024b7c
fa07da2
 
6024b7c
 
b77cb84
0c194f3
6024b7c
 
0c194f3
b77cb84
fa07da2
0c194f3
6fc2c2d
0c194f3
fa07da2
 
0c194f3
fa07da2
 
 
 
 
 
 
0c194f3
 
fa07da2
0c194f3
fa07da2
 
 
0c194f3
 
6024b7c
 
 
0c194f3
 
 
 
 
 
 
 
 
 
 
 
 
9638dbd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6024b7c
 
 
b77cb84
6024b7c
 
9638dbd
 
 
 
 
 
 
 
 
 
 
 
 
 
6024b7c
9638dbd
 
 
6024b7c
9638dbd
b77cb84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6024b7c
 
 
 
 
 
 
 
 
baeca97
 
 
 
 
 
 
 
6024b7c
6fc2c2d
6024b7c
9638dbd
6024b7c
 
9638dbd
b77cb84
6fc2c2d
0c194f3
baeca97
 
 
0c194f3
fa07da2
 
baeca97
fa07da2
0c194f3
baeca97
 
6fc2c2d
b77cb84
6fc2c2d
0c194f3
fa07da2
 
b77cb84
fa07da2
0c194f3
b77cb84
fa07da2
0c194f3
 
 
 
 
 
6024b7c
9638dbd
b77cb84
 
baeca97
b77cb84
 
 
 
 
 
 
 
 
 
 
 
 
6fc2c2d
 
b77cb84
 
6fc2c2d
 
 
 
b77cb84
 
fa07da2
b77cb84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6fc2c2d
 
 
 
b77cb84
 
 
 
 
 
6fc2c2d
 
 
b77cb84
 
 
 
baeca97
b77cb84
 
 
 
 
 
 
 
 
 
 
 
 
 
6fc2c2d
960994d
b77cb84
 
 
 
 
 
 
 
fa07da2
6024b7c
 
 
 
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
import gradio as gr
from gradio_leaderboard import Leaderboard
from gradio.themes.utils import sizes
import pandas as pd

from evaluate import submit_data, evaluate_data
from utils import make_tag_clickable, make_user_clickable, fetch_dataset_df

from datetime import datetime
from about import ENDPOINTS, LB_COLS, LB_DTYPES


ALL_EPS = ['Average'] + ENDPOINTS

def build_leaderboard(df_results):
    per_ep = {}
    for ep in ALL_EPS:
        df = df_results[df_results["endpoint"] == ep].copy()
        if df is None:
            print(f"[refresh] {ep} returned None; using empty DF")
        if df.empty:
            per_ep[ep] = pd.DataFrame(columns=LB_COLS) # Empty df
            continue

        # Make user and model details clickable
        df['user'] = df['user'].apply(lambda x: make_user_clickable(x)).astype(str)
        df['model details'] = df['model_report'].apply(lambda x: make_tag_clickable(x)).astype(str)

        per_ep[ep] = df[LB_COLS]

    return per_ep
    
# Initialize global dataframe
current_df = fetch_dataset_df()

def gradio_interface():

    with gr.Blocks(title="OpenADMET ADMET Challenge", theme=gr.themes.Default(text_size=sizes.text_lg)) as demo:
        timer = gr.Timer(15)  # Run every 15 seconds when page is focused
        data_version = gr.State(0)  # Track data changes  
        def update_current_dataframe(v):
            global current_df
            new_df = fetch_dataset_df()
            if not current_df.equals(new_df):
                current_df = new_df
                return v + 1
            return v
        timer.tick(fn=update_current_dataframe, inputs=[data_version], outputs=data_version)
        
        ### Header
        with gr.Row():
            with gr.Column(scale=8):  # bigger text area
                gr.Markdown("""
                    ## Welcome to the OpenADMET + XXX Blind Challenge!
                    Your task is to develop and submit predictive models for key ADMET properties on a blinded test set of real world drug discovery data πŸ§‘β€πŸ”¬
                            
                    Go to the **Leaderboard** to check out how the challenge is going. 
                    To participate, head out to the **Submit** tab and upload your results as a `CSV` file.
                    """
                    )
            with gr.Column(scale=1):  # smaller side column for logo
                gr.Image(
                    value="./_static/challenge_logo.png",
                    show_label=False,
                    show_download_button=False,
                    width="10vw",  # Take up the width of the column (2/8 = 1/4)
                )

        # --- Welcome markdown message ---
        welcome_md = """
        # πŸ’Š OpenADMET + XXX  
        ## Computational Blind Challenge in ADMET

        This challenge is a community-driven initiative to benchmark predictive models for ADMET properties in drug discovery,
        hosted by **OpenADMET** in collaboration with **XXX**. 


        ## Why are ADMET properties important in drug discovery?
        Small molecules continue to be the bricks and mortar of drug discovery globally, accounting for ~75% of FDA approvals over the last decade. 
        Oral bioavailability, easily tunable properties, modulation of a wide range of mechanisms, 
        and ease of manufacturing make small molecules highly attractive as therapeutic agents, a trend that is not expected to drastically change, 
        despite increased interest in biologics.  Indeed, newer small molecule modalities such as degraders, molecular glues, and antibody-drug conjugates 
        (to name a few) make understanding small molecule properties more important than ever.

        It is fairly difficult to predict the lifetime and distribution of small molecules within the body. Additionally, 
        interaction with off-targets can cause safety issues and toxicity. Collectively these *Absorption*, *Distribution*, *Metabolism*, *Excretion*, *Toxicology*--or **ADMET**--properties 
        sit in the middle of the assay cascade and can make or break preclinical candidate molecules. 

        **OpenADMET** aims to address these challenges through an open science effort to build predictive models of ADMET properties by characterizing the proteins and mechanisms 
        that give rise to these properties through integrated structural biology, high throughput experimentation and integrative computational models. 
        Read more about our strategy to transform drug discovery on our [website](https://openadmet.org/community/blogs/whatisopenadmet/). 

        For this blind challenge we selected ten (10) crucial endpoints for the community to predict:
        - LogD
        - Kinetic Solubility **KSOL**: uM
        - Mouse Liver Microsomal (**MLM**) *CLint*: mL/min/kg
        - Human Liver Microsomal (**HLM**) *Clint*: mL/min/kg
        - Caco-2 Efflux Ratio
        - Caco-2 Papp A>B (10^-6 cm/s)
        - Mouse Plasma Protein Binding (**MPPB**): % Unbound
        - Mouse Brain Protein Binding (**MBPB**): % Unbound
        - Rat Liver Microsomal (**RLM**) *Clint*: mL/min/kg
        - Mouse Gastrocnemius Muscle Binding (**MGMB**): % Unbound

        ## βœ… How to Participate
        1. **Register**: Create an account with Hugging Face.
        2. **Download the Public Dataset**: Clone the XXX dataset [link]
        3. **Train Your Model**: Use the provided training data for each ADMET property of your choice.
        4. **Submit Predictions**: Follow the instructions in the *Submit* tab to upload your predictions.
        5. Join the discussion on the [Challenge Discord](link)!

        ## πŸ“Š Data:

        The training set will have the following variables:
        
        | Column                       |    Unit   | data type |  Description |
        |:-----------------------------|-----------|-----------|:-------------|
        | Molecule Name                |           |    str    | Identifier for the molecule |
        | Smiles                       |           |    str    | Text representation of the 2D molecular structure |
        | LogD                         |           |   float   | LogD calculation |
        | KSol                         |    uM     |   float   | Kinetic Solubility |
        | MLM CLint                    | mL/min/kg |   float   | Mouse Liver Microsomal |
        | HLM CLint                    | mL/min/kg |   float   | Human Liver Microsomal |
        | Caco-2 Permeability Efflux   |           |   float   | Caco-2 Permeability Efflux |
        | Caco-2 Permeability Papp A>B | 10^-6 cm/s|   float   | Caco-2 Permeability Papp A>B |
        | MPPB                         | % Unbound |   float   | Mouse Plasma Protein Binding |
        | MBPB                         | % Unbound |   float   | Mouse Brain Protein Binding |
        | RLM CLint                    | mL/min/kg |   float   | Rat Liver Microsomal Stability |
        | MGMB.                        | % Unbound |   float   | Mouse Gastrocnemius Muscle Binding |

        At test time, we will only provide the Molecule Name and Smiles. Make sure your submission file has the same columns!

        ## πŸ“ Evaluation
        The challenge will be judged based on the judging criteria outlined here.

        - TBD

        πŸ“… **Timeline**:  
        - TBD

        ---

        """

        # --- Gradio Interface ---
        gr.HTML("""
                <style>
                /* bold only the "Overall" tab label */
                    #lb_subtabs [role="tab"][aria-controls="all_tab"] {
                        font-weight: 700 !important;
                    }
                </style>
                """)
        with gr.Tabs(elem_classes="tab-buttons"):
            lboard_dict = {}

            with gr.TabItem("πŸ“– About"):
                gr.Markdown(welcome_md)

            with gr.TabItem("πŸš€ Leaderboard", elem_id="lb_subtabs"):
                gr.Markdown("View the leaderboard for each ADMET endpoint by selecting the appropiate tab.")
                # Make separate leaderboards in separate tabs  
                #per_ep = build_leaderboard()
                # Aggregated leaderboard
                with gr.TabItem('OVERALL', elem_id="all_tab"):
                    lboard_dict['Average'] = Leaderboard(
                        value=build_leaderboard(current_df)['Average'],
                        datatype=LB_DTYPES,
                        select_columns=LB_COLS,
                        search_columns=["user"],
                        render=True,
                        every=15,
                    )
                # per-endpoint leaderboard
                for endpoint in ENDPOINTS:
                    with gr.TabItem(endpoint):
                        lboard_dict[endpoint] = Leaderboard(
                            value=build_leaderboard(current_df)[endpoint],
                            datatype=LB_DTYPES,
                            select_columns=LB_COLS,
                            search_columns=["user"],
                            render=True,
                            every=15,
                        )
                # Auto-refresh 
                def refresh_if_changed():
                    per_ep = build_leaderboard(current_df)
                    #return [gr.update(value=per_ep.get(ep, pd.DataFrame(columns=LB_COLS))) for ep in ALL_EPS]
                    return [per_ep[ep] for ep in ALL_EPS]

                data_version.change(fn=refresh_if_changed, outputs=[lboard_dict[ep] for ep in ALL_EPS])

            with gr.TabItem("βœ‰οΈ Submit"):
                gr.Markdown(
                """
                # ADMET Endpoints Submission
                Upload your prediction files here as a csv file.
                """
                )
                filename = gr.State(value=None) 
                eval_state = gr.State(value=None) 
                user_state = gr.State(value=None)
    
                with gr.Row():
                    
                    with gr.Column():
                        gr.Markdown(
                            """
                            ## Participant Information
                            To participate, we **only** require a Hugging Face username, which will be displayed on the leaderboard. 
                            Other information is optional but helps us track participation.
                            If you wish to be included in Challenge discussions, please provide your Discord username and email. 
                            If you wish to be included in a future publication with the Challenge results, please provide your name and affiliation.

                            We also ask you to provide a link to a report decribing your method. While not mandatory at the time of participation, 
                            you need to submit the link before the challenge deadline in order to be considered for the final leaderboard.
         
                            """
                            )
                        
                        username_input = gr.Textbox(
                            label="Username", 
                            placeholder="Enter your Hugging Face username",
                            info="This will be displayed on the leaderboard."
                        )
                    with gr.Column():
                        # Info to track participant, that will not be displayed publicly
                        participant_name = gr.Textbox(
                            label="Participant Name",
                            placeholder="Enter your name (optional)",
                            info="This will not be displayed on the leaderboard but will be used for tracking participation."
                        )
                        discord_username= gr.Textbox(
                            label="Discord Username",
                            placeholder="Enter your Discord username (optional)",
                            info="Enter the username you will use for the Discord channel (if you are planning to engage in the discussion)."
                        )
                        email = gr.Textbox(
                            label="Email",
                            placeholder="Enter your email (optional)",
                        )
                        affiliation = gr.Textbox(
                            label="Affiliation",
                            placeholder="Enter your school/company affiliation (optional)",
                        )
                        model_tag = gr.Textbox(
                            label="Model Report",
                            placeholder="Link to a report describing your method (optional)",
                        )

                with gr.Row():
                    with gr.Column():
                        gr.Markdown(
                            """
                            ## Submission Instructions
                            Upload a single CSV file containing your predictions for all ligands in the test set.
                            Only your latest submission will be considered.

                            You can download the ligand test set here (lik/to/download/smiles/csv).
                            """
                        )
                    with gr.Column():
                        predictions_file = gr.File(label="Single file with ADMET predictions (.csv)",
                                                file_types=[".csv"],
                                                file_count="single",)

                username_input.change(
                    fn=lambda x: x if x.strip() else None,
                    inputs=username_input,
                    outputs=user_state
                )  

                submit_btn = gr.Button("Submit Predictions")
                message = gr.Textbox(label="Status", lines=1, visible=False)

                submit_btn.click(
                    submit_data,
                    inputs=[predictions_file, user_state, participant_name, discord_username, email, affiliation, model_tag],
                    outputs=[message, filename],
                ).success(
                    fn=lambda m: gr.update(value=m, visible=True),
                    inputs=[message],
                    outputs=[message],
                ).success(
                    fn=evaluate_data,
                    inputs=[filename],
                    outputs=[eval_state]
                )              
    return demo

if __name__ == "__main__":
    gradio_interface().launch()