Spaces:
Sleeping
Sleeping
Minor bug fixes
Browse files
app/main.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import spaces
|
2 |
|
3 |
import os
|
@@ -427,81 +429,82 @@ with gr.Blocks(theme=THEME, title='GenFBDD', css=static.CSS, delete_cache=(3600,
|
|
427 |
value='Extract Pocket', variant='primary', interactive=True
|
428 |
)
|
429 |
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
)
|
438 |
-
|
439 |
-
|
440 |
-
label="
|
441 |
interactive=True
|
442 |
)
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
|
|
|
|
|
|
|
|
|
|
463 |
)
|
464 |
-
|
465 |
-
|
466 |
-
label="
|
|
|
467 |
interactive=True
|
468 |
)
|
469 |
-
|
470 |
-
|
471 |
-
label="Number of
|
472 |
interactive=True
|
473 |
)
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
interactive=True
|
485 |
-
)
|
486 |
-
link_steps = gr.Slider(
|
487 |
-
minimum=100, maximum=500, step=10,
|
488 |
-
label="Number of Denoising Steps for Generating Linkers",
|
489 |
-
interactive=True
|
490 |
-
)
|
491 |
-
with gr.Row(equal_height=True):
|
492 |
-
email_input =gr.Textbox(
|
493 |
-
label='Email Address (Optional)',
|
494 |
-
info="Your email address will be used to notify you of the status of your job. "
|
495 |
-
"If you cannot receive the email, please check your spam/junk folder.",
|
496 |
-
type='email'
|
497 |
)
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
run_btn = gr.Button(
|
503 |
-
value='Run GenFBDD', variant='primary', interactive=True,
|
504 |
-
)
|
505 |
with gr.Tab(label='Results', id='result'):
|
506 |
# Results
|
507 |
result_state = gr.State(value={})
|
@@ -787,6 +790,7 @@ with gr.Blocks(theme=THEME, title='GenFBDD', css=static.CSS, delete_cache=(3600,
|
|
787 |
pred_lookup_example.click(
|
788 |
fn=lambda: '80cf2658-7a1c-48d6-8372-61b978177fe6',
|
789 |
outputs=[pred_lookup_id],
|
|
|
790 |
).success(
|
791 |
fn=query_job_status,
|
792 |
inputs=pred_lookup_id,
|
@@ -881,20 +885,24 @@ with gr.Blocks(theme=THEME, title='GenFBDD', css=static.CSS, delete_cache=(3600,
|
|
881 |
|
882 |
def generate_result_zip(result_info, compound_mod_df, protein_file):
|
883 |
result_path = Path(result_info['output_dir'])
|
884 |
-
|
885 |
-
|
|
|
886 |
cols_to_drop = ['mol', 'Compound', 'protein_path']
|
887 |
compound_mod_df.drop(columns=[col for col in cols_to_drop if col in compound_mod_df.columns], inplace=True)
|
888 |
compound_mod_df.rename(columns=fn.COL_ALIASES, inplace=True)
|
889 |
-
compound_mod_df.to_csv(result_path / f'{result_info["type"]}_summary.csv', index=False)
|
890 |
|
891 |
with zipfile.ZipFile(zip_path, 'w') as zip_file:
|
892 |
for file in result_path.rglob('*'):
|
893 |
-
|
|
|
894 |
archive_path = file.relative_to(result_path)
|
895 |
zip_file.write(file, arcname=archive_path)
|
896 |
if Path(protein_file).name not in zip_file.namelist():
|
897 |
zip_file.write(Path(protein_file), arcname=Path(protein_file).name)
|
|
|
|
|
|
|
898 |
|
899 |
return gr.File(str(zip_path), visible=True)
|
900 |
|
|
|
1 |
+
import io
|
2 |
+
|
3 |
import spaces
|
4 |
|
5 |
import os
|
|
|
429 |
value='Extract Pocket', variant='primary', interactive=True
|
430 |
)
|
431 |
|
432 |
+
with gr.Row():
|
433 |
+
with gr.Column(variant='panel'):
|
434 |
+
gr.Markdown('## Dock Phase Settings')
|
435 |
+
dock_n_poses = gr.Slider(
|
436 |
+
value=5, minimum=1, maximum=20, step=1,
|
437 |
+
label="Number of conformers to generate per fragment",
|
438 |
+
interactive=True
|
439 |
+
)
|
440 |
+
dock_confidence_cutoff = gr.Slider(
|
441 |
+
value=-1.0, minimum=-2.0, maximum=0, step=0.1,
|
442 |
+
label="Confidence cutoff for filtering conformers of docked fragments (>0: high, <=-1.5: low)",
|
443 |
+
interactive=True
|
444 |
+
)
|
445 |
+
with gr.Accordion(label='Advanced Options', open=False):
|
446 |
+
dock_model = gr.Dropdown(
|
447 |
+
label='Select a Fragment Docking Model',
|
448 |
+
choices=['DiffDock-L'],
|
449 |
+
interactive=True,
|
450 |
)
|
451 |
+
dock_steps = gr.Slider(
|
452 |
+
minimum=20, maximum=40, step=1,
|
453 |
+
label="Number of Denoising Steps for Docking Fragments",
|
454 |
interactive=True
|
455 |
)
|
456 |
+
with gr.Column(variant='panel'):
|
457 |
+
gr.Markdown('## Link Phase Settings')
|
458 |
+
link_frag_pose_strategy = gr.Radio(
|
459 |
+
label='Select a Fragment-Conformer Linking Strategy',
|
460 |
+
choices=[
|
461 |
+
'Link Pairs of Fragment-Conformers Contacting the Pocket',
|
462 |
+
# 'Link Maximal Fragment-Conformers Spanning the Entire Pocket',
|
463 |
+
],
|
464 |
+
value='Link Pairs of Fragment-Conformers Contacting the Pocket',
|
465 |
+
)
|
466 |
+
link_frag_dist_range = RangeSlider(
|
467 |
+
value=[2, 8], minimum=1, maximum=10, step=1,
|
468 |
+
label="Fragment-Conformer Distance Range (Å) Eligible for Linking",
|
469 |
+
interactive=True
|
470 |
+
)
|
471 |
+
link_n_mols = gr.Slider(
|
472 |
+
value=10, minimum=1, maximum=20, step=1,
|
473 |
+
label="Number of molecules to generate per fragment conformer combination",
|
474 |
+
interactive=True
|
475 |
+
)
|
476 |
+
with gr.Accordion(label='Advanced Options', open=False):
|
477 |
+
link_model = gr.Dropdown(
|
478 |
+
label='Select a Linker Generation Model',
|
479 |
+
choices=['DiffLinker'],
|
480 |
+
interactive=True,
|
481 |
)
|
482 |
+
link_linker_size = gr.Slider(
|
483 |
+
minimum=0, maximum=20, step=1,
|
484 |
+
label="Linker Size",
|
485 |
+
info="0: automatically predicted; >=1: fixed size",
|
486 |
interactive=True
|
487 |
)
|
488 |
+
link_steps = gr.Slider(
|
489 |
+
minimum=100, maximum=500, step=10,
|
490 |
+
label="Number of Denoising Steps for Generating Linkers",
|
491 |
interactive=True
|
492 |
)
|
493 |
+
with gr.Row(equal_height=True):
|
494 |
+
email_input =gr.Textbox(
|
495 |
+
label='Email Address (Optional)',
|
496 |
+
info="Your email address will be used to notify you of the status of your job. "
|
497 |
+
"If you cannot receive the email, please check your spam/junk folder.",
|
498 |
+
type='email'
|
499 |
+
)
|
500 |
+
with gr.Column():
|
501 |
+
start_clr_btn = gr.ClearButton(
|
502 |
+
value='Reset Inputs', interactive=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
)
|
504 |
+
run_btn = gr.Button(
|
505 |
+
value='Run GenFBDD', variant='primary', interactive=True,
|
506 |
+
)
|
507 |
+
|
|
|
|
|
|
|
508 |
with gr.Tab(label='Results', id='result'):
|
509 |
# Results
|
510 |
result_state = gr.State(value={})
|
|
|
790 |
pred_lookup_example.click(
|
791 |
fn=lambda: '80cf2658-7a1c-48d6-8372-61b978177fe6',
|
792 |
outputs=[pred_lookup_id],
|
793 |
+
show_progress='hidden'
|
794 |
).success(
|
795 |
fn=query_job_status,
|
796 |
inputs=pred_lookup_id,
|
|
|
885 |
|
886 |
def generate_result_zip(result_info, compound_mod_df, protein_file):
|
887 |
result_path = Path(result_info['output_dir'])
|
888 |
+
zip_filename = f'GenFBDD_{result_path.name}.zip'
|
889 |
+
summary_filename = f'{result_info["type"]}_summary.csv'
|
890 |
+
zip_path = result_path / zip_filename
|
891 |
cols_to_drop = ['mol', 'Compound', 'protein_path']
|
892 |
compound_mod_df.drop(columns=[col for col in cols_to_drop if col in compound_mod_df.columns], inplace=True)
|
893 |
compound_mod_df.rename(columns=fn.COL_ALIASES, inplace=True)
|
|
|
894 |
|
895 |
with zipfile.ZipFile(zip_path, 'w') as zip_file:
|
896 |
for file in result_path.rglob('*'):
|
897 |
+
# Skip directories, the zip file itself and the new summary file
|
898 |
+
if file.is_file() and file.name not in [zip_filename, summary_filename]:
|
899 |
archive_path = file.relative_to(result_path)
|
900 |
zip_file.write(file, arcname=archive_path)
|
901 |
if Path(protein_file).name not in zip_file.namelist():
|
902 |
zip_file.write(Path(protein_file), arcname=Path(protein_file).name)
|
903 |
+
csv_buffer = io.BytesIO()
|
904 |
+
compound_mod_df.to_csv(csv_buffer, index=False)
|
905 |
+
zip_file.writestr(summary_filename, csv_buffer.getvalue())
|
906 |
|
907 |
return gr.File(str(zip_path), visible=True)
|
908 |
|
inference.py
CHANGED
@@ -757,7 +757,7 @@ def select_fragment_pairs(
|
|
757 |
combined_mol = Chem.CombineMols(row1['ligand_mol'], row2['ligand_mol'])
|
758 |
complex_name = f"{protein_id}-{row1['ID1']}-{row2['ID1']}"
|
759 |
if 'ligand_conf_path' in row1 and 'ligand_conf_path' in row2:
|
760 |
-
fragment_path = [row1['ligand_conf_path'], row2['ligand_conf_path']]
|
761 |
protein_fragment_conf_pairs.append(
|
762 |
(complex_name, protein_path, # pocket_path,
|
763 |
combined_smiles, fragment_path, combined_mol, dist)
|
@@ -978,7 +978,7 @@ def generate_linkers(
|
|
978 |
if 'protein_path' not in df.columns:
|
979 |
df['protein_path'] = df['X2']
|
980 |
if 'name' not in df.columns and 'ID1' in df.columns and 'ID2' in df.columns:
|
981 |
-
df['name'] = df['
|
982 |
df.dropna(subset=['fragment_mol', 'protein_path'], inplace=True)
|
983 |
|
984 |
cached_parse_molecule = cache(parse_molecule)
|
|
|
757 |
combined_mol = Chem.CombineMols(row1['ligand_mol'], row2['ligand_mol'])
|
758 |
complex_name = f"{protein_id}-{row1['ID1']}-{row2['ID1']}"
|
759 |
if 'ligand_conf_path' in row1 and 'ligand_conf_path' in row2:
|
760 |
+
fragment_path = [row1['ligand_conf_path'].name, row2['ligand_conf_path'].name]
|
761 |
protein_fragment_conf_pairs.append(
|
762 |
(complex_name, protein_path, # pocket_path,
|
763 |
combined_smiles, fragment_path, combined_mol, dist)
|
|
|
978 |
if 'protein_path' not in df.columns:
|
979 |
df['protein_path'] = df['X2']
|
980 |
if 'name' not in df.columns and 'ID1' in df.columns and 'ID2' in df.columns:
|
981 |
+
df['name'] = df['ID1'] + '-' + df['ID2']
|
982 |
df.dropna(subset=['fragment_mol', 'protein_path'], inplace=True)
|
983 |
|
984 |
cached_parse_molecule = cache(parse_molecule)
|
results/2025-01-01_01-01-01_80cf2658-7a1c-48d6-8372-61b978177fe6/linking_summary.csv
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
name,fragment_path,X1,X1^,out_path
|
2 |
-
1xkk-frag_6_0-frag_9_0,"[
|
3 |
-
1xkk-frag_6_0-frag_1_0,"[
|
4 |
-
1xkk-frag_6_0-frag_7_0,"[
|
5 |
-
1xkk-frag_3_0-frag_4_0,"[
|
6 |
-
1xkk-frag_3_0-frag_9_0,"[
|
7 |
-
1xkk-frag_3_0-frag_1_0,"[
|
|
|
1 |
name,fragment_path,X1,X1^,out_path
|
2 |
+
1xkk-frag_6_0-frag_9_0,"['results/2025-01-05_11-14-29.222981/docking/1xkk-frag_6_0-confidence-0.98.sdf', 'results/2025-01-05_11-14-29.222981/docking/1xkk-frag_9_0-confidence-1.02.sdf']",C1CCNCC1.Oc1ccccc1O,[C][C](Oc1[c][c][c][c]c1[O])C(=O)[N][C][C]N1[C][C][C][C][C]1,1xkk-frag_6_0-frag_9_0_0.sdf
|
3 |
+
1xkk-frag_6_0-frag_1_0,"['results/2025-01-05_11-14-29.222981/docking/1xkk-frag_6_0-confidence-0.98.sdf', 'results/2025-01-05_11-14-29.222981/docking/1xkk-frag_1_0-confidence0.01.sdf']",C1CCNCC1.c1ccc2ncncc2c1,[O][C][C]c1n[c]c2[c][c][c]c([C]3[C][C][C][N][C]3)c2n1,1xkk-frag_6_0-frag_1_0_0.sdf
|
4 |
+
1xkk-frag_6_0-frag_7_0,"['results/2025-01-05_11-14-29.222981/docking/1xkk-frag_6_0-confidence-0.98.sdf', 'results/2025-01-05_11-14-29.222981/docking/1xkk-frag_7_0-confidence0.25.sdf']",C1CCNCC1.c1ncc2cc[nH]c2n1,[C][C][C]C1=N[C]c2[c][c]n([C]3[C][C][C][N][C]3)c2[N]1,1xkk-frag_6_0-frag_7_0_0.sdf
|
5 |
+
1xkk-frag_3_0-frag_4_0,"['results/2025-01-05_11-14-29.222981/docking/1xkk-frag_3_0-confidence-1.00.sdf', 'results/2025-01-05_11-14-29.222981/docking/1xkk-frag_4_0-confidence-0.21.sdf']",C=CC=O.CN1CCNCC1,[C]N1[C][C][N][C][C]1[C]C#C/[C]=[C]/[C]/[C]=[C]\C(=O)[C]=[C],1xkk-frag_3_0-frag_4_0_0.sdf
|
6 |
+
1xkk-frag_3_0-frag_9_0,"['results/2025-01-05_11-14-29.222981/docking/1xkk-frag_3_0-confidence-1.00.sdf', 'results/2025-01-05_11-14-29.222981/docking/1xkk-frag_9_0-confidence-1.02.sdf']",C=CC=O.Oc1ccccc1O,[C][C](C(=O)[C]=[C])N1[C][C][C](C2=N[C]=C([N]C(=O)[N]c3[c][c]c([O])c([O])[c]3)[C]2)O[C]1,1xkk-frag_3_0-frag_9_0_0.sdf
|
7 |
+
1xkk-frag_3_0-frag_1_0,"['results/2025-01-05_11-14-29.222981/docking/1xkk-frag_3_0-confidence-1.00.sdf', 'results/2025-01-05_11-14-29.222981/docking/1xkk-frag_1_0-confidence0.01.sdf']",C=CC=O.c1ccc2ncncc2c1,O=[C][C][C]C#C[C][C]c1[c][c]c2[c]n[c]nc2[c]1,1xkk-frag_3_0-frag_1_0_0.sdf
|