Spaces:
Runtime error
Runtime error
Jacob Silterra
commited on
Commit
·
e533974
1
Parent(s):
90ab2dd
Switch to gradio UI
Browse files
app.py
DELETED
|
@@ -1,35 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
|
| 3 |
-
# Create the Streamlit app
|
| 4 |
-
st.title("DiffDock Pocket: Protein-Ligand Interaction Calculator")
|
| 5 |
-
|
| 6 |
-
# Create a form block
|
| 7 |
-
with st.form(key="calculation_form"):
|
| 8 |
-
# File upload for Protein PDB
|
| 9 |
-
protein_pdb = st.file_uploader("Protein PDB", type=["pdb"])
|
| 10 |
-
|
| 11 |
-
# File upload for Ligand SDF
|
| 12 |
-
ligand_sdf = st.file_uploader("Ligand SDF", type=["sdf"])
|
| 13 |
-
|
| 14 |
-
# Numeric input for "Samples per Complex"
|
| 15 |
-
samples_per_complex = st.number_input("Samples per Complex", min_value=1, max_value=100, value=4, step=1)
|
| 16 |
-
|
| 17 |
-
# Boolean checkbox for "Keep Local Structures"
|
| 18 |
-
keep_local_structures = st.checkbox("Keep Local Structures", value=True)
|
| 19 |
-
|
| 20 |
-
# Boolean checkbox for "Save Visualization"
|
| 21 |
-
save_visualization = st.checkbox("Save Visualization", value=True)
|
| 22 |
-
|
| 23 |
-
# Submit button
|
| 24 |
-
submit_button = st.form_submit_button("Calculate")
|
| 25 |
-
|
| 26 |
-
if submit_button:
|
| 27 |
-
# Implement your calculation logic here
|
| 28 |
-
st.write("TODO Calculating... (Add your implementation logic)")
|
| 29 |
-
|
| 30 |
-
# For demonstration purposes, display the user inputs
|
| 31 |
-
st.write(f"Protein PDB File: {protein_pdb}")
|
| 32 |
-
st.write(f"Ligand SDF File: {ligand_sdf}")
|
| 33 |
-
st.write(f"Samples per Complex: {samples_per_complex}")
|
| 34 |
-
st.write(f"Keep Local Structures: {keep_local_structures}")
|
| 35 |
-
st.write(f"Save Visualization: {save_visualization}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main.py
CHANGED
|
@@ -8,7 +8,7 @@ response = requests.get("https://git.io/JJkYN")
|
|
| 8 |
labels = response.text.split("\n")
|
| 9 |
|
| 10 |
|
| 11 |
-
def predict(inp):
|
| 12 |
inp = transforms.ToTensor()(inp).unsqueeze(0)
|
| 13 |
with torch.no_grad():
|
| 14 |
prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
|
|
@@ -16,15 +16,29 @@ def predict(inp):
|
|
| 16 |
return confidences
|
| 17 |
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
def run():
|
| 20 |
-
|
| 21 |
-
fn=
|
| 22 |
-
inputs=
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
)
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
| 30 |
-
run()
|
|
|
|
| 8 |
labels = response.text.split("\n")
|
| 9 |
|
| 10 |
|
| 11 |
+
def predict(inp, *args, **kwargs):
|
| 12 |
inp = transforms.ToTensor()(inp).unsqueeze(0)
|
| 13 |
with torch.no_grad():
|
| 14 |
prediction = torch.nn.functional.softmax(model(inp)[0], dim=0)
|
|
|
|
| 16 |
return confidences
|
| 17 |
|
| 18 |
|
| 19 |
+
def calculate(*args, **kwargs) -> str:
|
| 20 |
+
output_file_path = "main_output.txt"
|
| 21 |
+
with open(output_file_path, "w") as fi:
|
| 22 |
+
fi.write(f"args: {args}\n")
|
| 23 |
+
fi.write(f"kwargs: {kwargs}\n")
|
| 24 |
+
return output_file_path
|
| 25 |
+
|
| 26 |
+
|
| 27 |
def run():
|
| 28 |
+
iface = gr.Interface(
|
| 29 |
+
fn=calculate,
|
| 30 |
+
inputs=[
|
| 31 |
+
gr.File(label="Protein PDB", file_types=[".pdb"]),
|
| 32 |
+
gr.File(label="Ligand SDF", file_types=[".sdf"]),
|
| 33 |
+
gr.Number(label="Samples Per Complex", value=4, minimum=1, maximum=100, precision=0),
|
| 34 |
+
gr.Checkbox(label="Keep Local Structures", value=True),
|
| 35 |
+
gr.Checkbox(label="Save Visualization", value=True)
|
| 36 |
+
],
|
| 37 |
+
outputs=gr.File(label="Result")
|
| 38 |
)
|
| 39 |
|
| 40 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|
| 41 |
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|
| 44 |
+
run()
|