Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import sys
|
| 2 |
import random
|
| 3 |
import os
|
|
@@ -112,4 +113,86 @@ def predict(cfg, sequence):
|
|
| 112 |
outputs["binary prediction values"] = [1 if x > 0.5 else 0 for x in predictions]
|
| 113 |
return outputs
|
| 114 |
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
import sys
|
| 3 |
import random
|
| 4 |
import os
|
|
|
|
| 113 |
outputs["binary prediction values"] = [1 if x > 0.5 else 0 for x in predictions]
|
| 114 |
return outputs
|
| 115 |
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
# Gradio Interface
|
| 120 |
+
with gr.Blocks() as demo:
|
| 121 |
+
gr.Markdown(
|
| 122 |
+
"""
|
| 123 |
+
# PLTNUM: Protein LifeTime Neural Model
|
| 124 |
+
**Predict the protein half-life from its sequence or PDB file.**
|
| 125 |
+
"""
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
gr.Image(
|
| 129 |
+
"https://github.com/sagawatatsuya/PLTNUM/blob/main/model-image.png?raw=true",
|
| 130 |
+
label="Model Image",
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
# Model and Organism selection in the same row to avoid layout issues
|
| 134 |
+
with gr.Row():
|
| 135 |
+
model_choice = gr.Radio(
|
| 136 |
+
choices=["SaProt", "ESM2"],
|
| 137 |
+
label="Select PLTNUM's base model.",
|
| 138 |
+
value="SaProt",
|
| 139 |
+
)
|
| 140 |
+
organism_choice = gr.Radio(
|
| 141 |
+
choices=["Mouse", "Human"],
|
| 142 |
+
label="Select the target organism.",
|
| 143 |
+
value="Mouse",
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
with gr.Tabs():
|
| 147 |
+
with gr.TabItem("Upload PDB File"):
|
| 148 |
+
gr.Markdown("### Upload your PDB file:")
|
| 149 |
+
pdb_file = gr.File(label="Upload PDB File")
|
| 150 |
+
|
| 151 |
+
predict_button = gr.Button("Predict Stability")
|
| 152 |
+
prediction_output = gr.Textbox(
|
| 153 |
+
label="Stability Prediction", interactive=False
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
predict_button.click(
|
| 157 |
+
fn=predict_stability,
|
| 158 |
+
inputs=[model_choice, organism_choice, pdb_file],
|
| 159 |
+
outputs=prediction_output,
|
| 160 |
+
)
|
| 161 |
+
|
| 162 |
+
with gr.TabItem("Enter Protein Sequence"):
|
| 163 |
+
gr.Markdown("### Enter the protein sequence:")
|
| 164 |
+
sequence = gr.Textbox(
|
| 165 |
+
label="Protein Sequence",
|
| 166 |
+
placeholder="Enter your protein sequence here...",
|
| 167 |
+
lines=8,
|
| 168 |
+
)
|
| 169 |
+
predict_button = gr.Button("Predict Stability")
|
| 170 |
+
prediction_output = gr.Textbox(
|
| 171 |
+
label="Stability Prediction", interactive=False
|
| 172 |
+
)
|
| 173 |
+
|
| 174 |
+
predict_button.click(
|
| 175 |
+
fn=predict_stability,
|
| 176 |
+
inputs=[model_choice, organism_choice, sequence],
|
| 177 |
+
outputs=prediction_output,
|
| 178 |
+
)
|
| 179 |
+
|
| 180 |
+
gr.Markdown(
|
| 181 |
+
"""
|
| 182 |
+
### How to Use:
|
| 183 |
+
- **Select Model**: Choose between 'SaProt' or 'ESM2' for your prediction.
|
| 184 |
+
- **Select Organism**: Choose between 'Mouse' or 'Human'.
|
| 185 |
+
- **Upload PDB File**: Choose the 'Upload PDB File' tab and upload your file.
|
| 186 |
+
- **Enter Sequence**: Alternatively, switch to the 'Enter Protein Sequence' tab and input your sequence.
|
| 187 |
+
- **Predict**: Click 'Predict Stability' to receive the prediction.
|
| 188 |
+
"""
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
gr.Markdown(
|
| 192 |
+
"""
|
| 193 |
+
### About the Tool
|
| 194 |
+
This tool allows researchers and scientists to predict the stability of proteins using advanced algorithms. It supports both PDB file uploads and direct sequence input.
|
| 195 |
+
"""
|
| 196 |
+
)
|
| 197 |
+
|
| 198 |
+
demo.launch()
|