Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -505,9 +505,6 @@ def send_email(job_info):
|
|
505 |
gr.Info('Email notification sent successfully.')
|
506 |
except Exception as e:
|
507 |
gr.Warning('Failed to send email notification due to error: ' + str(e))
|
508 |
-
else:
|
509 |
-
gr.Info('You won\'t receive an email notification as you haven\'t provided an email address. '
|
510 |
-
'Please make sure you take note of the job ID.')
|
511 |
|
512 |
|
513 |
def check_user_running_job(email, request):
|
@@ -574,6 +571,7 @@ def ts_to_str(ts, timezone_str):
|
|
574 |
|
575 |
|
576 |
def lookup_job(job_id):
|
|
|
577 |
stop = False
|
578 |
while not stop:
|
579 |
try:
|
@@ -605,11 +603,14 @@ using the job id. You will also receive an email notification once the job is do
|
|
605 |
}
|
606 |
if job_status == "COMPLETED":
|
607 |
stop = True
|
|
|
|
|
|
|
|
|
|
|
|
|
608 |
yield {
|
609 |
-
pred_lookup_status:
|
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'),
|
@@ -617,18 +618,22 @@ using the job id. You will also receive an email notification once the job is do
|
|
617 |
}
|
618 |
if job_status == "FAILED":
|
619 |
stop = True
|
|
|
|
|
|
|
|
|
620 |
yield {
|
621 |
-
pred_lookup_status:
|
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'),
|
627 |
}
|
628 |
else:
|
629 |
stop = True
|
|
|
|
|
630 |
yield {
|
631 |
-
pred_lookup_status:
|
632 |
pred_lookup_btn: gr.Button(visible=True),
|
633 |
pred_lookup_stop_btn: gr.Button(visible=False),
|
634 |
tabs: gr.Tabs(selected='Prediction Status Lookup'),
|
@@ -1186,27 +1191,26 @@ def target_library_from_fasta(fasta_path):
|
|
1186 |
return df
|
1187 |
|
1188 |
|
1189 |
-
theme = gr.themes.Base(spacing_size="sm", text_size='md').set(
|
1190 |
-
background_fill_primary='#
|
1191 |
background_fill_secondary='white',
|
1192 |
-
checkbox_label_background_fill='#
|
1193 |
checkbox_label_background_fill_hover='#dfe6f0',
|
1194 |
checkbox_background_color='white',
|
1195 |
checkbox_border_color='#4372c4',
|
1196 |
border_color_primary='#4372c4',
|
1197 |
-
border_color_accent='#
|
1198 |
-
button_primary_background_fill='#
|
1199 |
button_primary_text_color='white',
|
1200 |
-
|
1201 |
-
|
1202 |
-
block_title_text_color='#
|
1203 |
-
block_label_text_color='#
|
1204 |
block_info_text_color='#505358',
|
1205 |
block_border_color=None,
|
1206 |
-
input_border_color='#4372c4',
|
1207 |
-
panel_border_color='#4372c4',
|
1208 |
-
input_background_fill='
|
1209 |
-
code_background_fill='white',
|
1210 |
)
|
1211 |
|
1212 |
with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48 * 3600)) as demo:
|
@@ -1247,7 +1251,7 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
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,
|
@@ -1293,7 +1297,7 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
1293 |
)
|
1294 |
drug_screen_task = gr.Dropdown(
|
1295 |
list(TASK_MAP.keys()),
|
1296 |
-
label='Step 3. Select
|
1297 |
value='Compound-Protein Interaction')
|
1298 |
with gr.Column(min_width=200):
|
1299 |
HelpTip(
|
@@ -1365,8 +1369,8 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
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(
|
1369 |
-
|
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')
|
@@ -1380,8 +1384,32 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
1380 |
)
|
1381 |
target_identify_target_family = gr.Dropdown(
|
1382 |
choices=['General'], value='General',
|
1383 |
-
label='
|
1384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1385 |
with gr.Row():
|
1386 |
with gr.Column():
|
1387 |
HelpTip(
|
@@ -1391,8 +1419,9 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
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(
|
1395 |
-
|
|
|
1396 |
with gr.Row():
|
1397 |
gr.File(label='Example FASTA target library',
|
1398 |
value='data/examples/target_library.fasta', interactive=False)
|
@@ -1402,35 +1431,10 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
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
|
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 |
)
|
@@ -1498,18 +1502,18 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
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(
|
1508 |
-
|
1509 |
-
|
|
|
1510 |
|
1511 |
-
|
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, "
|
@@ -1518,16 +1522,16 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
1518 |
)
|
1519 |
pair_infer_task = gr.Dropdown(
|
1520 |
list(TASK_MAP.keys()),
|
1521 |
-
label='Step 3. Select
|
1522 |
value='Compound-Protein Interaction')
|
1523 |
|
1524 |
-
|
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(
|
1530 |
-
|
|
|
1531 |
# infer_preset_recommend_btn = gr.Button(value='OR Let Us Recommend for You',
|
1532 |
# variant='primary')
|
1533 |
|
@@ -1597,7 +1601,8 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
1597 |
if the job has completed. Note that predictions are only kept for 48 hours upon job completion.
|
1598 |
|
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(
|
@@ -1655,7 +1660,7 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
1655 |
|
1656 |
|
1657 |
def uniprot_query(input_type, uid, gene, organism='Human'):
|
1658 |
-
|
1659 |
|
1660 |
match input_type:
|
1661 |
case 'UniProt ID':
|
@@ -1667,11 +1672,14 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48
|
|
1667 |
try:
|
1668 |
fasta = session.get(UNIPROT_ENDPOINT.format(query=query))
|
1669 |
fasta.raise_for_status()
|
1670 |
-
|
|
|
|
|
|
|
1671 |
except Exception as e:
|
1672 |
raise gr.Warning(f"Failed to query FASTA from UniProt database due to {str(e)}")
|
1673 |
finally:
|
1674 |
-
return
|
1675 |
|
1676 |
|
1677 |
def process_fasta_upload(fasta_upload):
|
@@ -1889,10 +1897,12 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
1889 |
|
1890 |
infer_type.select(fn=infer_type_change, inputs=infer_type,
|
1891 |
outputs=[pair_upload, pair_generate, infer_pair, infer_drug, infer_target,
|
1892 |
-
infer_csv_prompt, infer_library_prompt]
|
|
|
1893 |
|
1894 |
|
1895 |
def common_input_validate(state, preset, email, request):
|
|
|
1896 |
if not preset:
|
1897 |
raise gr.Error('Please select a model.')
|
1898 |
|
@@ -1914,7 +1924,7 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
1914 |
|
1915 |
|
1916 |
def common_job_initiate(job_id, job_type, email, request, task):
|
1917 |
-
gr.Info('Finished
|
1918 |
'You will be redirected to Prediction Status Lookup after the job is submitted.')
|
1919 |
job_info = {'id': job_id,
|
1920 |
'type': job_type,
|
@@ -2062,7 +2072,7 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
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(
|
@@ -2146,6 +2156,7 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
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 |
|
@@ -2191,13 +2202,12 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
2191 |
)
|
2192 |
|
2193 |
file_for_report.clear(
|
2194 |
-
fn=lambda: [gr.Button(
|
2195 |
[gr.File(visible=False, value=None)] * 2 +
|
2196 |
[gr.Dropdown(visible=False, value=None),
|
2197 |
-
gr.HTML(visible=False),
|
2198 |
-
gr.Button(interactive=False)],
|
2199 |
outputs=[
|
2200 |
-
csv_generate, html_generate, csv_download_file, html_download_file, report_task, html_report
|
2201 |
]
|
2202 |
)
|
2203 |
|
@@ -2249,4 +2259,4 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
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
|
|
|
505 |
gr.Info('Email notification sent successfully.')
|
506 |
except Exception as e:
|
507 |
gr.Warning('Failed to send email notification due to error: ' + str(e))
|
|
|
|
|
|
|
508 |
|
509 |
|
510 |
def check_user_running_job(email, request):
|
|
|
571 |
|
572 |
|
573 |
def lookup_job(job_id):
|
574 |
+
gr.Info('Start querying the job database...')
|
575 |
stop = False
|
576 |
while not stop:
|
577 |
try:
|
|
|
603 |
}
|
604 |
if job_status == "COMPLETED":
|
605 |
stop = True
|
606 |
+
msg = f"Your {job_type} job (ID: {job_id}) has been **COMPLETED**"
|
607 |
+
msg += f" at {end_time}" if job.get('end_time') else ""
|
608 |
+
msg += f" and the results will expire by {expiry_time}." if job.get('expiry_time') else "."
|
609 |
+
msg += f' Redirecting to the report page...'
|
610 |
+
|
611 |
+
gr.Info(msg)
|
612 |
yield {
|
613 |
+
pred_lookup_status: msg,
|
|
|
|
|
|
|
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'),
|
|
|
618 |
}
|
619 |
if job_status == "FAILED":
|
620 |
stop = True
|
621 |
+
msg = f'Your {job_type} job (ID: {job_id}) has **FAILED**'
|
622 |
+
msg += f' at {end_time}' if job.get('end_time') else ''
|
623 |
+
msg += f' due to error: {error}.' if job.get('expiry_time') else '.'
|
624 |
+
gr.Info(msg)
|
625 |
yield {
|
626 |
+
pred_lookup_status: msg,
|
|
|
|
|
627 |
pred_lookup_btn: gr.Button(visible=True),
|
628 |
pred_lookup_stop_btn: gr.Button(visible=False),
|
629 |
tabs: gr.Tabs(selected='Prediction Status Lookup'),
|
630 |
}
|
631 |
else:
|
632 |
stop = True
|
633 |
+
msg = f'Job ID {job_id} not found.'
|
634 |
+
gr.Info(msg)
|
635 |
yield {
|
636 |
+
pred_lookup_status: msg,
|
637 |
pred_lookup_btn: gr.Button(visible=True),
|
638 |
pred_lookup_stop_btn: gr.Button(visible=False),
|
639 |
tabs: gr.Tabs(selected='Prediction Status Lookup'),
|
|
|
1191 |
return df
|
1192 |
|
1193 |
|
1194 |
+
theme = gr.themes.Base(spacing_size="sm", text_size='md', font=gr.themes.GoogleFont("Roboto")).set(
|
1195 |
+
background_fill_primary='#eef3f9',
|
1196 |
background_fill_secondary='white',
|
1197 |
+
checkbox_label_background_fill='#eef3f9',
|
1198 |
checkbox_label_background_fill_hover='#dfe6f0',
|
1199 |
checkbox_background_color='white',
|
1200 |
checkbox_border_color='#4372c4',
|
1201 |
border_color_primary='#4372c4',
|
1202 |
+
border_color_accent='#2e6ab5',
|
1203 |
+
button_primary_background_fill='#2e6ab4',
|
1204 |
button_primary_text_color='white',
|
1205 |
+
body_text_color='#28496F',
|
1206 |
+
block_background_fill='#fbfcfd',
|
1207 |
+
block_title_text_color='#28496F',
|
1208 |
+
block_label_text_color='#28496F',
|
1209 |
block_info_text_color='#505358',
|
1210 |
block_border_color=None,
|
1211 |
+
# input_border_color='#4372c4',
|
1212 |
+
# panel_border_color='#4372c4',
|
1213 |
+
input_background_fill='#F1F2F4',
|
|
|
1214 |
)
|
1215 |
|
1216 |
with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS, delete_cache=(3600, 48 * 3600)) as demo:
|
|
|
1251 |
target_gene = gr.Textbox(
|
1252 |
show_label=False, visible=False,
|
1253 |
interactive=True, scale=4,
|
1254 |
+
info='Enter a gene symbol and query. The first record is used by default.')
|
1255 |
target_organism = gr.Textbox(
|
1256 |
info='Organism scientific name (default: Homo sapiens).',
|
1257 |
placeholder='Homo sapiens', show_label=False,
|
|
|
1297 |
)
|
1298 |
drug_screen_task = gr.Dropdown(
|
1299 |
list(TASK_MAP.keys()),
|
1300 |
+
label='Step 3. Select a Prediction Task',
|
1301 |
value='Compound-Protein Interaction')
|
1302 |
with gr.Column(min_width=200):
|
1303 |
HelpTip(
|
|
|
1369 |
info='Enter (paste) an SMILES string or upload an SDF file to convert to SMILES.',
|
1370 |
value='SMILES',
|
1371 |
interactive=True)
|
1372 |
+
compound_upload_btn = gr.UploadButton(
|
1373 |
+
label='OR Upload a SDF File', variant='primary', type='binary', visible=False)
|
1374 |
|
1375 |
compound_smiles = gr.Code(label='Input or Display Compound SMILES', interactive=True, lines=5)
|
1376 |
example_drug = gr.Button(value='Example: Aspirin', elem_classes='example')
|
|
|
1384 |
)
|
1385 |
target_identify_target_family = gr.Dropdown(
|
1386 |
choices=['General'], value='General',
|
1387 |
+
label='Target Family')
|
1388 |
|
1389 |
+
with gr.Row():
|
1390 |
+
with gr.Column():
|
1391 |
+
HelpTip(
|
1392 |
+
"Interaction prediction provides you binding probability score between the target of "
|
1393 |
+
"interest and each compound in the library, while affinity prediction directly "
|
1394 |
+
"estimates their binding strength measured using IC50."
|
1395 |
+
)
|
1396 |
+
target_identify_task = gr.Dropdown(
|
1397 |
+
list(TASK_MAP.keys()),
|
1398 |
+
label='Step 2. Select a Prediction Task',
|
1399 |
+
value='Compound-Protein Interaction')
|
1400 |
+
|
1401 |
+
with gr.Column():
|
1402 |
+
HelpTip(
|
1403 |
+
"Select your preferred model, or click Recommend for the best-performing model based "
|
1404 |
+
"on the selected task and whether the compound was trained. By default, General-trained "
|
1405 |
+
"model is used for Target Protein Identification. "
|
1406 |
+
"Please refer to the documentation for detailed benchmark results."
|
1407 |
+
)
|
1408 |
+
target_identify_preset = gr.Dropdown(
|
1409 |
+
list(PRESET_MAP.keys()),
|
1410 |
+
label='Step 3. Select a Preset Model')
|
1411 |
+
identify_preset_recommend_btn = gr.Button(value='OR Let Us Recommend for You',
|
1412 |
+
variant='primary')
|
1413 |
with gr.Row():
|
1414 |
with gr.Column():
|
1415 |
HelpTip(
|
|
|
1419 |
"Example CSV and SDF files are provided below "
|
1420 |
"and can be downloaded by clicking the lower right corner."
|
1421 |
)
|
1422 |
+
target_library = gr.Dropdown(
|
1423 |
+
label='Step 4. Select a Preset Target Library',
|
1424 |
+
choices=list(TARGET_LIBRARY_MAP.keys()))
|
1425 |
with gr.Row():
|
1426 |
gr.File(label='Example FASTA target library',
|
1427 |
value='data/examples/target_library.fasta', interactive=False)
|
|
|
1431 |
label='OR Upload Your Own Library', variant='primary')
|
1432 |
target_library_upload = gr.File(label='Custom target library file', visible=False)
|
1433 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1434 |
with gr.Row():
|
1435 |
with gr.Column():
|
1436 |
target_identify_email = gr.Textbox(
|
1437 |
+
label='Step 5. Input Your Email Address (Optional)',
|
1438 |
info="Your email address will be used to notify you of the status of your job. "
|
1439 |
"If you cannot receive the email, please check your spam/junk folder."
|
1440 |
)
|
|
|
1502 |
file_count="single", type='filepath')
|
1503 |
|
1504 |
with gr.Row():
|
1505 |
+
with gr.Column(min_width=200):
|
1506 |
HelpTip(
|
1507 |
"By default, models trained on all protein families (general) will be applied. "
|
1508 |
"If the proteins in the target library of interest "
|
1509 |
"all belong to the same protein family, manually selecting the family is supported."
|
1510 |
)
|
1511 |
+
pair_infer_target_family = gr.Dropdown(
|
1512 |
+
choices=list(TARGET_FAMILY_MAP.keys()),
|
1513 |
+
value='General',
|
1514 |
+
label='Step 2. Select Target Family (Optional)')
|
1515 |
|
1516 |
+
with gr.Column(min_width=200):
|
|
|
1517 |
HelpTip(
|
1518 |
"Interaction prediction provides you binding probability score "
|
1519 |
"between the target of interest and each compound in the library, "
|
|
|
1522 |
)
|
1523 |
pair_infer_task = gr.Dropdown(
|
1524 |
list(TASK_MAP.keys()),
|
1525 |
+
label='Step 3. Select a Prediction Task',
|
1526 |
value='Compound-Protein Interaction')
|
1527 |
|
1528 |
+
with gr.Column(min_width=200):
|
|
|
1529 |
HelpTip("Select your preferred model. "
|
1530 |
"Please refer to documentation for detailed benchmark results."
|
1531 |
)
|
1532 |
+
pair_infer_preset = gr.Dropdown(
|
1533 |
+
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 |
|
|
|
1601 |
if the job has completed. Note that predictions are only kept for 48 hours upon job completion.
|
1602 |
|
1603 |
You will be redirected to Chemical Property Report for carrying out further analysis and
|
1604 |
+
generating the full report if the job is done. If the Lookup fails to respond, please come back
|
1605 |
+
in five minutes, refresh the page, and try again.
|
1606 |
''')
|
1607 |
with gr.Column():
|
1608 |
pred_lookup_id = gr.Textbox(
|
|
|
1660 |
|
1661 |
|
1662 |
def uniprot_query(input_type, uid, gene, organism='Human'):
|
1663 |
+
fasta_rec = ''
|
1664 |
|
1665 |
match input_type:
|
1666 |
case 'UniProt ID':
|
|
|
1672 |
try:
|
1673 |
fasta = session.get(UNIPROT_ENDPOINT.format(query=query))
|
1674 |
fasta.raise_for_status()
|
1675 |
+
if fasta.text:
|
1676 |
+
fasta_rec = next(SeqIO.parse(io.StringIO(fasta.text), format='fasta'))
|
1677 |
+
fasta_rec = f"{fasta_rec.description}\n{fasta_rec.seq}"
|
1678 |
+
|
1679 |
except Exception as e:
|
1680 |
raise gr.Warning(f"Failed to query FASTA from UniProt database due to {str(e)}")
|
1681 |
finally:
|
1682 |
+
return fasta_rec
|
1683 |
|
1684 |
|
1685 |
def process_fasta_upload(fasta_upload):
|
|
|
1897 |
|
1898 |
infer_type.select(fn=infer_type_change, inputs=infer_type,
|
1899 |
outputs=[pair_upload, pair_generate, infer_pair, infer_drug, infer_target,
|
1900 |
+
infer_csv_prompt, infer_library_prompt],
|
1901 |
+
show_progress='hidden')
|
1902 |
|
1903 |
|
1904 |
def common_input_validate(state, preset, email, request):
|
1905 |
+
gr.Info('Start processing inputs...')
|
1906 |
if not preset:
|
1907 |
raise gr.Error('Please select a model.')
|
1908 |
|
|
|
1924 |
|
1925 |
|
1926 |
def common_job_initiate(job_id, job_type, email, request, task):
|
1927 |
+
gr.Info('Finished processing inputs. Initiating the prediction job... '
|
1928 |
'You will be redirected to Prediction Status Lookup after the job is submitted.')
|
1929 |
job_info = {'id': job_id,
|
1930 |
'type': job_type,
|
|
|
2072 |
inputs=[pred_lookup_id],
|
2073 |
outputs=[pred_lookup_status, pred_lookup_btn, pred_lookup_stop_btn, tabs, file_for_report],
|
2074 |
show_progress='minimal',
|
2075 |
+
concurrency_limit=100,
|
2076 |
)
|
2077 |
|
2078 |
drug_screen_click.success(
|
|
|
2156 |
inputs=[pred_lookup_id],
|
2157 |
outputs=[pred_lookup_status, pred_lookup_btn, pred_lookup_stop_btn, tabs, file_for_report],
|
2158 |
show_progress='minimal',
|
2159 |
+
cancels=[drug_screen_lookup, target_identify_lookup, pair_infer_lookup],
|
2160 |
concurrency_limit=100,
|
2161 |
)
|
2162 |
|
|
|
2202 |
)
|
2203 |
|
2204 |
file_for_report.clear(
|
2205 |
+
fn=lambda: [gr.Button(interactive=False)] * 3 +
|
2206 |
[gr.File(visible=False, value=None)] * 2 +
|
2207 |
[gr.Dropdown(visible=False, value=None),
|
2208 |
+
gr.HTML(visible=False)],
|
|
|
2209 |
outputs=[
|
2210 |
+
csv_generate, html_generate, analyze_btn, csv_download_file, html_download_file, report_task, html_report
|
2211 |
]
|
2212 |
)
|
2213 |
|
|
|
2259 |
|
2260 |
if __name__ == "__main__":
|
2261 |
hydra.initialize(version_base="1.3", config_path="configs", job_name="webserver_inference")
|
2262 |
+
demo.queue(default_concurrency_limit=None, max_size=10).launch(show_api=False)
|