Update app.py
Browse files
app.py
CHANGED
@@ -30,23 +30,37 @@ class Config:
|
|
30 |
|
31 |
|
32 |
def predict_stability_with_pdb(model_choice, organism_choice, pdb_files, cfg=Config()):
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
pdb_path = pdb_file.name
|
37 |
os.system("chmod 777 bin/foldseek")
|
38 |
sequences = get_foldseek_seq(pdb_path)
|
39 |
if not sequences:
|
40 |
-
results.append(
|
|
|
|
|
|
|
41 |
continue
|
42 |
-
sequence = sequences[2] if model_choice == "SaProt" else sequences[0]
|
43 |
-
|
44 |
-
prediction = predict_stability_core(model_choice, organism_choice, sequence, cfg)
|
45 |
-
results.append(f"Prediction for {pdb_file.name}: {prediction}")
|
46 |
-
return "<br>".join(results)
|
47 |
-
except Exception as e:
|
48 |
-
return f"An error occurred: {str(e)}"
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
def predict_stability_with_sequence(model_choice, organism_choice, sequence, cfg=Config()):
|
52 |
try:
|
@@ -167,8 +181,8 @@ with gr.Blocks() as demo:
|
|
167 |
gr.Markdown("### Upload your PDB files:")
|
168 |
pdb_files = gr.File(label="Upload PDB Files", file_count="multiple")
|
169 |
predict_button = gr.Button("Predict Stability")
|
170 |
-
prediction_output = gr.
|
171 |
-
label="
|
172 |
)
|
173 |
|
174 |
predict_button.click(
|
|
|
30 |
|
31 |
|
32 |
def predict_stability_with_pdb(model_choice, organism_choice, pdb_files, cfg=Config()):
|
33 |
+
results = []
|
34 |
+
for pdb_file in pdb_files:
|
35 |
+
try:
|
36 |
pdb_path = pdb_file.name
|
37 |
os.system("chmod 777 bin/foldseek")
|
38 |
sequences = get_foldseek_seq(pdb_path)
|
39 |
if not sequences:
|
40 |
+
results.append({"file_name": pdb_path,
|
41 |
+
"raw prediction value": None,
|
42 |
+
"binary prediction value": None
|
43 |
+
})
|
44 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
+
sequence = sequences[2] if model_choice == "SaProt" else sequences[0]
|
47 |
+
output = predict_stability_core(model_choice, organism_choice, sequence, cfg)
|
48 |
+
|
49 |
+
results.append({"file_name": pdb_path,
|
50 |
+
"raw prediction value": output["raw prediction values"][0],
|
51 |
+
"binary prediction value": output["binary prediction values"][0]
|
52 |
+
})
|
53 |
+
except Exception as e:
|
54 |
+
results.append({"file_name": pdb_file.name,
|
55 |
+
"raw prediction value": None,
|
56 |
+
"binary prediction value": None
|
57 |
+
})
|
58 |
+
|
59 |
+
df = pd.DataFrame(results)
|
60 |
+
output_csv = "/tmp/predictions.csv"
|
61 |
+
df.to_csv(output_csv, index=False)
|
62 |
+
|
63 |
+
return output_csv
|
64 |
|
65 |
def predict_stability_with_sequence(model_choice, organism_choice, sequence, cfg=Config()):
|
66 |
try:
|
|
|
181 |
gr.Markdown("### Upload your PDB files:")
|
182 |
pdb_files = gr.File(label="Upload PDB Files", file_count="multiple")
|
183 |
predict_button = gr.Button("Predict Stability")
|
184 |
+
prediction_output = gr.File(
|
185 |
+
label="Download Predictions"
|
186 |
)
|
187 |
|
188 |
predict_button.click(
|