simonduerr commited on
Commit
1a5f3ab
1 Parent(s): 4e14aa0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -21,7 +21,7 @@ import moleculekit
21
  print(moleculekit.__version__)
22
 
23
 
24
- def update(inp, file, mode):
25
  try:
26
  pdb_file = file.name
27
  except:
@@ -54,9 +54,11 @@ def update(inp, file, mode):
54
  ids = get_all_protein_resids(
55
  f"files/{pdb_file}.pdb",
56
  )
 
 
57
  else:
58
  ids = get_all_metalbinding_resids(f"files/{pdb_file}.pdb")
59
-
60
  voxels, prot_centers, prot_N, prots = processStructures(pdb_file, ids)
61
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
62
  voxels.to(device)
@@ -89,7 +91,7 @@ def update(inp, file, mode):
89
  writeprobes=True,
90
  probefile=f"output/probes_{pdb_file}.pdb",
91
  threshold=7,
92
- p=0.15,
93
  )
94
 
95
  return message, molecule(
@@ -231,7 +233,7 @@ metal3d = gr.Blocks()
231
  with metal3d:
232
  gr.Markdown("# Metal3D")
233
  with gr.Tabs():
234
- with gr.TabItem("App"):
235
  inp = gr.Textbox( placeholder="PDB Code or Uniprot identifier or upload file below", label="Input molecule"
236
  )
237
  file = gr.File(file_count="single", type="file")
@@ -243,7 +245,9 @@ with metal3d:
243
  label="Residues to use for prediction",
244
  )
245
  custom_resids = gr.Textbox(placeholder="Comma separated list of residues", label="Custom residues")
246
- gr.Slider(minimum=0.15,maximum=1, value=0.15, label="Clustering threshold")
 
 
247
  btn = gr.Button("Run")
248
  gr.Markdown(
249
  """ <small>Inference using CPU-only, can be quite slow for more than 20 residues. Use Colab notebook for GPU acceleration</small>
@@ -254,7 +258,7 @@ with metal3d:
254
  gr.Markdown("# Output")
255
  out = gr.Textbox(label="status")
256
  mol = gr.HTML()
257
- btn.click(fn=update, inputs=[inp, file, mode], outputs=[out, mol])
258
 
259
  metal3d.launch()
260
 
 
21
  print(moleculekit.__version__)
22
 
23
 
24
+ def update(inp, file, mode, custom_resids, clustering_threshold):
25
  try:
26
  pdb_file = file.name
27
  except:
 
54
  ids = get_all_protein_resids(
55
  f"files/{pdb_file}.pdb",
56
  )
57
+ elif len(custom_resids)!=0:
58
+ ids = [int(x) for x in custom_resids.split(',')]
59
  else:
60
  ids = get_all_metalbinding_resids(f"files/{pdb_file}.pdb")
61
+
62
  voxels, prot_centers, prot_N, prots = processStructures(pdb_file, ids)
63
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
64
  voxels.to(device)
 
91
  writeprobes=True,
92
  probefile=f"output/probes_{pdb_file}.pdb",
93
  threshold=7,
94
+ p=clustering_threshold,
95
  )
96
 
97
  return message, molecule(
 
233
  with metal3d:
234
  gr.Markdown("# Metal3D")
235
  with gr.Tabs():
236
+ with gr.TabItem("Input"):
237
  inp = gr.Textbox( placeholder="PDB Code or Uniprot identifier or upload file below", label="Input molecule"
238
  )
239
  file = gr.File(file_count="single", type="file")
 
245
  label="Residues to use for prediction",
246
  )
247
  custom_resids = gr.Textbox(placeholder="Comma separated list of residues", label="Custom residues")
248
+ with gr.Row():
249
+ clustering_threshold = gr.Slider(minimum=0.15,maximum=1, value=0.15,step=0.05, label="Clustering threshold")
250
+ distance_cutoff = gr.Slider(minimum=1,maximum=10, value=7,step=1, label="Clustering distance cutoff")
251
  btn = gr.Button("Run")
252
  gr.Markdown(
253
  """ <small>Inference using CPU-only, can be quite slow for more than 20 residues. Use Colab notebook for GPU acceleration</small>
 
258
  gr.Markdown("# Output")
259
  out = gr.Textbox(label="status")
260
  mol = gr.HTML()
261
+ btn.click(fn=update, inputs=[inp, file, mode, custom_resids, clustering_threshold], outputs=[out, mol])
262
 
263
  metal3d.launch()
264