Update app.py
Browse files
app.py
CHANGED
|
@@ -38,23 +38,19 @@ def predict_stability_with_pdb(model_choice, organism_choice, pdb_files, cfg=Con
|
|
| 38 |
sequences = []
|
| 39 |
|
| 40 |
for pdb_file in pdb_files:
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
except Exception as e:
|
| 55 |
-
results["file_name"].append(pdb_file.name)
|
| 56 |
-
results["raw prediction value"].append(None)
|
| 57 |
-
results["binary prediction value"].append(None)
|
| 58 |
raw_prediction, binary_prediction = predict_stability_core(model_choice, organism_choice, sequences, cfg)
|
| 59 |
results["file_name"] = results["file_name"] + file_names
|
| 60 |
results["raw prediction value"] = results["raw prediction value"] + raw_prediction
|
|
@@ -70,8 +66,12 @@ def predict_stability_with_sequence(model_choice, organism_choice, sequence, cfg
|
|
| 70 |
try:
|
| 71 |
if not sequence:
|
| 72 |
return "No valid sequence provided."
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
except Exception as e:
|
| 76 |
return f"An error occurred: {str(e)}"
|
| 77 |
|
|
@@ -192,8 +192,8 @@ with gr.Blocks() as demo:
|
|
| 192 |
lines=8,
|
| 193 |
)
|
| 194 |
predict_button = gr.Button("Predict Stability")
|
| 195 |
-
prediction_output = gr.
|
| 196 |
-
label="
|
| 197 |
)
|
| 198 |
|
| 199 |
predict_button.click(
|
|
|
|
| 38 |
sequences = []
|
| 39 |
|
| 40 |
for pdb_file in pdb_files:
|
| 41 |
+
pdb_path = pdb_file.name
|
| 42 |
+
os.system("chmod 777 bin/foldseek")
|
| 43 |
+
sequences = get_foldseek_seq(pdb_path)
|
| 44 |
+
if not sequences:
|
| 45 |
+
results["file_name"].append(pdb_file.name.split("/")[-1])
|
| 46 |
+
results["raw prediction value"].append(None)
|
| 47 |
+
results["binary prediction value"].append(None)
|
| 48 |
+
continue
|
| 49 |
+
|
| 50 |
+
sequence = sequences[2] if model_choice == "SaProt" else sequences[0]
|
| 51 |
+
file_names.append(pdb_file.name.split("/")[-1])
|
| 52 |
+
sequences.append(sequence)
|
| 53 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
raw_prediction, binary_prediction = predict_stability_core(model_choice, organism_choice, sequences, cfg)
|
| 55 |
results["file_name"] = results["file_name"] + file_names
|
| 56 |
results["raw prediction value"] = results["raw prediction value"] + raw_prediction
|
|
|
|
| 66 |
try:
|
| 67 |
if not sequence:
|
| 68 |
return "No valid sequence provided."
|
| 69 |
+
raw_prediction, binary_prediction = predict_stability_core(model_choice, organism_choice, sequence, cfg)
|
| 70 |
+
df = pd.DataFrame({"sequence": sequence, "raw prediction value": raw_prediction, "binary prediction value": binary_prediction})
|
| 71 |
+
output_csv = "/tmp/predictions.csv"
|
| 72 |
+
df.to_csv(output_csv, index=False)
|
| 73 |
+
|
| 74 |
+
return output_csv
|
| 75 |
except Exception as e:
|
| 76 |
return f"An error occurred: {str(e)}"
|
| 77 |
|
|
|
|
| 192 |
lines=8,
|
| 193 |
)
|
| 194 |
predict_button = gr.Button("Predict Stability")
|
| 195 |
+
prediction_output = gr.File(
|
| 196 |
+
label="Download Predictions"
|
| 197 |
)
|
| 198 |
|
| 199 |
predict_button.click(
|