simonduerr commited on
Commit
a69a846
1 Parent(s): 802eefc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -14
app.py CHANGED
@@ -11,7 +11,7 @@ import subprocess
11
  try:
12
  import torch_geometric
13
  except ImportError:
14
- subprocess.call(['pip', 'install', 'torch-scatter', 'torch-sparse', 'torch-cluster', 'torch-spline-conv', 'torch-geometric', '-f', 'https://data.pyg.org/whl/torch-1.12.0+cu102.html'])
15
 
16
  import time
17
  from argparse import ArgumentParser, Namespace, FileType
@@ -243,7 +243,7 @@ def esm(protein_path, out_file):
243
  )
244
 
245
 
246
- def update(inp, file, ligand_inp, ligand_file, n_it):
247
  pdb_path = get_pdb(inp, file)
248
  ligand_path = get_ligand(ligand_inp, ligand_file)
249
 
@@ -270,12 +270,12 @@ def update(inp, file, ligand_inp, ligand_file, n_it):
270
  [],
271
  [],
272
  )
273
- N = 10 # number of samples to generate
274
  protein_path_list = [pdb_path]
275
  ligand_descriptions = [ligand_path]
276
  no_random = False
277
  ode = False
278
- no_final_step_noise = False
279
  out_dir = "results/"
280
  test_dataset = PDBBind(
281
  transform=None,
@@ -382,7 +382,7 @@ def update(inp, file, ligand_inp, ligand_file, n_it):
382
  data_list, confidence = sampling(
383
  data_list=data_list,
384
  model=model,
385
- inference_steps=n_it,
386
  tr_schedule=tr_schedule,
387
  rot_schedule=rot_schedule,
388
  tor_schedule=tor_schedule,
@@ -518,9 +518,17 @@ with demo:
518
  label="SMILES string",
519
  )
520
  ligand_file = gr.File(file_count="single", label="Input Ligand")
521
- n_it = gr.Slider(
522
  minimum=10, maximum=40, label="Number of inference steps", step=1
523
  )
 
 
 
 
 
 
 
 
524
 
525
  btn = gr.Button("Run predictions")
526
 
@@ -537,52 +545,70 @@ with demo:
537
  "examples/6w70.pdb",
538
  "COc1ccc(cc1)n2c3c(c(n2)C(=O)N)CCN(C3=O)c4ccc(cc4)N5CCCCC5=O",
539
  "examples/6w70_ligand.sdf",
540
- 10,
 
 
 
541
  ],
542
  [
543
  "6moa",
544
  "examples/6moa_protein_processed.pdb",
545
  "",
546
  "examples/6moa_ligand.sdf",
547
- 10,
 
 
 
548
  ],
549
  [
550
  "",
551
  "examples/6o5u_protein_processed.pdb",
552
  "",
553
  "examples/6o5u_ligand.sdf",
554
- 10,
 
 
 
555
  ],
556
  [
557
  "",
558
  "examples/6o5u_protein_processed.pdb",
559
  "[NH3+]C[C@H]1O[C@H](O[C@@H]2[C@@H]([NH3+])C[C@H]([C@@H]([C@H]2O)O[C@H]2O[C@H](CO)[C@H]([C@@H]([C@H]2O)[NH3+])O)[NH3+])[C@@H]([C@H]([C@@H]1O)O)O",
560
  "examples/6o5u_ligand.sdf",
561
- 10,
 
 
 
562
  ],
563
  [
564
  "",
565
  "examples/6o5u_protein_processed.pdb",
566
  "",
567
  "examples/6o5u_ligand.sdf",
568
- 10,
 
 
 
569
  ],
570
  [
571
  "",
572
  "examples/6ahs_protein_processed.pdb",
573
  "",
574
  "examples/6ahs_ligand.sdf",
575
- 10,
 
 
 
576
  ],
577
  ],
578
- [inp, file, ligand_inp, ligand_file, n_it],
579
  [mol, out, filenames, pdb, output_file],
580
  # fn=update,
581
  # cache_examples=True,
582
  )
583
  btn.click(
584
  fn=update,
585
- inputs=[inp, file, ligand_inp, ligand_file, n_it],
586
  outputs=[mol, out, filenames, pdb, output_file],
587
  )
588
  out.change(fn=updateView, inputs=[out, filenames, pdb, ligand_file], outputs=mol)
 
11
  try:
12
  import torch_geometric
13
  except ImportError:
14
+ subprocess.call(['pip', 'install', 'torch-scatter', 'torch-sparse', 'torch-cluster', 'torch-spline-conv', 'torch-geometric', '-f', 'https://data.pyg.org/whl/torch-1.12.0+cu113.html'])
15
 
16
  import time
17
  from argparse import ArgumentParser, Namespace, FileType
 
243
  )
244
 
245
 
246
+ def update(inp, file, ligand_inp, ligand_file, n_it, n_samples, actual_steps, no_final_step_noise):
247
  pdb_path = get_pdb(inp, file)
248
  ligand_path = get_ligand(ligand_inp, ligand_file)
249
 
 
270
  [],
271
  [],
272
  )
273
+ N = n_samples # number of samples to generate
274
  protein_path_list = [pdb_path]
275
  ligand_descriptions = [ligand_path]
276
  no_random = False
277
  ode = False
278
+ no_final_step_noise = no_final_step_noise
279
  out_dir = "results/"
280
  test_dataset = PDBBind(
281
  transform=None,
 
382
  data_list, confidence = sampling(
383
  data_list=data_list,
384
  model=model,
385
+ inference_steps=actual_steps,
386
  tr_schedule=tr_schedule,
387
  rot_schedule=rot_schedule,
388
  tor_schedule=tor_schedule,
 
518
  label="SMILES string",
519
  )
520
  ligand_file = gr.File(file_count="single", label="Input Ligand")
521
+ n_it = gr.Slider(value=20,
522
  minimum=10, maximum=40, label="Number of inference steps", step=1
523
  )
524
+ actual_steps = gr.Slider(value=18,
525
+ minimum=10, maximum=40, label="Number of actual inference steps", step=1
526
+ )
527
+ n_samples = gr.Slider(value=40,
528
+ minimum=10, maximum=40, label="Number of samples", step=1
529
+ )
530
+ no_final_step_noise = gr.Checkbox(value=True,label="No final step noise"
531
+ )
532
 
533
  btn = gr.Button("Run predictions")
534
 
 
545
  "examples/6w70.pdb",
546
  "COc1ccc(cc1)n2c3c(c(n2)C(=O)N)CCN(C3=O)c4ccc(cc4)N5CCCCC5=O",
547
  "examples/6w70_ligand.sdf",
548
+ 20,
549
+ 40,
550
+ 18,
551
+ True
552
  ],
553
  [
554
  "6moa",
555
  "examples/6moa_protein_processed.pdb",
556
  "",
557
  "examples/6moa_ligand.sdf",
558
+ 20,
559
+ 40,
560
+ 18,
561
+ True
562
  ],
563
  [
564
  "",
565
  "examples/6o5u_protein_processed.pdb",
566
  "",
567
  "examples/6o5u_ligand.sdf",
568
+ 20,
569
+ 40,
570
+ 18,
571
+ True
572
  ],
573
  [
574
  "",
575
  "examples/6o5u_protein_processed.pdb",
576
  "[NH3+]C[C@H]1O[C@H](O[C@@H]2[C@@H]([NH3+])C[C@H]([C@@H]([C@H]2O)O[C@H]2O[C@H](CO)[C@H]([C@@H]([C@H]2O)[NH3+])O)[NH3+])[C@@H]([C@H]([C@@H]1O)O)O",
577
  "examples/6o5u_ligand.sdf",
578
+ 20,
579
+ 40,
580
+ 18,
581
+ True
582
  ],
583
  [
584
  "",
585
  "examples/6o5u_protein_processed.pdb",
586
  "",
587
  "examples/6o5u_ligand.sdf",
588
+ 20,
589
+ 40,
590
+ 18,
591
+ True
592
  ],
593
  [
594
  "",
595
  "examples/6ahs_protein_processed.pdb",
596
  "",
597
  "examples/6ahs_ligand.sdf",
598
+ 20,
599
+ 40,
600
+ 18,
601
+ True
602
  ],
603
  ],
604
+ [inp, file, ligand_inp, ligand_file, n_it, n_samples, actual_steps, no_final_step_noise],
605
  [mol, out, filenames, pdb, output_file],
606
  # fn=update,
607
  # cache_examples=True,
608
  )
609
  btn.click(
610
  fn=update,
611
+ inputs=[inp, file, ligand_inp, ligand_file, n_it, n_samples, actual_steps, no_final_step_noise],
612
  outputs=[mol, out, filenames, pdb, output_file],
613
  )
614
  out.change(fn=updateView, inputs=[out, filenames, pdb, ligand_file], outputs=mol)