Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import spaces
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
from allmetal3d.utils.helpersNew import *
|
| 5 |
+
from allmetal3d.utils.main import predict, predict_cli, update_mode
|
| 6 |
+
|
| 7 |
+
from gradio_molecule3d import Molecule3D
|
| 8 |
+
|
| 9 |
+
@spaces.GPU
|
| 10 |
+
def predict_zero_gpu(pdb, models, pthreshold, threshold, batch_size, mode, central_residue, radius):
|
| 11 |
+
out, metal_pdb, metal_cube, water_pdb, water_cube, results_json, waters_json = predict(pdb, models, pthreshold, threshold, batch_size, mode, central_residue, radius)
|
| 12 |
+
|
| 13 |
+
with gr.Blocks() as blocks:
|
| 14 |
+
gr.Markdown("## AllMetal3D and Water3D")
|
| 15 |
+
pdb = Molecule3D(label="Input PDB", showviewer=False) #gr.File("2cba.pdb",label="Upload PDB file")
|
| 16 |
+
|
| 17 |
+
gr.Markdown("Metals might bind anywhere in the protein, choose how to sample the residues in the protein. <br>Fast uses blocked sampling of residues to reduce required computational time, full uses all residues, site allows you to look around a specific site in the protein")
|
| 18 |
+
with gr.Row("Prediction mode"):
|
| 19 |
+
mode = gr.Dropdown(["fast", "all", "site"], value="fast", label="Mode")
|
| 20 |
+
central_residue = gr.Textbox(label="Central residue", info="add multiple residues with space e.g 101 203", visible=False)
|
| 21 |
+
radius = gr.Slider(value=8, minimum=4, maximum=50, label="Distance threshold", visible=False)
|
| 22 |
+
mode.change(update_mode, mode, [central_residue, radius])
|
| 23 |
+
|
| 24 |
+
models = gr.Radio(["AllMetal3D + Water3D", "Only AllMetal3D", "Only Water3D"], value="AllMetal3D + Water3D", label="Which models to run?")
|
| 25 |
+
|
| 26 |
+
with gr.Accordion("Settings"):
|
| 27 |
+
threshold = gr.Slider(value=7,minimum=0, maximum=10, label="Threshold")
|
| 28 |
+
pthreshold = gr.Slider(value=0.25,minimum=0.1, maximum=1, label="Probability Threshold")
|
| 29 |
+
batch_size = gr.Slider(value=50, minimum=0, maximum=100, label="Batch Size")
|
| 30 |
+
|
| 31 |
+
btn = gr.Button("Predict")
|
| 32 |
+
|
| 33 |
+
with gr.Row():
|
| 34 |
+
metal_pdb = gr.File(label="predicted metals (PDB)", visible=False)
|
| 35 |
+
metal_cube = gr.File(label="predicted metal density (CUBE)",visible=False)
|
| 36 |
+
water_pdb = gr.File(label="predicted waters (PDB)", visible=False)
|
| 37 |
+
water_cube = gr.File(label="predicted water density (CUBE)", visible=False)
|
| 38 |
+
|
| 39 |
+
out = gr.HTML("")
|
| 40 |
+
results_json = gr.JSON(visible=False)
|
| 41 |
+
waters_json = gr.JSON(visible=False)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
btn.click(predict_zero_gpu, inputs=[pdb, models, pthreshold, threshold, batch_size, mode, central_residue, radius], outputs=[out, metal_pdb, metal_cube, water_pdb, water_cube, results_json, waters_json])
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
# in order to get private link for the app for the viewer we need to disable thread lock and grab the link
|
| 48 |
+
blocks.launch(allowed_paths=["frontend"])
|