Spaces:
Runtime error
Runtime error
Eachan Johnson
commited on
Commit
·
7f2265f
1
Parent(s):
a0c5e52
Tidy code
Browse files- app.py +64 -43
- repos.json +12 -0
app.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
from typing import Iterable, List, Optional, Union
|
| 4 |
from functools import partial
|
| 5 |
from io import TextIOWrapper
|
|
|
|
| 6 |
import os
|
| 7 |
# os.environ["COMMANDLINE_ARGS"] = "--no-gradio-queue"
|
| 8 |
|
|
@@ -22,23 +23,26 @@ from schemist.converting import (
|
|
| 22 |
from schemist.tables import converter
|
| 23 |
import torch
|
| 24 |
|
|
|
|
|
|
|
| 25 |
CACHE = "./cache"
|
| 26 |
MAX_ROWS = 4000
|
|
|
|
| 27 |
HEADER_FILE = os.path.join("sources", "header.md")
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
}
|
| 31 |
|
| 32 |
MODELBOXES = {
|
| 33 |
key: AutoModelBox.from_pretrained(val, cache_dir=CACHE)
|
| 34 |
for key, val in MODEL_REPOS.items()
|
| 35 |
}
|
|
|
|
| 36 |
|
| 37 |
EXTRA_METRICS = {
|
| 38 |
-
"log10(variance)": lambda modelbox, candidates: modelbox.prediction_variance(candidates=candidates, cache=CACHE).map(lambda x: {modelbox._variance_key: torch.log10(x[modelbox._variance_key])}),
|
| 39 |
-
"Tanimoto nearest neighbor to training data": lambda modelbox, candidates: modelbox.tanimoto_nn(candidates=candidates),
|
| 40 |
-
"Doubtscore": lambda modelbox, candidates: modelbox.doubtscore(candidates=candidates, cache=CACHE).map(lambda x: {"doubtscore": torch.log10(x["doubtscore"])}),
|
| 41 |
-
"Information sensitivity (approx.)": lambda modelbox, candidates: modelbox.information_sensitivity(candidates=candidates, optimality_approximation=True, approximator="squared_jacobian", cache=CACHE).map(lambda x: {"information sensitivity": torch.log10(x["information sensitivity"])}),
|
| 42 |
}
|
| 43 |
|
| 44 |
def get_dropdown_options(df, _type = str):
|
|
@@ -48,6 +52,7 @@ def get_dropdown_options(df, _type = str):
|
|
| 48 |
cols = list(df.select_dtypes([np.number]))
|
| 49 |
return gr.Dropdown(choices=cols, interactive=True, value=cols[0], visible=True)
|
| 50 |
|
|
|
|
| 51 |
def load_input_data(file: Union[TextIOWrapper, str]) -> pd.DataFrame:
|
| 52 |
file = file if isinstance(file, str) else file.name
|
| 53 |
print_err(f"Loading {file}")
|
|
@@ -223,9 +228,13 @@ def predict_file(
|
|
| 223 |
df: pd.DataFrame,
|
| 224 |
column: str = 'smiles',
|
| 225 |
input_representation: str = 'smiles',
|
| 226 |
-
predict:
|
|
|
|
| 227 |
extra_metrics: Optional[Union[Iterable[str], str]] = None
|
| 228 |
):
|
|
|
|
|
|
|
|
|
|
| 229 |
if extra_metrics is None:
|
| 230 |
extra_metrics = []
|
| 231 |
else:
|
|
@@ -268,6 +277,8 @@ def draw_one(
|
|
| 268 |
strings: Union[Iterable[str], str],
|
| 269 |
input_representation: str = 'smiles'
|
| 270 |
):
|
|
|
|
|
|
|
| 271 |
_ids = _convert_input(
|
| 272 |
strings,
|
| 273 |
input_representation,
|
|
@@ -298,6 +309,8 @@ def plot_x_vs_y(
|
|
| 298 |
y: str,
|
| 299 |
color: Optional[str] = None,
|
| 300 |
):
|
|
|
|
|
|
|
| 301 |
print_err(df.head())
|
| 302 |
y_title = y
|
| 303 |
cols = ["id", "inchikey", "smiles", "mwt", "clogp", x, y]
|
|
@@ -374,7 +387,7 @@ with gr.Blocks() as demo:
|
|
| 374 |
interactive=True,
|
| 375 |
)
|
| 376 |
extra_metric = gr.CheckboxGroup(
|
| 377 |
-
label="Extra metrics (Information Sensitivity can increase calculation time!)",
|
| 378 |
choices=list(EXTRA_METRICS),
|
| 379 |
value=list(EXTRA_METRICS)[:2],
|
| 380 |
interactive=True,
|
|
@@ -389,7 +402,7 @@ with gr.Blocks() as demo:
|
|
| 389 |
"CC(=O)NC[C@H]1CN(C(=O)O1)C2=CC(=C(C=C2)N3CCOCC3)F",
|
| 390 |
"C1CC2=CC(=NC=C2OC1)CNC3CCN(CC3)C[C@@H]4CN5C(=O)C=CC6=C5N4C(=O)C=N6",
|
| 391 |
]),
|
| 392 |
-
|
| 393 |
list(EXTRA_METRICS)[:2],
|
| 394 |
], # cipro, ceftriaxone, cefiderocol, linezolid, gepotidacin
|
| 395 |
[
|
|
@@ -401,7 +414,7 @@ with gr.Blocks() as demo:
|
|
| 401 |
"C[C@@]1([C@H]2C[C@H]3[C@@H](C(=O)C(=C([C@]3(C(=O)C2=C(C4=C1C=CC=C4O)O)O)O)C(=O)N)N(C)C)O",
|
| 402 |
"CC1=C2C=CC=C(C2=C(C3=C1C[C@H]4[C@@H](C(=O)C(=C([C@]4(C3=O)O)O)C(=O)N)N(C)C)O)O",
|
| 403 |
]),
|
| 404 |
-
|
| 405 |
list(EXTRA_METRICS)[:2],
|
| 406 |
], # doxorubicin, ampicillin, amoxicillin, meropenem, tetracycline, anhydrotetracycline
|
| 407 |
[
|
|
@@ -410,10 +423,10 @@ with gr.Blocks() as demo:
|
|
| 410 |
"C1CN(CCC12C3=CC=CC=C3NC(=O)O2)CCC4=CC=C(C=C4)C(F)(F)F",
|
| 411 |
"COC1=CC(=CC(=C1OC)OC)CC2=CN=C(N=C2N)N",
|
| 412 |
"CC1=CC(=NO1)NS(=O)(=O)C2=CC=C(C=C2)N",
|
| 413 |
-
"C1[C@@H]([C@H]([C@@H]([C@H]([C@@H]1NC(=O)[C@H](CCN)O)O[C@@H]2[C@@H]([C@H]([C@@H]([C@H](O2)CO)O)N)O)O)O[C@@H]3[C@@H]([C@H]([C@@H]([C@H](O3)CN)O)O)O)N
|
| 414 |
-
"C1=CN=CC=C1C(=O)NN
|
| 415 |
]),
|
| 416 |
-
|
| 417 |
list(EXTRA_METRICS)[:2],
|
| 418 |
], # Halicin, Abaucin, Trimethoprim, Sulfamethoxazole, Amikacin, Isoniazid
|
| 419 |
[
|
|
@@ -425,7 +438,7 @@ with gr.Blocks() as demo:
|
|
| 425 |
"CC(C1CCC(C(O1)OC2C(CC(C(C2O)OC3C(C(C(CO3)(C)O)NC)O)N)N)N)NC",
|
| 426 |
"C[C@H]1/C=C/C=C(\C(=O)NC2=C(C(=C3C(=C2O)C(=C(C4=C3C(=O)[C@](O4)(O/C=C/[C@@H]([C@H]([C@H]([C@@H]([C@@H]([C@@H]([C@H]1O)C)O)C)OC(=O)C)C)OC)C)C)O)O)/C=N/N5CCN(CC5)C)/C",
|
| 427 |
]),
|
| 428 |
-
|
| 429 |
list(EXTRA_METRICS)[:2],
|
| 430 |
], # murepavadin, vancomycin, zosurabalpin, plazomicin, Gentamicin, rifampicin
|
| 431 |
[
|
|
@@ -437,7 +450,7 @@ with gr.Blocks() as demo:
|
|
| 437 |
"CCCCCCNC(=O)N1C=C(C(=O)NC1=O)F",
|
| 438 |
"C[C@@H]1OC[C@@H]2[C@@H](O1)[C@@H]([C@H]([C@@H](O2)O[C@H]3[C@H]4COC(=O)[C@@H]4[C@@H](C5=CC6=C(C=C35)OCO6)C7=CC(=C(C(=C7)OC)O)OC)O)O",
|
| 439 |
]),
|
| 440 |
-
|
| 441 |
list(EXTRA_METRICS)[:2],
|
| 442 |
], # Debio1452, Debio-1452-NH3, Fabimycin, 5-FU, Carmofur, Etoposide
|
| 443 |
[
|
|
@@ -449,7 +462,7 @@ with gr.Blocks() as demo:
|
|
| 449 |
"CN(CC1=CN=C2C(=N1)C(=NC(=N2)N)N)C3=CC=C(C=C3)C(=O)N[C@@H](CCC(=O)O)C(=O)O",
|
| 450 |
"CC1=NC2=C(C=C(C=C2)CN(C)C3=CC=C(S3)C(=O)N[C@@H](CCC(=O)O)C(=O)O)C(=O)N1",
|
| 451 |
]),
|
| 452 |
-
|
| 453 |
list(EXTRA_METRICS)[:2],
|
| 454 |
], # Trimethoprim, SCH79797, Pemetrexed, Nolatrexed, Methotrexate, Raltitrexed
|
| 455 |
[
|
|
@@ -461,19 +474,19 @@ with gr.Blocks() as demo:
|
|
| 461 |
"CCC1=C(C(=NC(=N1)N)N)C2=CC=C(C=C2)Cl",
|
| 462 |
"C1=CC(=CC=C1C(=O)N[C@@H](CCC(=O)O)C(=O)O)NCC2=CN=C3C(=N2)C(=NC(=N3)N)N",
|
| 463 |
]),
|
| 464 |
-
|
| 465 |
list(EXTRA_METRICS)[:2],
|
| 466 |
], # CHIR-090, SCH79797, DBeQ, Tenovin-6, Pyrimethamine, Aminopterin
|
| 467 |
|
| 468 |
],
|
| 469 |
example_labels=[
|
| 470 |
-
"Ciprofloxacin, Ceftriaxone, Cefiderocol, Linezolid, Gepotidacin",
|
| 471 |
-
"Doxorubicin, Ampicillin, Amoxicillin, Meropenem, Tetracycline, Anhydrotetracycline",
|
| 472 |
-
"Halicin, Abaucin, Trimethoprim, Sulfamethoxazole, Amikacin, Isoniazid",
|
| 473 |
-
"Murepavadin, Vancomycin, Zosurabalpin, Plazomicin, Gentamicin, Rifampicin",
|
| 474 |
-
"Debio-1452, Debio-1452-NH3, Fabimycin, 5-FU, Carmofur, Etoposide",
|
| 475 |
-
"Trimethoprim, Pemetrexed, Nolatrexed, Methotrexate, Raltitrexed",
|
| 476 |
-
"CHIR-090, SCH79797, DBeQ, Tenovin-6, Pyrimethamine, Aminopterin"
|
| 477 |
],
|
| 478 |
inputs=[input_line, output_species_single, extra_metric],
|
| 479 |
cache_mode="eager",
|
|
@@ -517,7 +530,7 @@ with gr.Blocks() as demo:
|
|
| 517 |
outputs=download_single
|
| 518 |
)
|
| 519 |
|
| 520 |
-
with gr.Tab(f"Predict on structures from a file (max. {MAX_ROWS} rows,
|
| 521 |
input_file = gr.File(
|
| 522 |
label="Upload a table of chemical compounds here",
|
| 523 |
file_types=[".xlsx", ".csv", ".tsv", ".txt"],
|
|
@@ -536,12 +549,20 @@ with gr.Blocks() as demo:
|
|
| 536 |
interactive=True,
|
| 537 |
visible=True,
|
| 538 |
)
|
| 539 |
-
output_species =
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 545 |
extra_metric_file = gr.CheckboxGroup(
|
| 546 |
label="Extra metrics (Information Sensitivity can increase calculation time)",
|
| 547 |
choices=list(EXTRA_METRICS),
|
|
@@ -578,7 +599,7 @@ with gr.Blocks() as demo:
|
|
| 578 |
interactive=True,
|
| 579 |
visible=False,
|
| 580 |
)
|
| 581 |
-
|
| 582 |
any_x_col = gr.Dropdown(
|
| 583 |
label="x-axis for right plot",
|
| 584 |
choices=[],
|
|
@@ -609,25 +630,25 @@ with gr.Blocks() as demo:
|
|
| 609 |
[
|
| 610 |
"example-data/stokes2020-eco.csv",
|
| 611 |
"SMILES",
|
| 612 |
-
"
|
| 613 |
-
"
|
| 614 |
-
"
|
| 615 |
list(EXTRA_METRICS)[:3],
|
| 616 |
],
|
| 617 |
[
|
| 618 |
"example-data/liu23-abau.csv",
|
| 619 |
"SMILES",
|
| 620 |
-
"
|
| 621 |
"Mean",
|
| 622 |
-
"
|
| 623 |
list(EXTRA_METRICS)[:3],
|
| 624 |
],
|
| 625 |
[
|
| 626 |
"example-data/wong24-sau-tox-5000.csv",
|
| 627 |
"SMILES",
|
| 628 |
-
"
|
| 629 |
"Mean",
|
| 630 |
-
"
|
| 631 |
list(EXTRA_METRICS)[:3],
|
| 632 |
],
|
| 633 |
],
|
|
@@ -636,7 +657,7 @@ with gr.Blocks() as demo:
|
|
| 636 |
"A. baumannii training data from Liu, 2023",
|
| 637 |
"S. aureus and toxicity training data from Wong, 2024",
|
| 638 |
],
|
| 639 |
-
inputs=[input_file, input_column, output_species, observed_col, color_col, extra_metric_file],
|
| 640 |
cache_mode="eager",
|
| 641 |
)
|
| 642 |
with gr.Row():
|
|
@@ -671,7 +692,7 @@ with gr.Blocks() as demo:
|
|
| 671 |
input_data,
|
| 672 |
input_column,
|
| 673 |
input_format,
|
| 674 |
-
output_species,
|
| 675 |
extra_metric_file,
|
| 676 |
],
|
| 677 |
outputs={
|
|
@@ -697,7 +718,7 @@ with gr.Blocks() as demo:
|
|
| 697 |
plot_pred_vs_observed,
|
| 698 |
inputs=[
|
| 699 |
input_data,
|
| 700 |
-
output_species,
|
| 701 |
observed_col,
|
| 702 |
color_col,
|
| 703 |
],
|
|
|
|
| 3 |
from typing import Iterable, List, Optional, Union
|
| 4 |
from functools import partial
|
| 5 |
from io import TextIOWrapper
|
| 6 |
+
import json
|
| 7 |
import os
|
| 8 |
# os.environ["COMMANDLINE_ARGS"] = "--no-gradio-queue"
|
| 9 |
|
|
|
|
| 23 |
from schemist.tables import converter
|
| 24 |
import torch
|
| 25 |
|
| 26 |
+
DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 27 |
+
|
| 28 |
CACHE = "./cache"
|
| 29 |
MAX_ROWS = 4000
|
| 30 |
+
BATCH_SIZE=32
|
| 31 |
HEADER_FILE = os.path.join("sources", "header.md")
|
| 32 |
+
with open("repos.json", "r") as f:
|
| 33 |
+
MODEL_REPOS = json.load(f)
|
|
|
|
| 34 |
|
| 35 |
MODELBOXES = {
|
| 36 |
key: AutoModelBox.from_pretrained(val, cache_dir=CACHE)
|
| 37 |
for key, val in MODEL_REPOS.items()
|
| 38 |
}
|
| 39 |
+
[mb.to(DEVICE) for mb in MODELBOXES.values()]
|
| 40 |
|
| 41 |
EXTRA_METRICS = {
|
| 42 |
+
"log10(variance)": lambda modelbox, candidates: modelbox.prediction_variance(candidates=candidates, batch_size=BATCH_SIZE, cache=CACHE).map(lambda x: {modelbox._variance_key: torch.log10(x[modelbox._variance_key])}),
|
| 43 |
+
"Tanimoto nearest neighbor to training data": lambda modelbox, candidates: modelbox.tanimoto_nn(candidates=candidates, batch_size=BATCH_SIZE),
|
| 44 |
+
"Doubtscore": lambda modelbox, candidates: modelbox.doubtscore(candidates=candidates, cache=CACHE, batch_size=BATCH_SIZE).map(lambda x: {"doubtscore": torch.log10(x["doubtscore"])}),
|
| 45 |
+
"Information sensitivity (approx.)": lambda modelbox, candidates: modelbox.information_sensitivity(candidates=candidates, batch_size=BATCH_SIZE, optimality_approximation=True, approximator="squared_jacobian", cache=CACHE).map(lambda x: {"information sensitivity": torch.log10(x["information sensitivity"])}),
|
| 46 |
}
|
| 47 |
|
| 48 |
def get_dropdown_options(df, _type = str):
|
|
|
|
| 52 |
cols = list(df.select_dtypes([np.number]))
|
| 53 |
return gr.Dropdown(choices=cols, interactive=True, value=cols[0], visible=True)
|
| 54 |
|
| 55 |
+
|
| 56 |
def load_input_data(file: Union[TextIOWrapper, str]) -> pd.DataFrame:
|
| 57 |
file = file if isinstance(file, str) else file.name
|
| 58 |
print_err(f"Loading {file}")
|
|
|
|
| 228 |
df: pd.DataFrame,
|
| 229 |
column: str = 'smiles',
|
| 230 |
input_representation: str = 'smiles',
|
| 231 |
+
predict: str = 'smiles',
|
| 232 |
+
predict2: Optional[str] = None,
|
| 233 |
extra_metrics: Optional[Union[Iterable[str], str]] = None
|
| 234 |
):
|
| 235 |
+
predict = cast(predict, to=list)
|
| 236 |
+
if predict2 is not None:
|
| 237 |
+
predict += cast(predict2, to=list)
|
| 238 |
if extra_metrics is None:
|
| 239 |
extra_metrics = []
|
| 240 |
else:
|
|
|
|
| 277 |
strings: Union[Iterable[str], str],
|
| 278 |
input_representation: str = 'smiles'
|
| 279 |
):
|
| 280 |
+
message = f"Drawing {len(cast(strings, to=list))} molecules..."
|
| 281 |
+
gr.Info(message, duration=10)
|
| 282 |
_ids = _convert_input(
|
| 283 |
strings,
|
| 284 |
input_representation,
|
|
|
|
| 309 |
y: str,
|
| 310 |
color: Optional[str] = None,
|
| 311 |
):
|
| 312 |
+
message = f"Plotting x={x}, y={y}, color={color}..."
|
| 313 |
+
gr.Info(message, duration=10)
|
| 314 |
print_err(df.head())
|
| 315 |
y_title = y
|
| 316 |
cols = ["id", "inchikey", "smiles", "mwt", "clogp", x, y]
|
|
|
|
| 387 |
interactive=True,
|
| 388 |
)
|
| 389 |
extra_metric = gr.CheckboxGroup(
|
| 390 |
+
label="Extra metrics (Doubscore & Information Sensitivity can increase calculation time to a couple of minutes!)",
|
| 391 |
choices=list(EXTRA_METRICS),
|
| 392 |
value=list(EXTRA_METRICS)[:2],
|
| 393 |
interactive=True,
|
|
|
|
| 402 |
"CC(=O)NC[C@H]1CN(C(=O)O1)C2=CC(=C(C=C2)N3CCOCC3)F",
|
| 403 |
"C1CC2=CC(=NC=C2OC1)CNC3CCN(CC3)C[C@@H]4CN5C(=O)C=CC6=C5N4C(=O)C=N6",
|
| 404 |
]),
|
| 405 |
+
"Yersinia pestis",
|
| 406 |
list(EXTRA_METRICS)[:2],
|
| 407 |
], # cipro, ceftriaxone, cefiderocol, linezolid, gepotidacin
|
| 408 |
[
|
|
|
|
| 414 |
"C[C@@]1([C@H]2C[C@H]3[C@@H](C(=O)C(=C([C@]3(C(=O)C2=C(C4=C1C=CC=C4O)O)O)O)C(=O)N)N(C)C)O",
|
| 415 |
"CC1=C2C=CC=C(C2=C(C3=C1C[C@H]4[C@@H](C(=O)C(=C([C@]4(C3=O)O)O)C(=O)N)N(C)C)O)O",
|
| 416 |
]),
|
| 417 |
+
"Staphylococcus aureus",
|
| 418 |
list(EXTRA_METRICS)[:2],
|
| 419 |
], # doxorubicin, ampicillin, amoxicillin, meropenem, tetracycline, anhydrotetracycline
|
| 420 |
[
|
|
|
|
| 423 |
"C1CN(CCC12C3=CC=CC=C3NC(=O)O2)CCC4=CC=C(C=C4)C(F)(F)F",
|
| 424 |
"COC1=CC(=CC(=C1OC)OC)CC2=CN=C(N=C2N)N",
|
| 425 |
"CC1=CC(=NO1)NS(=O)(=O)C2=CC=C(C=C2)N",
|
| 426 |
+
"C1[C@@H]([C@H]([C@@H]([C@H]([C@@H]1NC(=O)[C@H](CCN)O)O[C@@H]2[C@@H]([C@H]([C@@H]([C@H](O2)CO)O)N)O)O)O[C@@H]3[C@@H]([C@H]([C@@H]([C@H](O3)CN)O)O)O)N",
|
| 427 |
+
"C1=CN=CC=C1C(=O)NN",
|
| 428 |
]),
|
| 429 |
+
["Escherichia coli", "Acinetobacter baumannii"],
|
| 430 |
list(EXTRA_METRICS)[:2],
|
| 431 |
], # Halicin, Abaucin, Trimethoprim, Sulfamethoxazole, Amikacin, Isoniazid
|
| 432 |
[
|
|
|
|
| 438 |
"CC(C1CCC(C(O1)OC2C(CC(C(C2O)OC3C(C(C(CO3)(C)O)NC)O)N)N)N)NC",
|
| 439 |
"C[C@H]1/C=C/C=C(\C(=O)NC2=C(C(=C3C(=C2O)C(=C(C4=C3C(=O)[C@](O4)(O/C=C/[C@@H]([C@H]([C@H]([C@@H]([C@@H]([C@@H]([C@H]1O)C)O)C)OC(=O)C)C)OC)C)C)O)O)/C=N/N5CCN(CC5)C)/C",
|
| 440 |
]),
|
| 441 |
+
"Acinetobacter baumannii",
|
| 442 |
list(EXTRA_METRICS)[:2],
|
| 443 |
], # murepavadin, vancomycin, zosurabalpin, plazomicin, Gentamicin, rifampicin
|
| 444 |
[
|
|
|
|
| 450 |
"CCCCCCNC(=O)N1C=C(C(=O)NC1=O)F",
|
| 451 |
"C[C@@H]1OC[C@@H]2[C@@H](O1)[C@@H]([C@H]([C@@H](O2)O[C@H]3[C@H]4COC(=O)[C@@H]4[C@@H](C5=CC6=C(C=C35)OCO6)C7=CC(=C(C(=C7)OC)O)OC)O)O",
|
| 452 |
]),
|
| 453 |
+
"Escherichia coli",
|
| 454 |
list(EXTRA_METRICS)[:2],
|
| 455 |
], # Debio1452, Debio-1452-NH3, Fabimycin, 5-FU, Carmofur, Etoposide
|
| 456 |
[
|
|
|
|
| 462 |
"CN(CC1=CN=C2C(=N1)C(=NC(=N2)N)N)C3=CC=C(C=C3)C(=O)N[C@@H](CCC(=O)O)C(=O)O",
|
| 463 |
"CC1=NC2=C(C=C(C=C2)CN(C)C3=CC=C(S3)C(=O)N[C@@H](CCC(=O)O)C(=O)O)C(=O)N1",
|
| 464 |
]),
|
| 465 |
+
"Klebsiella pneumoniae",
|
| 466 |
list(EXTRA_METRICS)[:2],
|
| 467 |
], # Trimethoprim, SCH79797, Pemetrexed, Nolatrexed, Methotrexate, Raltitrexed
|
| 468 |
[
|
|
|
|
| 474 |
"CCC1=C(C(=NC(=N1)N)N)C2=CC=C(C=C2)Cl",
|
| 475 |
"C1=CC(=CC=C1C(=O)N[C@@H](CCC(=O)O)C(=O)O)NCC2=CN=C3C(=N2)C(=NC(=N3)N)N",
|
| 476 |
]),
|
| 477 |
+
"Klebsiella pneumoniae",
|
| 478 |
list(EXTRA_METRICS)[:2],
|
| 479 |
], # CHIR-090, SCH79797, DBeQ, Tenovin-6, Pyrimethamine, Aminopterin
|
| 480 |
|
| 481 |
],
|
| 482 |
example_labels=[
|
| 483 |
+
"_Y. pestis_ (plague) vs Ciprofloxacin, Ceftriaxone, Cefiderocol, Linezolid, Gepotidacin",
|
| 484 |
+
"_S. aureus_ vs Doxorubicin, Ampicillin, Amoxicillin, Meropenem, Tetracycline, Anhydrotetracycline",
|
| 485 |
+
"_E. coli_ and _A. baumannii_ vs Halicin, Abaucin, Trimethoprim, Sulfamethoxazole, Amikacin, Isoniazid",
|
| 486 |
+
"_A. baumannii_ vs Murepavadin, Vancomycin, Zosurabalpin, Plazomicin, Gentamicin, Rifampicin",
|
| 487 |
+
"_E. coli_ vs Debio-1452, Debio-1452-NH3, Fabimycin, 5-FU, Carmofur, Etoposide",
|
| 488 |
+
"_K. pneumoniae_ vs Trimethoprim, Pemetrexed, Nolatrexed, Methotrexate, Raltitrexed",
|
| 489 |
+
"_K. pneumoniae_ vs CHIR-090, SCH79797, DBeQ, Tenovin-6, Pyrimethamine, Aminopterin"
|
| 490 |
],
|
| 491 |
inputs=[input_line, output_species_single, extra_metric],
|
| 492 |
cache_mode="eager",
|
|
|
|
| 530 |
outputs=download_single
|
| 531 |
)
|
| 532 |
|
| 533 |
+
with gr.Tab(f"Predict on structures from a file (max. {MAX_ROWS} rows, ≤ 2 species)"):
|
| 534 |
input_file = gr.File(
|
| 535 |
label="Upload a table of chemical compounds here",
|
| 536 |
file_types=[".xlsx", ".csv", ".tsv", ".txt"],
|
|
|
|
| 549 |
interactive=True,
|
| 550 |
visible=True,
|
| 551 |
)
|
| 552 |
+
output_species = [
|
| 553 |
+
gr.Dropdown(
|
| 554 |
+
label="Species 1 for prediction",
|
| 555 |
+
choices=list(MODEL_REPOS),
|
| 556 |
+
value=list(MODEL_REPOS)[0],
|
| 557 |
+
interactive=True,
|
| 558 |
+
),
|
| 559 |
+
gr.Dropdown(
|
| 560 |
+
label="Species 2 for prediction",
|
| 561 |
+
choices=list(MODEL_REPOS),
|
| 562 |
+
value=None,
|
| 563 |
+
interactive=True,
|
| 564 |
+
),
|
| 565 |
+
]
|
| 566 |
extra_metric_file = gr.CheckboxGroup(
|
| 567 |
label="Extra metrics (Information Sensitivity can increase calculation time)",
|
| 568 |
choices=list(EXTRA_METRICS),
|
|
|
|
| 599 |
interactive=True,
|
| 600 |
visible=False,
|
| 601 |
)
|
| 602 |
+
with gr.Row():
|
| 603 |
any_x_col = gr.Dropdown(
|
| 604 |
label="x-axis for right plot",
|
| 605 |
choices=[],
|
|
|
|
| 630 |
[
|
| 631 |
"example-data/stokes2020-eco.csv",
|
| 632 |
"SMILES",
|
| 633 |
+
"Escherichia coli",
|
| 634 |
+
"Mean_Growth",
|
| 635 |
+
"Escherichia coli: Doubtscore",
|
| 636 |
list(EXTRA_METRICS)[:3],
|
| 637 |
],
|
| 638 |
[
|
| 639 |
"example-data/liu23-abau.csv",
|
| 640 |
"SMILES",
|
| 641 |
+
"Acinetobacter baumannii",
|
| 642 |
"Mean",
|
| 643 |
+
"Acinetobacter baumannii: Doubtscore",
|
| 644 |
list(EXTRA_METRICS)[:3],
|
| 645 |
],
|
| 646 |
[
|
| 647 |
"example-data/wong24-sau-tox-5000.csv",
|
| 648 |
"SMILES",
|
| 649 |
+
"Staphylococcus aureus",
|
| 650 |
"Mean",
|
| 651 |
+
"Staphylococcus aureus: Doubtscore",
|
| 652 |
list(EXTRA_METRICS)[:3],
|
| 653 |
],
|
| 654 |
],
|
|
|
|
| 657 |
"A. baumannii training data from Liu, 2023",
|
| 658 |
"S. aureus and toxicity training data from Wong, 2024",
|
| 659 |
],
|
| 660 |
+
inputs=[input_file, input_column, output_species[0], observed_col, color_col, extra_metric_file],
|
| 661 |
cache_mode="eager",
|
| 662 |
)
|
| 663 |
with gr.Row():
|
|
|
|
| 692 |
input_data,
|
| 693 |
input_column,
|
| 694 |
input_format,
|
| 695 |
+
*output_species,
|
| 696 |
extra_metric_file,
|
| 697 |
],
|
| 698 |
outputs={
|
|
|
|
| 718 |
plot_pred_vs_observed,
|
| 719 |
inputs=[
|
| 720 |
input_data,
|
| 721 |
+
output_species[0],
|
| 722 |
observed_col,
|
| 723 |
color_col,
|
| 724 |
],
|
repos.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"Acinetobacter baumannii": "hf://scbirlab/spark-dv-2503-abau",
|
| 3 |
+
"Brucella abortus": "hf://scbirlab/spark-dv-2503-babo",
|
| 4 |
+
"Escherichia coli": "hf://scbirlab/spark-dv-2503-ecol",
|
| 5 |
+
"Francisella tularensis": "hf://scbirlab/spark-dv-2503-ftul",
|
| 6 |
+
"Klebsiella pneumoniae": "hf://scbirlab/spark-dv-2503-kpne",
|
| 7 |
+
"Pseudomonas aeruginosa": "hf://scbirlab/spark-dv-2503-paer",
|
| 8 |
+
"Staphylococcus aureus": "hf://scbirlab/spark-dv-2503-saur",
|
| 9 |
+
"Streptococcus pneumoniae": "hf://scbirlab/spark-dv-2503-spne",
|
| 10 |
+
"Yersinia enterocolitica": "hf://scbirlab/spark-dv-2503-yent",
|
| 11 |
+
"Yersinia pestis": "hf://scbirlab/spark-dv-2503-ypes"
|
| 12 |
+
}
|