jadechoghari commited on
Commit
d4e347d
·
1 Parent(s): 07cd985
Files changed (4) hide show
  1. __init__.py +0 -0
  2. __pycache__/app.cpython-310.pyc +0 -0
  3. app.py +71 -4
  4. boltz +1 -0
__init__.py ADDED
File without changes
__pycache__/app.cpython-310.pyc ADDED
Binary file (1.33 kB). View file
 
app.py CHANGED
@@ -1,7 +1,74 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
1
  import gradio as gr
2
+ import os
3
+ from gradio_molecule3d import Molecule3D
4
+ from boltz.main_test import predict # Import your predict function
5
 
6
+ # Example Molecule3D representation settings
7
+ reps = [
8
+ {
9
+ "model": 0,
10
+ "chain": "",
11
+ "resname": "",
12
+ "style": "stick",
13
+ "color": "whiteCarbon",
14
+ "residue_range": "",
15
+ "around": 0,
16
+ "byres": False,
17
+ "visible": False
18
+ }
19
+ ]
20
+
21
+ # Your prediction function
22
+ def run_prediction(input_file):
23
+ # Assuming `input_file` is a Gradio `File` object
24
+ data = input_file.name # Get the path to the uploaded .fasta file
25
+ out_dir = "/predict" # Set your output directory
26
+ cache = "~/.boltz"
27
+ accelerator = "cpu"
28
+ sampling_steps = 200
29
+ diffusion_samples = 1
30
+ output_format = "pdb"
31
+
32
+ # Call your original predict function
33
+ predict(
34
+ data=data,
35
+ out_dir=out_dir,
36
+ cache=cache,
37
+ checkpoint=checkpoint,
38
+ devices=devices,
39
+ accelerator=accelerator,
40
+ recycling_steps=recycling_steps,
41
+ sampling_steps=sampling_steps,
42
+ diffusion_samples=diffusion_samples,
43
+ output_format=output_format,
44
+ num_workers=num_workers,
45
+ override=override,
46
+ )
47
+
48
+ # Fetch the generated PDB file
49
+ output_pdb_path = os.path.join(out_dir, "output.pdb")
50
+ if os.path.exists(output_pdb_path):
51
+ print("Generated PDB file found:", output_pdb_path)
52
+ return output_pdb_path # Return the path for Molecule3D to load
53
+ else:
54
+ print("Generated PDB file not found")
55
+ return None
56
+
57
+ # Gradio interface setup
58
+ with gr.Blocks() as demo:
59
+ gr.Markdown("# Molecule3D - Upload a .fasta File for Prediction")
60
+
61
+ # Input: File upload component for .fasta files
62
+ inp = gr.File(label="Upload a .fasta File", file_types=[".fasta"])
63
+
64
+ # Output: Molecule3D component for rendering the generated PDB file
65
+ out = Molecule3D(label="Generated Molecule", reps=reps)
66
+
67
+ btn = gr.Button("Predict")
68
+
69
+ # Connect the button click to the prediction function
70
+ btn.click(run_prediction, inputs=inp, outputs=out)
71
+
72
+ if __name__ == "__main__":
73
+ demo.launch()
74
 
 
 
boltz ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit 6d2f537957a232eadfea569ab95374205e61bbc6