Spaces:
Sleeping
Sleeping
Commit
·
ca33195
1
Parent(s):
ed63760
test
Browse files
app.py
CHANGED
|
@@ -108,20 +108,20 @@ def get_models(model_config, model_dir, checkpoint):
|
|
| 108 |
return model
|
| 109 |
|
| 110 |
def mbp_scoring(ligand_path, protein_path):
|
|
|
|
| 111 |
data_example = get_data(model_config, ligand_path, protein_path)
|
|
|
|
| 112 |
_, (affinity_pred_IC50, affinity_pred_K), _ = model(data_example, ASRP=False)
|
| 113 |
return affinity_pred_IC50.item(), affinity_pred_K.item()
|
| 114 |
|
| 115 |
|
| 116 |
def test(ligand, protein):
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
# except Exception as e:
|
| 124 |
-
# return e, e
|
| 125 |
|
| 126 |
with gr.Blocks() as demo:
|
| 127 |
ligand = gr.File(label="ligand")
|
|
@@ -132,9 +132,4 @@ with gr.Blocks() as demo:
|
|
| 132 |
submit_btn = gr.Button("Submit")
|
| 133 |
submit_btn.click(fn=test, inputs=[ligand, protein], outputs=[IC50, K], api_name="MBP_Scoring")
|
| 134 |
|
| 135 |
-
|
| 136 |
-
data_example = get_data(model_config, './workdir/gradio/1a0q_ligand.sdf', './workdir/gradio/1a0q_protein.pdb')
|
| 137 |
-
model = get_models(model_config, model_dir, checkpoint)
|
| 138 |
-
|
| 139 |
-
demo.launch()
|
| 140 |
-
|
|
|
|
| 108 |
return model
|
| 109 |
|
| 110 |
def mbp_scoring(ligand_path, protein_path):
|
| 111 |
+
model_config = get_config(model_dir)
|
| 112 |
data_example = get_data(model_config, ligand_path, protein_path)
|
| 113 |
+
model = get_models(model_config, model_dir, checkpoint)
|
| 114 |
_, (affinity_pred_IC50, affinity_pred_K), _ = model(data_example, ASRP=False)
|
| 115 |
return affinity_pred_IC50.item(), affinity_pred_K.item()
|
| 116 |
|
| 117 |
|
| 118 |
def test(ligand, protein):
|
| 119 |
+
try:
|
| 120 |
+
IC50, K = mbp_scoring(ligand.name, protein.name)
|
| 121 |
+
return '{:.2f}'.format(IC50), '{:.2f}'.format(K)
|
| 122 |
+
except Exception as e:
|
| 123 |
+
print(e)
|
| 124 |
+
return 'Please set input correctly', 'Please set input correctly'
|
|
|
|
|
|
|
| 125 |
|
| 126 |
with gr.Blocks() as demo:
|
| 127 |
ligand = gr.File(label="ligand")
|
|
|
|
| 132 |
submit_btn = gr.Button("Submit")
|
| 133 |
submit_btn.click(fn=test, inputs=[ligand, protein], outputs=[IC50, K], api_name="MBP_Scoring")
|
| 134 |
|
| 135 |
+
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|