Spaces:
Running
on
Zero
Running
on
Zero
jadechoghari
commited on
Commit
·
e0f2a0e
1
Parent(s):
cf729de
add final
Browse files
.gradio/cached_examples/13/Generated Molecule/2dacb41b06297c98890e/boltz_0.pdb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
.gradio/cached_examples/13/Generated Molecule/72c05e00d37b5c2010bd/Monkeypox_4.pdb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
.gradio/cached_examples/13/indices.csv
CHANGED
@@ -1,2 +1,4 @@
|
|
1 |
4
|
2 |
1
|
|
|
|
|
|
1 |
4
|
2 |
1
|
3 |
+
0
|
4 |
+
5
|
.gradio/cached_examples/13/log.csv
CHANGED
@@ -1,3 +1,5 @@
|
|
1 |
Generated Molecule,timestamp
|
2 |
"{""path"": "".gradio/cached_examples/13/Generated Molecule/96624d241f3ceaf7652e/MITOCHONDRIAL_9.pdb"", ""url"": ""/gradio_api/file=/tmp/gradio/dfeb6cce50c7d0cb5ab8f1fcbc0ed91e88c6f502e6abf12023254e663fafee05/MITOCHONDRIAL_9.pdb"", ""size"": 2031480, ""orig_name"": ""MITOCHONDRIAL_9.pdb"", ""mime_type"": null, ""is_stream"": false, ""meta"": {""_type"": ""gradio.FileData""}}",2024-11-20 21:18:05.776535
|
3 |
"{""path"": "".gradio/cached_examples/13/Generated Molecule/4f0e0b233c39c3b226f9/Armadillo_6.pdb"", ""url"": ""/gradio_api/file=/tmp/gradio/e9e42deb7d9ea5c72c0bd60fb8f2bbed6357d48e775667232dc67eddc7886d87/Armadillo_6.pdb"", ""size"": 1271295, ""orig_name"": ""Armadillo_6.pdb"", ""mime_type"": null, ""is_stream"": false, ""meta"": {""_type"": ""gradio.FileData""}}",2024-11-20 22:28:22.665771
|
|
|
|
|
|
1 |
Generated Molecule,timestamp
|
2 |
"{""path"": "".gradio/cached_examples/13/Generated Molecule/96624d241f3ceaf7652e/MITOCHONDRIAL_9.pdb"", ""url"": ""/gradio_api/file=/tmp/gradio/dfeb6cce50c7d0cb5ab8f1fcbc0ed91e88c6f502e6abf12023254e663fafee05/MITOCHONDRIAL_9.pdb"", ""size"": 2031480, ""orig_name"": ""MITOCHONDRIAL_9.pdb"", ""mime_type"": null, ""is_stream"": false, ""meta"": {""_type"": ""gradio.FileData""}}",2024-11-20 21:18:05.776535
|
3 |
"{""path"": "".gradio/cached_examples/13/Generated Molecule/4f0e0b233c39c3b226f9/Armadillo_6.pdb"", ""url"": ""/gradio_api/file=/tmp/gradio/e9e42deb7d9ea5c72c0bd60fb8f2bbed6357d48e775667232dc67eddc7886d87/Armadillo_6.pdb"", ""size"": 1271295, ""orig_name"": ""Armadillo_6.pdb"", ""mime_type"": null, ""is_stream"": false, ""meta"": {""_type"": ""gradio.FileData""}}",2024-11-20 22:28:22.665771
|
4 |
+
"{""path"": "".gradio/cached_examples/13/Generated Molecule/2dacb41b06297c98890e/boltz_0.pdb"", ""url"": ""/gradio_api/file=/tmp/gradio/2ab77757589b1fd365f7221f92918cd369c77ddd8251942bc03a023821578dcd/boltz_0.pdb"", ""size"": 493208, ""orig_name"": ""boltz_0.pdb"", ""mime_type"": null, ""is_stream"": false, ""meta"": {""_type"": ""gradio.FileData""}}",2024-11-21 06:37:15.944530
|
5 |
+
"{""path"": "".gradio/cached_examples/13/Generated Molecule/72c05e00d37b5c2010bd/Monkeypox_4.pdb"", ""url"": ""/gradio_api/file=/tmp/gradio/dddfb893d502b267dcc8eef503e040c3b0a274cf678df53be49614c61cb1c603/Monkeypox_4.pdb"", ""size"": 453357, ""orig_name"": ""Monkeypox_4.pdb"", ""mime_type"": null, ""is_stream"": false, ""meta"": {""_type"": ""gradio.FileData""}}",2024-11-21 06:50:24.876272
|
app.py
CHANGED
@@ -6,7 +6,7 @@ import subprocess
|
|
6 |
import glob
|
7 |
|
8 |
|
9 |
-
#
|
10 |
CACHE_DIR = "gradio_cached_examples"
|
11 |
|
12 |
|
@@ -61,55 +61,27 @@ def on_example_click(fasta_file: str) -> str:
|
|
61 |
return load_cached_example_outputs(fasta_file)
|
62 |
|
63 |
# run predictions
|
64 |
-
|
65 |
-
def predict(data,
|
66 |
-
accelerator="gpu",
|
67 |
-
diffusion_samples=1
|
68 |
-
override=False):
|
69 |
|
70 |
print("Arguments passed to `predict` function:")
|
71 |
print(f" data: {data}")
|
72 |
-
print(f" out_dir: {out_dir}")
|
73 |
-
print(f" cache: {cache}")
|
74 |
-
print(f" checkpoint: {checkpoint}")
|
75 |
-
print(f" devices: {devices}")
|
76 |
print(f" accelerator: {accelerator}")
|
77 |
-
print(f" recycling_steps: {recycling_steps}")
|
78 |
print(f" sampling_steps: {sampling_steps}")
|
79 |
print(f" diffusion_samples: {diffusion_samples}")
|
80 |
-
|
81 |
-
print(f" num_workers: {num_workers}")
|
82 |
-
print(f" override: {override}")
|
83 |
-
# Construct the base command
|
84 |
command = [
|
85 |
"boltz", "predict",
|
86 |
-
"--out_dir",
|
87 |
-
"--cache", cache,
|
88 |
-
"--devices", str(devices),
|
89 |
"--accelerator", accelerator,
|
90 |
-
"--recycling_steps", str(recycling_steps),
|
91 |
"--sampling_steps", str(sampling_steps),
|
92 |
"--diffusion_samples", str(diffusion_samples),
|
93 |
-
"--output_format",
|
94 |
-
"--num_workers", str(num_workers)
|
95 |
]
|
96 |
-
|
97 |
-
|
98 |
-
# Add optional arguments if provided
|
99 |
-
if checkpoint:
|
100 |
-
command.extend(["--checkpoint", checkpoint])
|
101 |
-
if override:
|
102 |
-
command.append("--override")
|
103 |
-
|
104 |
-
|
105 |
-
# Add the data argument (path to the input file)
|
106 |
command.append(data)
|
107 |
-
|
108 |
-
# print("Constructed subprocess command:")
|
109 |
-
# print(" " + " ".join(command))
|
110 |
-
|
111 |
-
|
112 |
-
# Run the command using subprocess
|
113 |
result = subprocess.run(command, capture_output=True, text=True)
|
114 |
if result.returncode == 0:
|
115 |
print("Prediction completed successfully...!")
|
@@ -118,39 +90,29 @@ def predict(data, out_dir, cache="~/.boltz", checkpoint=None, devices=1,
|
|
118 |
print("Prediction failed :(")
|
119 |
print("Error:", result.stderr)
|
120 |
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
# Assuming `input_file` is a path to the .fasta file
|
125 |
-
data = input_file.name # Path to the uploaded .fasta file
|
126 |
print("the data : ", data)
|
127 |
-
# Update the `reps` settings with the chosen style and color
|
128 |
-
|
129 |
-
# Call your predict function
|
130 |
predict(
|
131 |
data=data,
|
132 |
-
out_dir="./",
|
133 |
-
cache=cache,
|
134 |
accelerator=accelerator,
|
135 |
sampling_steps=sampling_steps,
|
136 |
-
diffusion_samples=diffusion_samples
|
137 |
-
output_format=output_format,
|
138 |
-
checkpoint=checkpoint
|
139 |
)
|
140 |
|
141 |
-
#
|
|
|
142 |
search_path = os.path.join(out_dir, "boltz_results*/predictions/**/*.pdb")
|
143 |
-
pdb_files = glob.glob(search_path, recursive=True)
|
144 |
|
145 |
if not pdb_files:
|
146 |
print("No .pdb files found in the predictions folder.")
|
147 |
return None
|
148 |
|
149 |
-
#
|
|
|
150 |
latest_pdb_file = max(pdb_files, key=os.path.getmtime)
|
151 |
-
|
152 |
-
|
153 |
-
# Return the latest PDB file path
|
154 |
return latest_pdb_file
|
155 |
|
156 |
|
@@ -189,4 +151,3 @@ with gr.Blocks() as demo:
|
|
189 |
|
190 |
if __name__ == "__main__":
|
191 |
demo.launch(share=True, debug=True)
|
192 |
-
|
|
|
6 |
import glob
|
7 |
|
8 |
|
9 |
+
# directory to store cached outputs
|
10 |
CACHE_DIR = "gradio_cached_examples"
|
11 |
|
12 |
|
|
|
61 |
return load_cached_example_outputs(fasta_file)
|
62 |
|
63 |
# run predictions
|
64 |
+
@spaces.GPU(duration=120)
|
65 |
+
def predict(data,
|
66 |
+
accelerator="gpu", sampling_steps=50,
|
67 |
+
diffusion_samples=1):
|
|
|
68 |
|
69 |
print("Arguments passed to `predict` function:")
|
70 |
print(f" data: {data}")
|
|
|
|
|
|
|
|
|
71 |
print(f" accelerator: {accelerator}")
|
|
|
72 |
print(f" sampling_steps: {sampling_steps}")
|
73 |
print(f" diffusion_samples: {diffusion_samples}")
|
74 |
+
# we construct the base command
|
|
|
|
|
|
|
75 |
command = [
|
76 |
"boltz", "predict",
|
77 |
+
"--out_dir", "./",
|
|
|
|
|
78 |
"--accelerator", accelerator,
|
|
|
79 |
"--sampling_steps", str(sampling_steps),
|
80 |
"--diffusion_samples", str(diffusion_samples),
|
81 |
+
"--output_format", "pdb",
|
|
|
82 |
]
|
83 |
+
command.extend(["--checkpoint", "./ckpt/boltz1.ckpt"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
command.append(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
result = subprocess.run(command, capture_output=True, text=True)
|
86 |
if result.returncode == 0:
|
87 |
print("Prediction completed successfully...!")
|
|
|
90 |
print("Prediction failed :(")
|
91 |
print("Error:", result.stderr)
|
92 |
|
93 |
+
def run_prediction(input_file, accelerator, sampling_steps,
|
94 |
+
diffusion_samples):
|
95 |
+
data = input_file.name
|
|
|
|
|
96 |
print("the data : ", data)
|
|
|
|
|
|
|
97 |
predict(
|
98 |
data=data,
|
|
|
|
|
99 |
accelerator=accelerator,
|
100 |
sampling_steps=sampling_steps,
|
101 |
+
diffusion_samples=diffusion_samples
|
|
|
|
|
102 |
)
|
103 |
|
104 |
+
# search for the latest .pdb file in the predictions folder
|
105 |
+
out_dir = "./"
|
106 |
search_path = os.path.join(out_dir, "boltz_results*/predictions/**/*.pdb")
|
107 |
+
pdb_files = glob.glob(search_path, recursive=True)
|
108 |
|
109 |
if not pdb_files:
|
110 |
print("No .pdb files found in the predictions folder.")
|
111 |
return None
|
112 |
|
113 |
+
# some manual logic
|
114 |
+
# get the latest .pdb file based on modification time
|
115 |
latest_pdb_file = max(pdb_files, key=os.path.getmtime)
|
|
|
|
|
|
|
116 |
return latest_pdb_file
|
117 |
|
118 |
|
|
|
151 |
|
152 |
if __name__ == "__main__":
|
153 |
demo.launch(share=True, debug=True)
|
|