Spaces:
Sleeping
Sleeping
Update inference_app.py
Browse files- inference_app.py +19 -3
inference_app.py
CHANGED
|
@@ -7,17 +7,33 @@ import gradio as gr
|
|
| 7 |
from gradio_molecule3d import Molecule3D
|
| 8 |
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
def predict (input_seq_1, input_msa_1, input_protein_1, input_seq_2,input_msa_2, input_protein_2):
|
| 13 |
start_time = time.time()
|
| 14 |
# Do inference here
|
|
|
|
| 15 |
# return an output pdb file with the protein and two chains A and B.
|
|
|
|
|
|
|
| 16 |
# also return a JSON with any metrics you want to report
|
| 17 |
-
metrics = {"
|
|
|
|
| 18 |
end_time = time.time()
|
| 19 |
run_time = end_time - start_time
|
| 20 |
-
return
|
| 21 |
|
| 22 |
with gr.Blocks() as app:
|
| 23 |
|
|
@@ -55,7 +71,7 @@ with gr.Blocks() as app:
|
|
| 55 |
|
| 56 |
],
|
| 57 |
],
|
| 58 |
-
[input_seq_1, input_protein_1, input_seq_2,
|
| 59 |
)
|
| 60 |
reps = [
|
| 61 |
{
|
|
|
|
| 7 |
from gradio_molecule3d import Molecule3D
|
| 8 |
|
| 9 |
|
| 10 |
+
import numpy as np
|
| 11 |
+
from biotite.structure.io.pdb import PDBFile
|
| 12 |
+
|
| 13 |
+
def set_all_to_zero(input_pdb_file_1, input_pdb_file_2, output_file):
|
| 14 |
+
structure1 = PDBFile.read(input_pdb_file_1).get_structure()
|
| 15 |
+
structure2 = PDBFile.read(input_pdb_file_2).get_structure()
|
| 16 |
+
structure1.coord = np.zeros_like(structure1.coord)
|
| 17 |
+
structure2.coord = np.zeros_like(structure2.coord)
|
| 18 |
+
out_structure = structure1 + structure2
|
| 19 |
+
file = PDBFile()
|
| 20 |
+
file.set_structure(out_structure)
|
| 21 |
+
file.write(output_file)
|
| 22 |
|
| 23 |
|
| 24 |
def predict (input_seq_1, input_msa_1, input_protein_1, input_seq_2,input_msa_2, input_protein_2):
|
| 25 |
start_time = time.time()
|
| 26 |
# Do inference here
|
| 27 |
+
|
| 28 |
# return an output pdb file with the protein and two chains A and B.
|
| 29 |
+
output_file = "test_out.pdb"
|
| 30 |
+
set_all_to_zero(input_protein_1, input_protein_2, output_file)
|
| 31 |
# also return a JSON with any metrics you want to report
|
| 32 |
+
metrics = {"F_nat": 100}
|
| 33 |
+
|
| 34 |
end_time = time.time()
|
| 35 |
run_time = end_time - start_time
|
| 36 |
+
return output_file, json.dumps(metrics), run_time
|
| 37 |
|
| 38 |
with gr.Blocks() as app:
|
| 39 |
|
|
|
|
| 71 |
|
| 72 |
],
|
| 73 |
],
|
| 74 |
+
[input_seq_1, input_protein_1, input_seq_2, input_protein_2],
|
| 75 |
)
|
| 76 |
reps = [
|
| 77 |
{
|