Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -54,7 +54,7 @@ import sascorer
|
|
54 |
|
55 |
UNIPROT_ENDPOINT = 'https://rest.uniprot.org/uniprotkb/{query}'
|
56 |
DATASET_MAX_LEN = 10_000
|
57 |
-
SERVER_DATA_DIR = '
|
58 |
|
59 |
CSS = """
|
60 |
.help-tip {
|
@@ -608,9 +608,8 @@ using the job id. You will also receive an email notification once the job is do
|
|
608 |
yield {
|
609 |
pred_lookup_status: f'Your {job_type} job (ID: {job_id}) has been **COMPLETED**' +
|
610 |
f' at {end_time}' if job.get('end_time') else '' +
|
611 |
-
|
612 |
-
|
613 |
-
f'Redirecting to the report page...',
|
614 |
pred_lookup_btn: gr.Button(visible=True),
|
615 |
pred_lookup_stop_btn: gr.Button(visible=False),
|
616 |
tabs: gr.Tabs(selected='Chemical Property Report'),
|
@@ -621,8 +620,7 @@ using the job id. You will also receive an email notification once the job is do
|
|
621 |
yield {
|
622 |
pred_lookup_status: f'Your {job_type} job (ID: {job_id}) has **FAILED**' +
|
623 |
f' at {end_time}' if job.get('end_time') else '' +
|
624 |
-
|
625 |
-
'expiry_time') else '.',
|
626 |
pred_lookup_btn: gr.Button(visible=True),
|
627 |
pred_lookup_stop_btn: gr.Button(visible=False),
|
628 |
tabs: gr.Tabs(selected='Prediction Status Lookup'),
|
@@ -655,41 +653,42 @@ def submit_predict(predict_filepath, task, preset, target_family, state):
|
|
655 |
preset = PRESET_MAP[preset]
|
656 |
|
657 |
prediction_df = pd.DataFrame()
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
prediction_df = pd.merge(prediction_df, orig_df, left_index=True, right_index=True, how='left')
|
682 |
|
683 |
-
|
684 |
-
|
|
|
|
|
685 |
|
686 |
-
return {run_state: False}
|
687 |
except Exception as e:
|
688 |
gr.Warning(f"Prediction job failed due to error: {str(e)}")
|
689 |
status = "FAILED"
|
690 |
predictions_file = None
|
691 |
error = str(e)
|
692 |
return {run_state: False}
|
|
|
693 |
finally:
|
694 |
Job = Query()
|
695 |
job_query = (Job.id == job_id)
|
@@ -1219,229 +1218,227 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
1219 |
with gr.Tabs() as tabs:
|
1220 |
with gr.TabItem(label='Drug Hit Screening', id='Drug Hit Screening'):
|
1221 |
gr.Markdown('''
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
with gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1229 |
with gr.Row():
|
1230 |
with gr.Column():
|
1231 |
HelpTip(
|
1232 |
-
"Enter (paste) a
|
1233 |
-
"If multiple entities are in the
|
1234 |
-
"
|
1235 |
-
"
|
1236 |
-
)
|
1237 |
-
target_input_type = gr.Dropdown(
|
1238 |
-
label='Step 1. Select Target Input Type and Input',
|
1239 |
-
choices=['Sequence', 'UniProt ID', 'Gene symbol'],
|
1240 |
-
info='Enter (paste) a FASTA string below manually or upload a FASTA file.',
|
1241 |
-
value='Sequence',
|
1242 |
-
scale=4, interactive=True
|
1243 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1244 |
|
1245 |
with gr.Row():
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
placeholder='Homo sapiens', show_label=False,
|
1256 |
-
visible=False, interactive=True, scale=4, )
|
1257 |
-
target_upload_btn = gr.UploadButton(label='Upload a FASTA File', type='binary',
|
1258 |
-
visible=True, variant='primary',
|
1259 |
-
size='lg')
|
1260 |
-
target_paste_markdown = gr.Button(value='OR Paste Your Sequence Below',
|
1261 |
-
variant='secondary')
|
1262 |
-
target_query_btn = gr.Button(value='Query the Sequence', variant='primary',
|
1263 |
-
visible=False, scale=4)
|
1264 |
-
# with gr.Row():
|
1265 |
-
# example_uniprot = gr.Button(value='Example: Q16539', elem_classes='example', visible=False)
|
1266 |
-
# example_gene = gr.Button(value='Example: MAPK14', elem_classes='example', visible=False)
|
1267 |
-
example_fasta = gr.Button(value='Example: MAPK14 (Q16539)', elem_classes='example')
|
1268 |
-
target_fasta = gr.Code(label='Input or Display FASTA', interactive=True, lines=5)
|
1269 |
-
# with gr.Row():
|
1270 |
-
# with gr.Column():
|
1271 |
-
# with gr.Column():
|
1272 |
-
# gr.File(label='Example FASTA file',
|
1273 |
-
# value='data/examples/MAPK14.fasta', interactive=False)
|
1274 |
|
1275 |
with gr.Row():
|
1276 |
-
with gr.Column(
|
1277 |
HelpTip(
|
1278 |
-
"
|
1279 |
-
"
|
1280 |
-
"
|
1281 |
-
"
|
|
|
1282 |
)
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
label='
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1290 |
HelpTip(
|
1291 |
"Interaction prediction provides you binding probability score between the target of "
|
1292 |
"interest and each compound in the library, "
|
1293 |
"while affinity prediction directly estimates their binding strength measured using "
|
1294 |
"IC50."
|
1295 |
)
|
1296 |
-
|
1297 |
list(TASK_MAP.keys()),
|
1298 |
-
label='Step
|
1299 |
value='Compound-Protein Interaction')
|
1300 |
-
with gr.Column(min_width=200):
|
1301 |
-
HelpTip(
|
1302 |
-
"Select your preferred model, or click Recommend for the best-performing model based "
|
1303 |
-
"on the selected task, family, and whether the target was trained. "
|
1304 |
-
"Please refer to documentation for detailed benchmark results."
|
1305 |
-
)
|
1306 |
-
drug_screen_preset = gr.Dropdown(
|
1307 |
-
list(PRESET_MAP.keys()),
|
1308 |
-
label='Step 4. Select a Preset Model')
|
1309 |
-
screen_preset_recommend_btn = gr.Button(
|
1310 |
-
value='OR Let Us Recommend for You', variant='primary')
|
1311 |
|
1312 |
with gr.Row():
|
1313 |
with gr.Column():
|
1314 |
HelpTip(
|
1315 |
-
"Select
|
1316 |
-
"
|
1317 |
-
"
|
1318 |
-
"provided below and can be downloaded by clicking the lower right corner."
|
1319 |
)
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
value='data/examples/compound_library.sdf', interactive=False)
|
1326 |
-
gr.File(label='Example CSV compound library',
|
1327 |
-
value='data/examples/compound_library.csv', interactive=False)
|
1328 |
-
drug_library_upload_btn = gr.UploadButton(
|
1329 |
-
label='OR Upload Your Own Library', variant='primary')
|
1330 |
-
drug_library_upload = gr.File(label='Custom compound library file', visible=False)
|
1331 |
with gr.Row():
|
1332 |
with gr.Column():
|
1333 |
-
|
1334 |
label='Step 6. Input Your Email Address (Optional)',
|
1335 |
info="Your email address will be used to notify you of the status of your job. "
|
1336 |
"If you cannot receive the email, please check your spam/junk folder."
|
1337 |
)
|
1338 |
|
1339 |
with gr.Row(visible=True):
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
# TODO Modify the pd df directly with df['X2'] = target
|
1344 |
-
|
1345 |
-
screen_data_for_predict = gr.File(visible=False, file_count="single", type='filepath')
|
1346 |
-
|
1347 |
-
with gr.TabItem(label='Target Protein Identification', id='Target Protein Identification'):
|
1348 |
-
gr.Markdown('''
|
1349 |
-
# <center>Target Protein Identification</center>
|
1350 |
-
|
1351 |
-
<center>
|
1352 |
-
To predict interactions or binding affinities of a single compound against a protein library.
|
1353 |
-
</center>
|
1354 |
-
''')
|
1355 |
-
with gr.Blocks() as identify_block:
|
1356 |
-
with gr.Column() as identify_page:
|
1357 |
-
with gr.Row():
|
1358 |
-
with gr.Column():
|
1359 |
-
HelpTip(
|
1360 |
-
"Enter (paste) a compound SMILES below manually or upload a SDF file. "
|
1361 |
-
"If multiple entities are in the SDF, only the first will be used. "
|
1362 |
-
"SMILES can be obtained by searching for the compound of interest in databases such "
|
1363 |
-
"as NCBI, PubChem and and ChEMBL."
|
1364 |
-
)
|
1365 |
-
compound_type = gr.Dropdown(
|
1366 |
-
label='Step 1. Select Compound Input Type and Input',
|
1367 |
-
choices=['SMILES', 'SDF'],
|
1368 |
-
info='Enter (paste) an SMILES string or upload an SDF file to convert to SMILES.',
|
1369 |
-
value='SMILES',
|
1370 |
-
interactive=True)
|
1371 |
-
compound_upload_btn = gr.UploadButton(label='OR Upload a SDF File', variant='primary',
|
1372 |
-
type='binary', visible=False)
|
1373 |
-
|
1374 |
-
compound_smiles = gr.Code(label='Input or Display Compound SMILES', interactive=True, lines=5)
|
1375 |
-
example_drug = gr.Button(value='Example: Aspirin', elem_classes='example')
|
1376 |
-
|
1377 |
-
with gr.Row():
|
1378 |
-
with gr.Column(visible=False):
|
1379 |
-
HelpTip(
|
1380 |
-
"By default, models trained on all protein families (general) will be applied. "
|
1381 |
-
# "If the proteins in the target library of interest all belong to the same protein "
|
1382 |
-
# "family, manually selecting the family is supported."
|
1383 |
-
)
|
1384 |
-
target_identify_target_family = gr.Dropdown(
|
1385 |
-
choices=['General'], value='General',
|
1386 |
-
label='Step 2. Select Target Family (Optional)')
|
1387 |
-
|
1388 |
-
with gr.Row():
|
1389 |
-
with gr.Column():
|
1390 |
-
HelpTip(
|
1391 |
-
"Select a preset target library (e.g., ChEMBL33_human_proteins). "
|
1392 |
-
"Alternatively, upload a CSV file with a column named X2 containing target protein "
|
1393 |
-
"sequences, or use an FASTA file (Max. 10,000 targets per task). "
|
1394 |
-
"Example CSV and SDF files are provided below "
|
1395 |
-
"and can be downloaded by clicking the lower right corner."
|
1396 |
-
)
|
1397 |
-
target_library = gr.Dropdown(label='Step 3. Select a Preset Target Library',
|
1398 |
-
choices=list(TARGET_LIBRARY_MAP.keys()))
|
1399 |
-
with gr.Row():
|
1400 |
-
gr.File(label='Example FASTA target library',
|
1401 |
-
value='data/examples/target_library.fasta', interactive=False)
|
1402 |
-
gr.File(label='Example CSV target library',
|
1403 |
-
value='data/examples/target_library.csv', interactive=False)
|
1404 |
-
target_library_upload_btn = gr.UploadButton(
|
1405 |
-
label='OR Upload Your Own Library', variant='primary')
|
1406 |
-
target_library_upload = gr.File(label='Custom target library file', visible=False)
|
1407 |
-
|
1408 |
-
with gr.Row():
|
1409 |
-
with gr.Column():
|
1410 |
-
HelpTip(
|
1411 |
-
"Interaction prediction provides you binding probability score between the target of "
|
1412 |
-
"interest and each compound in the library, "
|
1413 |
-
"while affinity prediction directly estimates their binding strength measured using "
|
1414 |
-
"IC50."
|
1415 |
-
)
|
1416 |
-
target_identify_task = gr.Dropdown(
|
1417 |
-
list(TASK_MAP.keys()),
|
1418 |
-
label='Step 4. Select the Prediction Task You Want to Conduct',
|
1419 |
-
value='Compound-Protein Interaction')
|
1420 |
-
|
1421 |
-
with gr.Row():
|
1422 |
-
with gr.Column():
|
1423 |
-
HelpTip(
|
1424 |
-
"Select your preferred model, or click Recommend for the best-performing model based "
|
1425 |
-
"on the selected task, family, and whether the compound was trained. "
|
1426 |
-
"Please refer to documentation for detailed benchamrk results."
|
1427 |
-
)
|
1428 |
-
target_identify_preset = gr.Dropdown(list(PRESET_MAP.keys()),
|
1429 |
-
label='Step 5. Select a Preset Model')
|
1430 |
-
identify_preset_recommend_btn = gr.Button(value='OR Let Us Recommend for You',
|
1431 |
-
variant='primary')
|
1432 |
-
|
1433 |
-
with gr.Row():
|
1434 |
-
with gr.Column():
|
1435 |
-
target_identify_email = gr.Textbox(
|
1436 |
-
label='Step 6. Input Your Email Address (Optional)',
|
1437 |
-
info="Your email address will be used to notify you of the status of your job. "
|
1438 |
-
"If you cannot receive the email, please check your spam/junk folder."
|
1439 |
-
)
|
1440 |
-
|
1441 |
-
with gr.Row(visible=True):
|
1442 |
-
# target_identify_clr_btn = gr.ClearButton(size='lg')
|
1443 |
-
target_identify_btn = gr.Button(value='SUBMIT THE IDENTIFICATION JOB', variant='primary',
|
1444 |
-
size='lg')
|
1445 |
|
1446 |
identify_data_for_predict = gr.File(visible=False, file_count="single", type='filepath')
|
1447 |
|
@@ -1452,100 +1449,99 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
1452 |
<center>To predict interactions or binding affinities between up to
|
1453 |
10,000 paired compound-protein data.</center>
|
1454 |
''')
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
interactive=False)
|
1475 |
-
with gr.Row():
|
1476 |
-
infer_csv_prompt = gr.Button(
|
1477 |
-
value="Upload Your Own Dataset Below",
|
1478 |
-
variant='secondary')
|
1479 |
-
with gr.Column():
|
1480 |
-
infer_pair = gr.File(
|
1481 |
-
label='Upload CSV File Containing Paired Records',
|
1482 |
-
file_count="single", type='filepath', visible=True)
|
1483 |
-
with gr.Column(visible=False) as pair_generate:
|
1484 |
-
with gr.Row():
|
1485 |
-
gr.File(label='Example SDF compound library',
|
1486 |
-
value='data/examples/compound_library.sdf', interactive=False)
|
1487 |
-
gr.File(label='Example FASTA target library',
|
1488 |
-
value='data/examples/target_library.fasta', interactive=False)
|
1489 |
-
with gr.Row():
|
1490 |
-
gr.File(label='Example CSV compound library',
|
1491 |
-
value='data/examples/compound_library.csv', interactive=False)
|
1492 |
-
gr.File(label='Example CSV target library',
|
1493 |
-
value='data/examples/target_library.csv', interactive=False)
|
1494 |
-
with gr.Row():
|
1495 |
-
infer_library_prompt = gr.Button(
|
1496 |
-
value="Upload Your Own Libraries Below",
|
1497 |
-
visible=False, variant='secondary')
|
1498 |
-
with gr.Row():
|
1499 |
-
infer_drug = gr.File(label='Upload SDF/CSV File Containing Multiple Compounds',
|
1500 |
-
file_count="single", type='filepath')
|
1501 |
-
infer_target = gr.File(label='Upload FASTA/CSV File Containing Multiple Targets',
|
1502 |
-
file_count="single", type='filepath')
|
1503 |
-
|
1504 |
with gr.Row():
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
label='Step 2. Select Target Family (Optional)')
|
1514 |
-
|
1515 |
with gr.Row():
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
"while affinity prediction directly estimates their binding strength "
|
1521 |
-
"measured using IC50."
|
1522 |
-
)
|
1523 |
-
pair_infer_task = gr.Dropdown(
|
1524 |
-
list(TASK_MAP.keys()),
|
1525 |
-
label='Step 3. Select the Prediction Task You Want to Conduct',
|
1526 |
-
value='Compound-Protein Interaction')
|
1527 |
-
|
1528 |
with gr.Row():
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
pair_infer_preset = gr.Dropdown(list(PRESET_MAP.keys()),
|
1534 |
-
label='Step 4. Select a Preset Model')
|
1535 |
-
# infer_preset_recommend_btn = gr.Button(value='OR Let Us Recommend for You',
|
1536 |
-
# variant='primary')
|
1537 |
-
|
1538 |
with gr.Row():
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
|
|
|
|
|
|
|
|
1543 |
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1547 |
|
1548 |
-
|
|
|
|
|
|
|
|
|
1549 |
|
1550 |
with gr.TabItem(label='Chemical Property Report', id='Chemical Property Report'):
|
1551 |
gr.Markdown('''
|
@@ -1563,36 +1559,35 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
1563 |
Please first `Preview` the report, then `Generate` and download a CSV report
|
1564 |
or an interactive HTML report below if you wish to access the full report.
|
1565 |
''')
|
1566 |
-
with gr.
|
1567 |
-
with gr.
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
with gr.
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
with gr.
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
html_download_file = gr.File(label='Download HTML Report', visible=False)
|
1596 |
|
1597 |
with gr.TabItem(label='Prediction Status Lookup', id='Prediction Status Lookup'):
|
1598 |
gr.Markdown('''
|
@@ -1604,15 +1599,14 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
1604 |
You will be redirected to Chemical Property Report for carrying out further analysis and
|
1605 |
generating the full report if the job is done.
|
1606 |
''')
|
1607 |
-
with gr.
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
pred_lookup_status = gr.Markdown()
|
1616 |
|
1617 |
# retrieve_email = gr.Textbox(label='Step 2. Input Your Email Address', placeholder='e.g.,
|
1618 |
|
@@ -2055,7 +2049,8 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2055 |
fn=drug_screen_validate,
|
2056 |
inputs=[target_fasta, drug_library, drug_library_upload, drug_screen_preset, drug_screen_task,
|
2057 |
drug_screen_email, run_state],
|
2058 |
-
outputs=[screen_data_for_predict, run_state]
|
|
|
2059 |
)
|
2060 |
|
2061 |
drug_screen_lookup = drug_screen_click.success(
|
@@ -2066,7 +2061,8 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2066 |
fn=lookup_job,
|
2067 |
inputs=[pred_lookup_id],
|
2068 |
outputs=[pred_lookup_status, pred_lookup_btn, pred_lookup_stop_btn, tabs, file_for_report],
|
2069 |
-
show_progress='
|
|
|
2070 |
)
|
2071 |
|
2072 |
drug_screen_click.success(
|
@@ -2085,7 +2081,8 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2085 |
fn=target_identify_validate,
|
2086 |
inputs=[compound_smiles, target_library, target_library_upload, target_identify_preset, target_identify_task,
|
2087 |
target_identify_email, run_state],
|
2088 |
-
outputs=[identify_data_for_predict, run_state]
|
|
|
2089 |
)
|
2090 |
|
2091 |
target_identify_lookup = target_identify_click.success(
|
@@ -2096,7 +2093,8 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2096 |
fn=lookup_job,
|
2097 |
inputs=[pred_lookup_id],
|
2098 |
outputs=[pred_lookup_status, pred_lookup_btn, pred_lookup_stop_btn, tabs, file_for_report],
|
2099 |
-
show_progress='
|
|
|
2100 |
)
|
2101 |
|
2102 |
target_identify_click.success(
|
@@ -2116,7 +2114,7 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2116 |
inputs=[infer_pair, infer_drug, infer_target, pair_infer_preset, pair_infer_task,
|
2117 |
pair_infer_email, run_state],
|
2118 |
outputs=[infer_data_for_predict, run_state],
|
2119 |
-
|
2120 |
)
|
2121 |
|
2122 |
pair_infer_lookup = pair_infer_click.success(
|
@@ -2127,7 +2125,8 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2127 |
fn=lookup_job,
|
2128 |
inputs=[pred_lookup_id],
|
2129 |
outputs=[pred_lookup_status, pred_lookup_btn, pred_lookup_stop_btn, tabs, file_for_report],
|
2130 |
-
show_progress='
|
|
|
2131 |
)
|
2132 |
|
2133 |
pair_infer_click.success(
|
@@ -2146,14 +2145,15 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2146 |
fn=lookup_job,
|
2147 |
inputs=[pred_lookup_id],
|
2148 |
outputs=[pred_lookup_status, pred_lookup_btn, pred_lookup_stop_btn, tabs, file_for_report],
|
2149 |
-
show_progress='
|
|
|
2150 |
)
|
2151 |
|
2152 |
pred_lookup_stop_btn.click(
|
2153 |
fn=lambda: [gr.Button(visible=True), gr.Button(visible=False)],
|
2154 |
outputs=[pred_lookup_btn, pred_lookup_stop_btn],
|
2155 |
cancels=[pred_lookup_click, drug_screen_lookup, target_identify_lookup, pair_infer_lookup],
|
2156 |
-
|
2157 |
)
|
2158 |
|
2159 |
|
@@ -2177,12 +2177,14 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2177 |
|
2178 |
|
2179 |
report_df_change = file_for_report.change(
|
2180 |
-
fn=update_df, inputs=file_for_report, outputs=[html_report, raw_df, report_df, analyze_btn, report_task]
|
|
|
2181 |
)
|
2182 |
|
2183 |
file_for_report.upload(
|
2184 |
fn=update_df, inputs=file_for_report, outputs=[html_report, raw_df, report_df, analyze_btn, report_task],
|
2185 |
-
cancels=[report_df_change]
|
|
|
2186 |
).then(
|
2187 |
fn=inquire_task, inputs=[raw_df],
|
2188 |
outputs=[report_task, html_report, analyze_btn, csv_generate, html_generate],
|
@@ -2196,12 +2198,17 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2196 |
gr.Button(interactive=False)],
|
2197 |
outputs=[
|
2198 |
csv_generate, html_generate, csv_download_file, html_download_file, report_task, html_report, analyze_btn
|
2199 |
-
]
|
|
|
2200 |
|
2201 |
-
analyze_btn.click(
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
|
|
|
|
|
|
|
|
2205 |
|
2206 |
report_task.select(fn=lambda: gr.Button(interactive=True),
|
2207 |
outputs=analyze_btn)
|
@@ -2241,9 +2248,5 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2241 |
outputs=html_download_file, show_progress='full')
|
2242 |
|
2243 |
if __name__ == "__main__":
|
2244 |
-
|
2245 |
-
|
2246 |
-
infer_block.queue(default_concurrency_limit=2, max_size=10)
|
2247 |
-
report_block.queue(default_concurrency_limit=10, max_size=10)
|
2248 |
-
|
2249 |
-
demo.launch(show_api=False)
|
|
|
54 |
|
55 |
UNIPROT_ENDPOINT = 'https://rest.uniprot.org/uniprotkb/{query}'
|
56 |
DATASET_MAX_LEN = 10_000
|
57 |
+
SERVER_DATA_DIR = os.getenv('DATA') # '/data'
|
58 |
|
59 |
CSS = """
|
60 |
.help-tip {
|
|
|
608 |
yield {
|
609 |
pred_lookup_status: f'Your {job_type} job (ID: {job_id}) has been **COMPLETED**' +
|
610 |
f' at {end_time}' if job.get('end_time') else '' +
|
611 |
+
f', and the results will expire by {expiry_time}.'
|
612 |
+
if job.get('expiry_time') else '.' + f'Redirecting to the report page...',
|
|
|
613 |
pred_lookup_btn: gr.Button(visible=True),
|
614 |
pred_lookup_stop_btn: gr.Button(visible=False),
|
615 |
tabs: gr.Tabs(selected='Chemical Property Report'),
|
|
|
620 |
yield {
|
621 |
pred_lookup_status: f'Your {job_type} job (ID: {job_id}) has **FAILED**' +
|
622 |
f' at {end_time}' if job.get('end_time') else '' +
|
623 |
+
f' due to error: {error}.' if job.get('expiry_time') else '.',
|
|
|
624 |
pred_lookup_btn: gr.Button(visible=True),
|
625 |
pred_lookup_stop_btn: gr.Button(visible=False),
|
626 |
tabs: gr.Tabs(selected='Prediction Status Lookup'),
|
|
|
653 |
preset = PRESET_MAP[preset]
|
654 |
|
655 |
prediction_df = pd.DataFrame()
|
656 |
+
cfg = hydra.compose(
|
657 |
+
config_name="webserver_inference",
|
658 |
+
overrides=[f"task={task}",
|
659 |
+
f"preset={preset}",
|
660 |
+
f"ckpt_path=resources/checkpoints/{preset}-{task}-{target_family}.ckpt",
|
661 |
+
f"data.data_file='{str(predict_filepath)}'"])
|
662 |
+
# with concurrent.futures.ThreadPoolExecutor() as executor:
|
663 |
+
# future = executor.submit(predict, cfg)
|
664 |
+
# try:
|
665 |
+
# predictions, _ = future.result(timeout=4*60*60)
|
666 |
+
# except concurrent.futures.TimeoutError:
|
667 |
+
# raise gr.Error("Prediction timed out.")
|
668 |
+
predictions, _ = predict(cfg)
|
669 |
+
predictions = [pd.DataFrame(prediction) for prediction in predictions]
|
670 |
+
prediction_df = pd.concat([prediction_df, pd.concat(predictions, ignore_index=True)])
|
671 |
+
prediction_df.set_index('N', inplace=True)
|
672 |
+
orig_df = pd.read_csv(
|
673 |
+
predict_filepath,
|
674 |
+
usecols=lambda x: x not in ['X1', 'ID1', 'Compound', 'Scaffold', 'Scaffold SMILES',
|
675 |
+
'X2', 'ID2',
|
676 |
+
'Y', 'Y^']
|
677 |
+
)
|
678 |
+
prediction_df = pd.merge(prediction_df, orig_df, left_index=True, right_index=True, how='left')
|
|
|
679 |
|
680 |
+
prediction_df.to_csv(predictions_file)
|
681 |
+
status = "COMPLETED"
|
682 |
+
|
683 |
+
return {run_state: False}
|
684 |
|
|
|
685 |
except Exception as e:
|
686 |
gr.Warning(f"Prediction job failed due to error: {str(e)}")
|
687 |
status = "FAILED"
|
688 |
predictions_file = None
|
689 |
error = str(e)
|
690 |
return {run_state: False}
|
691 |
+
|
692 |
finally:
|
693 |
Job = Query()
|
694 |
job_query = (Job.id == job_id)
|
|
|
1218 |
with gr.Tabs() as tabs:
|
1219 |
with gr.TabItem(label='Drug Hit Screening', id='Drug Hit Screening'):
|
1220 |
gr.Markdown('''
|
1221 |
+
# <center>Drug Hit Screening</center>
|
1222 |
+
|
1223 |
+
<center>
|
1224 |
+
To predict interactions or binding affinities of a single target against a compound library.
|
1225 |
+
</center>
|
1226 |
+
''')
|
1227 |
+
with gr.Row():
|
1228 |
+
with gr.Column():
|
1229 |
+
HelpTip(
|
1230 |
+
"Enter (paste) a amino acid sequence below manually or upload a FASTA file. "
|
1231 |
+
"If multiple entities are in the FASTA, only the first will be used. "
|
1232 |
+
"Alternatively, enter a Uniprot ID or gene symbol with organism and click Query for "
|
1233 |
+
"the sequence."
|
1234 |
+
)
|
1235 |
+
target_input_type = gr.Dropdown(
|
1236 |
+
label='Step 1. Select Target Input Type and Input',
|
1237 |
+
choices=['Sequence', 'UniProt ID', 'Gene symbol'],
|
1238 |
+
info='Enter (paste) a FASTA string below manually or upload a FASTA file.',
|
1239 |
+
value='Sequence',
|
1240 |
+
scale=4, interactive=True
|
1241 |
+
)
|
1242 |
+
|
1243 |
+
with gr.Row():
|
1244 |
+
target_id = gr.Textbox(show_label=False, visible=False,
|
1245 |
+
interactive=True, scale=4,
|
1246 |
+
info='Enter a UniProt ID and query.')
|
1247 |
+
target_gene = gr.Textbox(
|
1248 |
+
show_label=False, visible=False,
|
1249 |
+
interactive=True, scale=4,
|
1250 |
+
info='Enter a gene symbol and query.')
|
1251 |
+
target_organism = gr.Textbox(
|
1252 |
+
info='Organism scientific name (default: Homo sapiens).',
|
1253 |
+
placeholder='Homo sapiens', show_label=False,
|
1254 |
+
visible=False, interactive=True, scale=4, )
|
1255 |
+
target_upload_btn = gr.UploadButton(label='Upload a FASTA File', type='binary',
|
1256 |
+
visible=True, variant='primary',
|
1257 |
+
size='lg')
|
1258 |
+
target_paste_markdown = gr.Button(value='OR Paste Your Sequence Below',
|
1259 |
+
variant='secondary')
|
1260 |
+
target_query_btn = gr.Button(value='Query the Sequence', variant='primary',
|
1261 |
+
visible=False, scale=4)
|
1262 |
+
# with gr.Row():
|
1263 |
+
# example_uniprot = gr.Button(value='Example: Q16539', elem_classes='example', visible=False)
|
1264 |
+
# example_gene = gr.Button(value='Example: MAPK14', elem_classes='example', visible=False)
|
1265 |
+
example_fasta = gr.Button(value='Example: MAPK14 (Q16539)', elem_classes='example')
|
1266 |
+
target_fasta = gr.Code(label='Input or Display FASTA', interactive=True, lines=5)
|
1267 |
+
# with gr.Row():
|
1268 |
+
# with gr.Column():
|
1269 |
+
# with gr.Column():
|
1270 |
+
# gr.File(label='Example FASTA file',
|
1271 |
+
# value='data/examples/MAPK14.fasta', interactive=False)
|
1272 |
+
|
1273 |
+
with gr.Row():
|
1274 |
+
with gr.Column(min_width=200):
|
1275 |
+
HelpTip(
|
1276 |
+
"Click Auto-detect to identify the protein family using sequence alignment. "
|
1277 |
+
"This optional step allows applying a family-specific model instead of a all-family "
|
1278 |
+
"model (general). "
|
1279 |
+
"Manually select general if the alignment results are unsatisfactory."
|
1280 |
+
)
|
1281 |
+
drug_screen_target_family = gr.Dropdown(
|
1282 |
+
choices=list(TARGET_FAMILY_MAP.keys()),
|
1283 |
+
value='General',
|
1284 |
+
label='Step 2. Select Target Family (Optional)', interactive=True)
|
1285 |
+
target_family_detect_btn = gr.Button(value='OR Let Us Auto-Detect for You',
|
1286 |
+
variant='primary')
|
1287 |
+
with gr.Column(min_width=200):
|
1288 |
+
HelpTip(
|
1289 |
+
"Interaction prediction provides you binding probability score between the target of "
|
1290 |
+
"interest and each compound in the library, "
|
1291 |
+
"while affinity prediction directly estimates their binding strength measured using "
|
1292 |
+
"IC50."
|
1293 |
+
)
|
1294 |
+
drug_screen_task = gr.Dropdown(
|
1295 |
+
list(TASK_MAP.keys()),
|
1296 |
+
label='Step 3. Select the Prediction Task',
|
1297 |
+
value='Compound-Protein Interaction')
|
1298 |
+
with gr.Column(min_width=200):
|
1299 |
+
HelpTip(
|
1300 |
+
"Select your preferred model, or click Recommend for the best-performing model based "
|
1301 |
+
"on the selected task, family, and whether the target was trained. "
|
1302 |
+
"Please refer to documentation for detailed benchmark results."
|
1303 |
+
)
|
1304 |
+
drug_screen_preset = gr.Dropdown(
|
1305 |
+
list(PRESET_MAP.keys()),
|
1306 |
+
label='Step 4. Select a Preset Model')
|
1307 |
+
screen_preset_recommend_btn = gr.Button(
|
1308 |
+
value='OR Let Us Recommend for You', variant='primary')
|
1309 |
+
|
1310 |
+
with gr.Row():
|
1311 |
+
with gr.Column():
|
1312 |
+
HelpTip(
|
1313 |
+
"Select a preset compound library (e.g., DrugBank). "
|
1314 |
+
"Alternatively, upload a CSV file with a column named X1 containing compound SMILES, "
|
1315 |
+
"or use an SDF file (Max. 10,000 compounds per task). Example CSV and SDF files are "
|
1316 |
+
"provided below and can be downloaded by clicking the lower right corner."
|
1317 |
+
)
|
1318 |
+
drug_library = gr.Dropdown(
|
1319 |
+
label='Step 5. Select a Preset Compound Library',
|
1320 |
+
choices=list(DRUG_LIBRARY_MAP.keys()))
|
1321 |
+
with gr.Row():
|
1322 |
+
gr.File(label='Example SDF compound library',
|
1323 |
+
value='data/examples/compound_library.sdf', interactive=False)
|
1324 |
+
gr.File(label='Example CSV compound library',
|
1325 |
+
value='data/examples/compound_library.csv', interactive=False)
|
1326 |
+
drug_library_upload_btn = gr.UploadButton(
|
1327 |
+
label='OR Upload Your Own Library', variant='primary')
|
1328 |
+
drug_library_upload = gr.File(label='Custom compound library file', visible=False)
|
1329 |
+
with gr.Row():
|
1330 |
+
with gr.Column():
|
1331 |
+
drug_screen_email = gr.Textbox(
|
1332 |
+
label='Step 6. Input Your Email Address (Optional)',
|
1333 |
+
info="Your email address will be used to notify you of the status of your job. "
|
1334 |
+
"If you cannot receive the email, please check your spam/junk folder."
|
1335 |
+
)
|
1336 |
+
|
1337 |
+
with gr.Row(visible=True):
|
1338 |
+
with gr.Column():
|
1339 |
+
# drug_screen_clr_btn = gr.ClearButton(size='lg')
|
1340 |
+
drug_screen_btn = gr.Button(value='SUBMIT THE SCREENING JOB', variant='primary', size='lg')
|
1341 |
+
# TODO Modify the pd df directly with df['X2'] = target
|
1342 |
+
|
1343 |
+
screen_data_for_predict = gr.File(visible=False, file_count="single", type='filepath')
|
1344 |
+
|
1345 |
+
with gr.TabItem(label='Target Protein Identification', id='Target Protein Identification'):
|
1346 |
+
gr.Markdown('''
|
1347 |
+
# <center>Target Protein Identification</center>
|
1348 |
+
|
1349 |
+
<center>
|
1350 |
+
To predict interactions or binding affinities of a single compound against a protein library.
|
1351 |
+
</center>
|
1352 |
+
''')
|
1353 |
+
with gr.Column() as identify_page:
|
1354 |
with gr.Row():
|
1355 |
with gr.Column():
|
1356 |
HelpTip(
|
1357 |
+
"Enter (paste) a compound SMILES below manually or upload a SDF file. "
|
1358 |
+
"If multiple entities are in the SDF, only the first will be used. "
|
1359 |
+
"SMILES can be obtained by searching for the compound of interest in databases such "
|
1360 |
+
"as NCBI, PubChem and and ChEMBL."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1361 |
)
|
1362 |
+
compound_type = gr.Dropdown(
|
1363 |
+
label='Step 1. Select Compound Input Type and Input',
|
1364 |
+
choices=['SMILES', 'SDF'],
|
1365 |
+
info='Enter (paste) an SMILES string or upload an SDF file to convert to SMILES.',
|
1366 |
+
value='SMILES',
|
1367 |
+
interactive=True)
|
1368 |
+
compound_upload_btn = gr.UploadButton(label='OR Upload a SDF File', variant='primary',
|
1369 |
+
type='binary', visible=False)
|
1370 |
+
|
1371 |
+
compound_smiles = gr.Code(label='Input or Display Compound SMILES', interactive=True, lines=5)
|
1372 |
+
example_drug = gr.Button(value='Example: Aspirin', elem_classes='example')
|
1373 |
|
1374 |
with gr.Row():
|
1375 |
+
with gr.Column(visible=False):
|
1376 |
+
HelpTip(
|
1377 |
+
"By default, models trained on all protein families (general) will be applied. "
|
1378 |
+
# "If the proteins in the target library of interest all belong to the same protein "
|
1379 |
+
# "family, manually selecting the family is supported."
|
1380 |
+
)
|
1381 |
+
target_identify_target_family = gr.Dropdown(
|
1382 |
+
choices=['General'], value='General',
|
1383 |
+
label='Step 2. Select Target Family (Optional)')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1384 |
|
1385 |
with gr.Row():
|
1386 |
+
with gr.Column():
|
1387 |
HelpTip(
|
1388 |
+
"Select a preset target library (e.g., ChEMBL33_human_proteins). "
|
1389 |
+
"Alternatively, upload a CSV file with a column named X2 containing target protein "
|
1390 |
+
"sequences, or use an FASTA file (Max. 10,000 targets per task). "
|
1391 |
+
"Example CSV and SDF files are provided below "
|
1392 |
+
"and can be downloaded by clicking the lower right corner."
|
1393 |
)
|
1394 |
+
target_library = gr.Dropdown(label='Step 3. Select a Preset Target Library',
|
1395 |
+
choices=list(TARGET_LIBRARY_MAP.keys()))
|
1396 |
+
with gr.Row():
|
1397 |
+
gr.File(label='Example FASTA target library',
|
1398 |
+
value='data/examples/target_library.fasta', interactive=False)
|
1399 |
+
gr.File(label='Example CSV target library',
|
1400 |
+
value='data/examples/target_library.csv', interactive=False)
|
1401 |
+
target_library_upload_btn = gr.UploadButton(
|
1402 |
+
label='OR Upload Your Own Library', variant='primary')
|
1403 |
+
target_library_upload = gr.File(label='Custom target library file', visible=False)
|
1404 |
+
|
1405 |
+
with gr.Row():
|
1406 |
+
with gr.Column():
|
1407 |
HelpTip(
|
1408 |
"Interaction prediction provides you binding probability score between the target of "
|
1409 |
"interest and each compound in the library, "
|
1410 |
"while affinity prediction directly estimates their binding strength measured using "
|
1411 |
"IC50."
|
1412 |
)
|
1413 |
+
target_identify_task = gr.Dropdown(
|
1414 |
list(TASK_MAP.keys()),
|
1415 |
+
label='Step 4. Select the Prediction Task You Want to Conduct',
|
1416 |
value='Compound-Protein Interaction')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1417 |
|
1418 |
with gr.Row():
|
1419 |
with gr.Column():
|
1420 |
HelpTip(
|
1421 |
+
"Select your preferred model, or click Recommend for the best-performing model based "
|
1422 |
+
"on the selected task, family, and whether the compound was trained. "
|
1423 |
+
"Please refer to documentation for detailed benchamrk results."
|
|
|
1424 |
)
|
1425 |
+
target_identify_preset = gr.Dropdown(list(PRESET_MAP.keys()),
|
1426 |
+
label='Step 5. Select a Preset Model')
|
1427 |
+
identify_preset_recommend_btn = gr.Button(value='OR Let Us Recommend for You',
|
1428 |
+
variant='primary')
|
1429 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
1430 |
with gr.Row():
|
1431 |
with gr.Column():
|
1432 |
+
target_identify_email = gr.Textbox(
|
1433 |
label='Step 6. Input Your Email Address (Optional)',
|
1434 |
info="Your email address will be used to notify you of the status of your job. "
|
1435 |
"If you cannot receive the email, please check your spam/junk folder."
|
1436 |
)
|
1437 |
|
1438 |
with gr.Row(visible=True):
|
1439 |
+
# target_identify_clr_btn = gr.ClearButton(size='lg')
|
1440 |
+
target_identify_btn = gr.Button(value='SUBMIT THE IDENTIFICATION JOB', variant='primary',
|
1441 |
+
size='lg')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1442 |
|
1443 |
identify_data_for_predict = gr.File(visible=False, file_count="single", type='filepath')
|
1444 |
|
|
|
1449 |
<center>To predict interactions or binding affinities between up to
|
1450 |
10,000 paired compound-protein data.</center>
|
1451 |
''')
|
1452 |
+
HelpTip(
|
1453 |
+
"A custom interation pair dataset can be a CSV file with 2 required columns "
|
1454 |
+
"(X1 for smiles and X2 for sequences) "
|
1455 |
+
"and optionally 2 ID columns (ID1 for compound ID and ID2 for target ID), "
|
1456 |
+
"or generated from a FASTA file containing multiple "
|
1457 |
+
"sequences and a SDF file containing multiple compounds. "
|
1458 |
+
"Currently, a maximum of 10,000 pairs is supported, "
|
1459 |
+
"which means that the size of CSV file or "
|
1460 |
+
"the product of the two library sizes should not exceed 10,000."
|
1461 |
+
)
|
1462 |
+
infer_type = gr.Dropdown(
|
1463 |
+
choices=['Upload a CSV file containing paired compound-protein data',
|
1464 |
+
'Upload a compound library and a target library'],
|
1465 |
+
label='Step 1. Select Pair Input Type and Input',
|
1466 |
+
value='Upload a CSV file containing paired compound-protein data')
|
1467 |
+
with gr.Column() as pair_upload:
|
1468 |
+
gr.File(label="Example CSV dataset",
|
1469 |
+
value="data/examples/interaction_pair_inference.csv",
|
1470 |
+
interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1471 |
with gr.Row():
|
1472 |
+
infer_csv_prompt = gr.Button(
|
1473 |
+
value="Upload Your Own Dataset Below",
|
1474 |
+
variant='secondary')
|
1475 |
+
with gr.Column():
|
1476 |
+
infer_pair = gr.File(
|
1477 |
+
label='Upload CSV File Containing Paired Records',
|
1478 |
+
file_count="single", type='filepath', visible=True)
|
1479 |
+
with gr.Column(visible=False) as pair_generate:
|
|
|
|
|
1480 |
with gr.Row():
|
1481 |
+
gr.File(label='Example SDF compound library',
|
1482 |
+
value='data/examples/compound_library.sdf', interactive=False)
|
1483 |
+
gr.File(label='Example FASTA target library',
|
1484 |
+
value='data/examples/target_library.fasta', interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1485 |
with gr.Row():
|
1486 |
+
gr.File(label='Example CSV compound library',
|
1487 |
+
value='data/examples/compound_library.csv', interactive=False)
|
1488 |
+
gr.File(label='Example CSV target library',
|
1489 |
+
value='data/examples/target_library.csv', interactive=False)
|
|
|
|
|
|
|
|
|
|
|
1490 |
with gr.Row():
|
1491 |
+
infer_library_prompt = gr.Button(
|
1492 |
+
value="Upload Your Own Libraries Below",
|
1493 |
+
visible=False, variant='secondary')
|
1494 |
+
with gr.Row():
|
1495 |
+
infer_drug = gr.File(label='Upload SDF/CSV File Containing Multiple Compounds',
|
1496 |
+
file_count="single", type='filepath')
|
1497 |
+
infer_target = gr.File(label='Upload FASTA/CSV File Containing Multiple Targets',
|
1498 |
+
file_count="single", type='filepath')
|
1499 |
|
1500 |
+
with gr.Row():
|
1501 |
+
with gr.Column():
|
1502 |
+
HelpTip(
|
1503 |
+
"By default, models trained on all protein families (general) will be applied. "
|
1504 |
+
"If the proteins in the target library of interest "
|
1505 |
+
"all belong to the same protein family, manually selecting the family is supported."
|
1506 |
+
)
|
1507 |
+
pair_infer_target_family = gr.Dropdown(choices=list(TARGET_FAMILY_MAP.keys()),
|
1508 |
+
value='General',
|
1509 |
+
label='Step 2. Select Target Family (Optional)')
|
1510 |
+
|
1511 |
+
with gr.Row():
|
1512 |
+
with gr.Column():
|
1513 |
+
HelpTip(
|
1514 |
+
"Interaction prediction provides you binding probability score "
|
1515 |
+
"between the target of interest and each compound in the library, "
|
1516 |
+
"while affinity prediction directly estimates their binding strength "
|
1517 |
+
"measured using IC50."
|
1518 |
+
)
|
1519 |
+
pair_infer_task = gr.Dropdown(
|
1520 |
+
list(TASK_MAP.keys()),
|
1521 |
+
label='Step 3. Select the Prediction Task You Want to Conduct',
|
1522 |
+
value='Compound-Protein Interaction')
|
1523 |
+
|
1524 |
+
with gr.Row():
|
1525 |
+
with gr.Column():
|
1526 |
+
HelpTip("Select your preferred model. "
|
1527 |
+
"Please refer to documentation for detailed benchmark results."
|
1528 |
+
)
|
1529 |
+
pair_infer_preset = gr.Dropdown(list(PRESET_MAP.keys()),
|
1530 |
+
label='Step 4. Select a Preset Model')
|
1531 |
+
# infer_preset_recommend_btn = gr.Button(value='OR Let Us Recommend for You',
|
1532 |
+
# variant='primary')
|
1533 |
+
|
1534 |
+
with gr.Row():
|
1535 |
+
pair_infer_email = gr.Textbox(
|
1536 |
+
label='Step 5. Input Your Email Address (Optional)',
|
1537 |
+
info="Your email address will be used to notify you of the status of your job. "
|
1538 |
+
"If you cannot receive the email, please check your spam/junk folder.")
|
1539 |
|
1540 |
+
with gr.Row(visible=True):
|
1541 |
+
# pair_infer_clr_btn = gr.ClearButton(size='lg')
|
1542 |
+
pair_infer_btn = gr.Button(value='SUBMIT THE INFERENCE JOB', variant='primary', size='lg')
|
1543 |
+
|
1544 |
+
infer_data_for_predict = gr.File(file_count="single", type='filepath', visible=False)
|
1545 |
|
1546 |
with gr.TabItem(label='Chemical Property Report', id='Chemical Property Report'):
|
1547 |
gr.Markdown('''
|
|
|
1559 |
Please first `Preview` the report, then `Generate` and download a CSV report
|
1560 |
or an interactive HTML report below if you wish to access the full report.
|
1561 |
''')
|
1562 |
+
with gr.Row():
|
1563 |
+
with gr.Column():
|
1564 |
+
file_for_report = gr.File(interactive=True, type='filepath')
|
1565 |
+
report_task = gr.Dropdown(list(TASK_MAP.keys()), visible=False, value=None,
|
1566 |
+
label='Specify the Task for the Labels in the Upload Dataset')
|
1567 |
+
raw_df = gr.State(value=pd.DataFrame())
|
1568 |
+
report_df = gr.State(value=pd.DataFrame())
|
1569 |
+
scores = gr.CheckboxGroup(list(SCORE_MAP.keys()), label='Scores')
|
1570 |
+
filters = gr.CheckboxGroup(list(FILTER_MAP.keys()), label='Filters')
|
1571 |
+
|
1572 |
+
with gr.Row():
|
1573 |
+
# clear_btn = gr.ClearButton(size='lg')
|
1574 |
+
analyze_btn = gr.Button('Preview Top 30 Records', variant='primary', size='lg',
|
1575 |
+
interactive=False)
|
1576 |
+
|
1577 |
+
with gr.Row():
|
1578 |
+
with gr.Column(scale=3):
|
1579 |
+
html_report = gr.HTML() # label='Results', visible=True)
|
1580 |
+
ranking_pie_chart = gr.Plot(visible=False)
|
1581 |
+
|
1582 |
+
with gr.Row():
|
1583 |
+
with gr.Column():
|
1584 |
+
csv_generate = gr.Button(value='Generate CSV Report',
|
1585 |
+
interactive=False, variant='primary')
|
1586 |
+
csv_download_file = gr.File(label='Download CSV Report', visible=False)
|
1587 |
+
with gr.Column():
|
1588 |
+
html_generate = gr.Button(value='Generate HTML Report',
|
1589 |
+
interactive=False, variant='primary')
|
1590 |
+
html_download_file = gr.File(label='Download HTML Report', visible=False)
|
|
|
1591 |
|
1592 |
with gr.TabItem(label='Prediction Status Lookup', id='Prediction Status Lookup'):
|
1593 |
gr.Markdown('''
|
|
|
1599 |
You will be redirected to Chemical Property Report for carrying out further analysis and
|
1600 |
generating the full report if the job is done.
|
1601 |
''')
|
1602 |
+
with gr.Column():
|
1603 |
+
pred_lookup_id = gr.Textbox(
|
1604 |
+
label='Input Your Job ID', placeholder='e.g., e9dfd149-3f5c-48a6-b797-c27d027611ac',
|
1605 |
+
info="Your job ID is a UUID4 string that you receive after submitting a job on the "
|
1606 |
+
"page or in the email notification.")
|
1607 |
+
pred_lookup_btn = gr.Button(value='Lookup the Job Status', variant='primary', visible=True)
|
1608 |
+
pred_lookup_stop_btn = gr.Button(value='Stop Tracking', variant='stop', visible=False)
|
1609 |
+
pred_lookup_status = gr.Markdown()
|
|
|
1610 |
|
1611 |
# retrieve_email = gr.Textbox(label='Step 2. Input Your Email Address', placeholder='e.g.,
|
1612 |
|
|
|
2049 |
fn=drug_screen_validate,
|
2050 |
inputs=[target_fasta, drug_library, drug_library_upload, drug_screen_preset, drug_screen_task,
|
2051 |
drug_screen_email, run_state],
|
2052 |
+
outputs=[screen_data_for_predict, run_state],
|
2053 |
+
concurrency_limit=2,
|
2054 |
)
|
2055 |
|
2056 |
drug_screen_lookup = drug_screen_click.success(
|
|
|
2061 |
fn=lookup_job,
|
2062 |
inputs=[pred_lookup_id],
|
2063 |
outputs=[pred_lookup_status, pred_lookup_btn, pred_lookup_stop_btn, tabs, file_for_report],
|
2064 |
+
show_progress='minimal',
|
2065 |
+
concurrency_limit=100
|
2066 |
)
|
2067 |
|
2068 |
drug_screen_click.success(
|
|
|
2081 |
fn=target_identify_validate,
|
2082 |
inputs=[compound_smiles, target_library, target_library_upload, target_identify_preset, target_identify_task,
|
2083 |
target_identify_email, run_state],
|
2084 |
+
outputs=[identify_data_for_predict, run_state],
|
2085 |
+
concurrency_limit=2,
|
2086 |
)
|
2087 |
|
2088 |
target_identify_lookup = target_identify_click.success(
|
|
|
2093 |
fn=lookup_job,
|
2094 |
inputs=[pred_lookup_id],
|
2095 |
outputs=[pred_lookup_status, pred_lookup_btn, pred_lookup_stop_btn, tabs, file_for_report],
|
2096 |
+
show_progress='minimal',
|
2097 |
+
concurrency_limit=100
|
2098 |
)
|
2099 |
|
2100 |
target_identify_click.success(
|
|
|
2114 |
inputs=[infer_pair, infer_drug, infer_target, pair_infer_preset, pair_infer_task,
|
2115 |
pair_infer_email, run_state],
|
2116 |
outputs=[infer_data_for_predict, run_state],
|
2117 |
+
concurrency_limit=2,
|
2118 |
)
|
2119 |
|
2120 |
pair_infer_lookup = pair_infer_click.success(
|
|
|
2125 |
fn=lookup_job,
|
2126 |
inputs=[pred_lookup_id],
|
2127 |
outputs=[pred_lookup_status, pred_lookup_btn, pred_lookup_stop_btn, tabs, file_for_report],
|
2128 |
+
show_progress='minimal',
|
2129 |
+
concurrency_limit=100
|
2130 |
)
|
2131 |
|
2132 |
pair_infer_click.success(
|
|
|
2145 |
fn=lookup_job,
|
2146 |
inputs=[pred_lookup_id],
|
2147 |
outputs=[pred_lookup_status, pred_lookup_btn, pred_lookup_stop_btn, tabs, file_for_report],
|
2148 |
+
show_progress='minimal',
|
2149 |
+
concurrency_limit=100,
|
2150 |
)
|
2151 |
|
2152 |
pred_lookup_stop_btn.click(
|
2153 |
fn=lambda: [gr.Button(visible=True), gr.Button(visible=False)],
|
2154 |
outputs=[pred_lookup_btn, pred_lookup_stop_btn],
|
2155 |
cancels=[pred_lookup_click, drug_screen_lookup, target_identify_lookup, pair_infer_lookup],
|
2156 |
+
concurrency_limit=None,
|
2157 |
)
|
2158 |
|
2159 |
|
|
|
2177 |
|
2178 |
|
2179 |
report_df_change = file_for_report.change(
|
2180 |
+
fn=update_df, inputs=file_for_report, outputs=[html_report, raw_df, report_df, analyze_btn, report_task],
|
2181 |
+
concurrency_limit=100,
|
2182 |
)
|
2183 |
|
2184 |
file_for_report.upload(
|
2185 |
fn=update_df, inputs=file_for_report, outputs=[html_report, raw_df, report_df, analyze_btn, report_task],
|
2186 |
+
cancels=[report_df_change],
|
2187 |
+
concurrency_limit=100,
|
2188 |
).then(
|
2189 |
fn=inquire_task, inputs=[raw_df],
|
2190 |
outputs=[report_task, html_report, analyze_btn, csv_generate, html_generate],
|
|
|
2198 |
gr.Button(interactive=False)],
|
2199 |
outputs=[
|
2200 |
csv_generate, html_generate, csv_download_file, html_download_file, report_task, html_report, analyze_btn
|
2201 |
+
]
|
2202 |
+
)
|
2203 |
|
2204 |
+
analyze_btn.click(
|
2205 |
+
fn=submit_report, inputs=[raw_df, scores, filters, report_task], outputs=[
|
2206 |
+
html_report, report_df, csv_download_file, html_download_file]
|
2207 |
+
).success(
|
2208 |
+
fn=lambda: [gr.Button(interactive=True)] * 2,
|
2209 |
+
outputs=[csv_generate, html_generate],
|
2210 |
+
concurrency_limit=100,
|
2211 |
+
)
|
2212 |
|
2213 |
report_task.select(fn=lambda: gr.Button(interactive=True),
|
2214 |
outputs=analyze_btn)
|
|
|
2248 |
outputs=html_download_file, show_progress='full')
|
2249 |
|
2250 |
if __name__ == "__main__":
|
2251 |
+
hydra.initialize(version_base="1.3", config_path="configs", job_name="webserver_inference")
|
2252 |
+
demo.queue(default_concurrency_limit=None, max_size=10).launch(show_api=False, share=True)
|
|
|
|
|
|
|
|