Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -68,10 +68,10 @@ model_configs = {
|
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
-
def function(model_name: str, num_molecules: int, seed_num: int)
|
| 72 |
'''
|
| 73 |
Returns:
|
| 74 |
-
image, score_df,
|
| 75 |
'''
|
| 76 |
if model_name == "DrugGEN-NoTarget":
|
| 77 |
model_name = "NoTarget"
|
|
@@ -112,6 +112,20 @@ def function(model_name: str, num_molecules: int, seed_num: int) -> tuple[PIL.Im
|
|
| 112 |
"SA Score": [scores["sa"].iloc[0]]
|
| 113 |
})
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
output_file_path = f'experiments/inference/{model_name}/inference_drugs.txt'
|
| 116 |
|
| 117 |
new_path = f'{model_name}_denovo_mols.smi'
|
|
@@ -146,7 +160,7 @@ def function(model_name: str, num_molecules: int, seed_num: int) -> tuple[PIL.Im
|
|
| 146 |
highlightBondLists=None,
|
| 147 |
)
|
| 148 |
|
| 149 |
-
return molecule_image, score_df, new_path
|
| 150 |
|
| 151 |
|
| 152 |
|
|
@@ -154,9 +168,21 @@ with gr.Blocks(theme=gr.themes.Ocean()) as demo:
|
|
| 154 |
with gr.Row():
|
| 155 |
with gr.Column(scale=1):
|
| 156 |
gr.Markdown("# DrugGEN: Target Centric De Novo Design of Drug Candidate Molecules with Graph Generative Deep Adversarial Networks")
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
with gr.Accordion("About DrugGEN Models", open=False):
|
| 162 |
gr.Markdown("""
|
|
@@ -234,29 +260,67 @@ For more details, see our [paper on arXiv](https://arxiv.org/abs/2302.07868).
|
|
| 234 |
)
|
| 235 |
|
| 236 |
with gr.Column(scale=2):
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
|
|
|
|
|
|
| 246 |
|
| 247 |
-
with gr.
|
| 248 |
-
|
| 249 |
-
label="
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
-
submit_button.click(function, inputs=[model_name, num_molecules, seed_num], outputs=[image_output, scores_df, file_download], api_name="inference")
|
| 259 |
-
#demo.queue(concurrency_count=1)
|
| 260 |
demo.queue()
|
| 261 |
demo.launch()
|
| 262 |
|
|
|
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
+
def function(model_name: str, num_molecules: int, seed_num: int):
|
| 72 |
'''
|
| 73 |
Returns:
|
| 74 |
+
image, score_df, file_path, and individual metrics
|
| 75 |
'''
|
| 76 |
if model_name == "DrugGEN-NoTarget":
|
| 77 |
model_name = "NoTarget"
|
|
|
|
| 112 |
"SA Score": [scores["sa"].iloc[0]]
|
| 113 |
})
|
| 114 |
|
| 115 |
+
# Extract individual metrics
|
| 116 |
+
validity = scores["validity"].iloc[0]
|
| 117 |
+
uniqueness = scores["uniqueness"].iloc[0]
|
| 118 |
+
novelty_train = scores["novelty"].iloc[0]
|
| 119 |
+
novelty_test = scores["novelty_test"].iloc[0]
|
| 120 |
+
drug_novelty = scores["drug_novelty"].iloc[0]
|
| 121 |
+
runtime = et
|
| 122 |
+
qed = scores["qed"].iloc[0]
|
| 123 |
+
sa = scores["sa"].iloc[0]
|
| 124 |
+
int_div = scores["IntDiv"].iloc[0]
|
| 125 |
+
snn_chembl = scores["snn_chembl"].iloc[0]
|
| 126 |
+
snn_drug = scores["snn_drug"].iloc[0]
|
| 127 |
+
max_len = scores["max_len"].iloc[0]
|
| 128 |
+
|
| 129 |
output_file_path = f'experiments/inference/{model_name}/inference_drugs.txt'
|
| 130 |
|
| 131 |
new_path = f'{model_name}_denovo_mols.smi'
|
|
|
|
| 160 |
highlightBondLists=None,
|
| 161 |
)
|
| 162 |
|
| 163 |
+
return molecule_image, score_df, new_path, validity, uniqueness, novelty_train, novelty_test, drug_novelty, runtime, qed, sa, int_div, snn_chembl, snn_drug, max_len
|
| 164 |
|
| 165 |
|
| 166 |
|
|
|
|
| 168 |
with gr.Row():
|
| 169 |
with gr.Column(scale=1):
|
| 170 |
gr.Markdown("# DrugGEN: Target Centric De Novo Design of Drug Candidate Molecules with Graph Generative Deep Adversarial Networks")
|
| 171 |
+
|
| 172 |
+
gr.HTML("""
|
| 173 |
+
<div style="display: flex; gap: 10px; margin-bottom: 15px;">
|
| 174 |
+
<a href="https://arxiv.org/abs/2302.07868" target="_blank" style="text-decoration: none;">
|
| 175 |
+
<div style="display: inline-block; background-color: #b31b1b; color: white; padding: 5px 10px; border-radius: 5px; font-size: 14px;">
|
| 176 |
+
<span style="font-weight: bold;">arXiv</span> 2302.07868
|
| 177 |
+
</div>
|
| 178 |
+
</a>
|
| 179 |
+
<a href="https://github.com/HUBioDataLab/DrugGEN" target="_blank" style="text-decoration: none;">
|
| 180 |
+
<div style="display: inline-block; background-color: #24292e; color: white; padding: 5px 10px; border-radius: 5px; font-size: 14px;">
|
| 181 |
+
<span style="font-weight: bold;">GitHub</span> Repository
|
| 182 |
+
</div>
|
| 183 |
+
</a>
|
| 184 |
+
</div>
|
| 185 |
+
""")
|
| 186 |
|
| 187 |
with gr.Accordion("About DrugGEN Models", open=False):
|
| 188 |
gr.Markdown("""
|
|
|
|
| 260 |
)
|
| 261 |
|
| 262 |
with gr.Column(scale=2):
|
| 263 |
+
image_output = gr.Image(
|
| 264 |
+
label="Sample of Generated Molecules",
|
| 265 |
+
elem_id="molecule_display"
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
file_download = gr.File(
|
| 269 |
+
label="Download All Generated Molecules (SMILES format)",
|
| 270 |
+
)
|
| 271 |
+
|
| 272 |
+
with gr.Box():
|
| 273 |
+
gr.Markdown("### Performance Metrics")
|
| 274 |
|
| 275 |
+
with gr.Row():
|
| 276 |
+
with gr.Column():
|
| 277 |
+
validity = gr.Number(label="Validity", precision=3)
|
| 278 |
+
uniqueness = gr.Number(label="Uniqueness", precision=3)
|
| 279 |
+
novelty_train = gr.Number(label="Novelty (Train)", precision=3)
|
| 280 |
+
novelty_test = gr.Number(label="Novelty (Test)", precision=3)
|
| 281 |
+
drug_novelty = gr.Number(label="Drug Novelty", precision=3)
|
| 282 |
+
runtime = gr.Number(label="Runtime (seconds)", precision=2)
|
| 283 |
+
|
| 284 |
+
with gr.Column():
|
| 285 |
+
qed = gr.Number(label="QED Score", precision=3, info="Higher is more drug-like (0-1)")
|
| 286 |
+
sa = gr.Number(label="SA Score", precision=3, info="Lower is easier to synthesize (1-10)")
|
| 287 |
+
int_div = gr.Number(label="Internal Diversity", precision=3)
|
| 288 |
+
snn_chembl = gr.Number(label="SNN ChEMBL", precision=3)
|
| 289 |
+
snn_drug = gr.Number(label="SNN Drug", precision=3)
|
| 290 |
+
max_len = gr.Number(label="Max Length", precision=3)
|
| 291 |
+
|
| 292 |
+
with gr.Accordion("All Metrics (Table View)", open=False):
|
| 293 |
+
scores_df = gr.Dataframe(
|
| 294 |
+
headers=["Runtime (seconds)", "Validity", "Uniqueness", "Novelty (Train)", "Novelty (Test)",
|
| 295 |
+
"Drug Novelty", "Max Length", "Mean Atom Type", "SNN ChEMBL", "SNN Drug",
|
| 296 |
+
"Internal Diversity", "QED", "SA Score"]
|
| 297 |
+
)
|
| 298 |
+
|
| 299 |
+
gr.Markdown("### Created by the HUBioDataLab | [GitHub](https://github.com/HUBioDataLab/DrugGEN) | [Paper](https://arxiv.org/abs/2302.07868)")
|
| 300 |
+
|
| 301 |
+
submit_button.click(
|
| 302 |
+
function,
|
| 303 |
+
inputs=[model_name, num_molecules, seed_num],
|
| 304 |
+
outputs=[
|
| 305 |
+
image_output,
|
| 306 |
+
scores_df,
|
| 307 |
+
file_download,
|
| 308 |
+
validity,
|
| 309 |
+
uniqueness,
|
| 310 |
+
novelty_train,
|
| 311 |
+
novelty_test,
|
| 312 |
+
drug_novelty,
|
| 313 |
+
runtime,
|
| 314 |
+
qed,
|
| 315 |
+
sa,
|
| 316 |
+
int_div,
|
| 317 |
+
snn_chembl,
|
| 318 |
+
snn_drug,
|
| 319 |
+
max_len
|
| 320 |
+
],
|
| 321 |
+
api_name="inference"
|
| 322 |
+
)
|
| 323 |
|
|
|
|
|
|
|
| 324 |
demo.queue()
|
| 325 |
demo.launch()
|
| 326 |
|