igashov commited on
Commit
fd9834a
·
verified ·
1 Parent(s): 105febc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -55
app.py CHANGED
@@ -128,7 +128,7 @@ def show_input(in_fragments, in_protein):
128
  vis = show_target(in_protein)
129
  elif in_fragments is not None and in_protein is not None:
130
  vis = show_fragments_and_target(in_fragments, in_protein)
131
- return [vis, gr.Dropdown.update(choices=[], value=None, visible=False), None]
132
 
133
 
134
  def show_fragments(in_fragments):
@@ -170,14 +170,14 @@ def clear_fragments_input(in_protein):
170
  vis = ''
171
  if in_protein is not None:
172
  vis = show_target(in_protein)
173
- return [None, vis, gr.Dropdown.update(choices=[], value=None, visible=False), None]
174
 
175
 
176
  def clear_protein_input(in_fragments):
177
  vis = ''
178
  if in_fragments is not None:
179
  vis = show_fragments(in_fragments)
180
- return [None, vis, gr.Dropdown.update(choices=[], value=None, visible=False), None]
181
 
182
 
183
  def click_on_example(example):
@@ -347,7 +347,7 @@ def generate_without_pocket(input_file, n_steps, n_atoms, num_samples, selected_
347
  return [
348
  draw_sample(choice, out_files, num_samples),
349
  out_files,
350
- gr.Dropdown.update(
351
  choices=out_files[2:],
352
  value=choice,
353
  visible=True,
@@ -494,7 +494,7 @@ def generate_with_pocket(in_fragments, in_protein, n_steps, n_atoms, num_samples
494
  return [
495
  draw_sample(choice, out_files, num_samples),
496
  out_files,
497
- gr.Dropdown.update(
498
  choices=out_files[3:],
499
  value=choice,
500
  visible=True,
@@ -515,56 +515,55 @@ with gr.Blocks(js=output.STARTUP_JS) as demo:
515
  '[**[Paper]**](https://arxiv.org/abs/2210.05274) '
516
  '[**[Code]**](https://github.com/igashov/DiffLinker)'
517
  )
518
- with gr.Group():
519
- with gr.Row():
520
- with gr.Column():
521
- gr.Markdown('## Input')
522
- gr.Markdown('Upload the file with 3D-coordinates of the input fragments in .pdb, .mol2 or .sdf format:')
523
- input_fragments_file = gr.File(file_count='single', label='Input Fragments')
524
- gr.Markdown('Upload the file of the target protein in .pdb format (optionally):')
525
- input_protein_file = gr.File(file_count='single', label='Target Protein (Optional)')
526
-
527
- n_steps = gr.Slider(
528
- minimum=MIN_N_STEPS, maximum=MAX_N_STEPS,
529
- label="Number of Denoising Steps", step=10
530
- )
531
- n_atoms = gr.Slider(
532
- minimum=0, maximum=20,
533
- label="Linker Size: DiffLinker will predict it if set to 0",
534
- step=1
535
- )
536
- n_samples = gr.Slider(minimum=5, maximum=50, label="Number of Samples", step=5)
537
- examples = gr.Dataset(
538
- components=[gr.File(visible=False), gr.File(visible=False)],
539
- samples=[
540
- ['examples/example_1.sdf', ''],
541
- ['examples/example_2.sdf', ''],
542
- ['examples/3hz1_fragments.sdf', 'examples/3hz1_protein.pdb'],
543
- ['examples/5ou2_fragments.sdf', 'examples/5ou2_protein.pdb'],
544
- ],
545
- type='values',
546
- headers=['Input Fragments', 'Target Protein'],
547
- )
548
-
549
- button = gr.Button('Generate Linker!')
550
- gr.Markdown('')
551
- gr.Markdown('## Output Files')
552
- gr.Markdown('Download files with the generated molecules here:')
553
- output_files = gr.File(file_count='multiple', label='Output Files', interactive=False)
554
- hidden = gr.Textbox(visible=False)
555
- with gr.Column():
556
- gr.Markdown('## Visualization')
557
- gr.Markdown('**Hint:** click on atoms to select anchor points (optionally)')
558
- samples = gr.Dropdown(
559
- choices=[],
560
- value=None,
561
- type='value',
562
- multiselect=False,
563
- visible=False,
564
- interactive=True,
565
- label='Samples'
566
- )
567
- visualization = gr.HTML()
568
 
569
  input_fragments_file.change(
570
  fn=show_input,
 
128
  vis = show_target(in_protein)
129
  elif in_fragments is not None and in_protein is not None:
130
  vis = show_fragments_and_target(in_fragments, in_protein)
131
+ return [vis, gr.Dropdown(choices=[], value=None, visible=False), None]
132
 
133
 
134
  def show_fragments(in_fragments):
 
170
  vis = ''
171
  if in_protein is not None:
172
  vis = show_target(in_protein)
173
+ return [None, vis, gr.Dropdown(choices=[], value=None, visible=False), None]
174
 
175
 
176
  def clear_protein_input(in_fragments):
177
  vis = ''
178
  if in_fragments is not None:
179
  vis = show_fragments(in_fragments)
180
+ return [None, vis, gr.Dropdown(choices=[], value=None, visible=False), None]
181
 
182
 
183
  def click_on_example(example):
 
347
  return [
348
  draw_sample(choice, out_files, num_samples),
349
  out_files,
350
+ gr.Dropdown(
351
  choices=out_files[2:],
352
  value=choice,
353
  visible=True,
 
494
  return [
495
  draw_sample(choice, out_files, num_samples),
496
  out_files,
497
+ gr.Dropdown(
498
  choices=out_files[3:],
499
  value=choice,
500
  visible=True,
 
515
  '[**[Paper]**](https://arxiv.org/abs/2210.05274) '
516
  '[**[Code]**](https://github.com/igashov/DiffLinker)'
517
  )
518
+ with gr.Row():
519
+ with gr.Column():
520
+ gr.Markdown('## Input')
521
+ gr.Markdown('Upload the file with 3D-coordinates of the input fragments in .pdb, .mol2 or .sdf format:')
522
+ input_fragments_file = gr.File(file_count='single', label='Input Fragments')
523
+ gr.Markdown('Upload the file of the target protein in .pdb format (optionally):')
524
+ input_protein_file = gr.File(file_count='single', label='Target Protein (Optional)')
525
+
526
+ n_steps = gr.Slider(
527
+ minimum=MIN_N_STEPS, maximum=MAX_N_STEPS,
528
+ label="Number of Denoising Steps", step=10
529
+ )
530
+ n_atoms = gr.Slider(
531
+ minimum=0, maximum=20,
532
+ label="Linker Size: DiffLinker will predict it if set to 0",
533
+ step=1
534
+ )
535
+ n_samples = gr.Slider(minimum=5, maximum=50, label="Number of Samples", step=5)
536
+ examples = gr.Dataset(
537
+ components=[gr.File(visible=False), gr.File(visible=False)],
538
+ samples=[
539
+ ['examples/example_1.sdf', ''],
540
+ ['examples/example_2.sdf', ''],
541
+ ['examples/3hz1_fragments.sdf', 'examples/3hz1_protein.pdb'],
542
+ ['examples/5ou2_fragments.sdf', 'examples/5ou2_protein.pdb'],
543
+ ],
544
+ type='values',
545
+ headers=['Input Fragments', 'Target Protein'],
546
+ )
547
+
548
+ button = gr.Button('Generate Linker!')
549
+ gr.Markdown('')
550
+ gr.Markdown('## Output Files')
551
+ gr.Markdown('Download files with the generated molecules here:')
552
+ output_files = gr.File(file_count='multiple', label='Output Files', interactive=False)
553
+ hidden = gr.Textbox(visible=False)
554
+ with gr.Column():
555
+ gr.Markdown('## Visualization')
556
+ gr.Markdown('**Hint:** click on atoms to select anchor points (optionally)')
557
+ samples = gr.Dropdown(
558
+ choices=[],
559
+ value=None,
560
+ type='value',
561
+ multiselect=False,
562
+ visible=False,
563
+ interactive=True,
564
+ label='Samples'
565
+ )
566
+ visualization = gr.HTML()
 
567
 
568
  input_fragments_file.change(
569
  fn=show_input,