File size: 3,347 Bytes
93a77af 178b187 93a77af 8f7fecd 93a77af 8f7fecd 93a77af 178b187 f4d9b4d 178b187 93a77af c998ccf 93a77af 8f7fecd f01f3e2 93a77af 178b187 93a77af 178b187 93a77af 8f7fecd 93a77af 8f7fecd 93a77af f01f3e2 8f7fecd f01f3e2 93a77af 8f7fecd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
import gradio as gr
import sys
import random
sys.path.append("scripts/")
from foldseek_util import get_struc_seq
# Assuming 'predict_stability' is your function that predicts protein stability
def predict_stability(model_choice, organism_choice, pdb_file=None, sequence=None):
# Dummy return for illustration; replace with your actual prediction logic
return f"Predicted Stability using {model_choice} for {organism_choice}: Example Output"
def get_foldseek_seq(pdb_path):
try:
parsed_seqs = get_struc_seq(
"bin/foldseek",
pdb_path,
["A"],
process_id=random.randint(0, 10000000),
)["A"]
return parsed_seqs
except:
return None
# Gradio Interface
with gr.Blocks() as demo:
gr.Markdown(
"""
# PLTNUM: Protein LifeTime Neural Model
**Predict the protein half-life from its sequence or PDB file.**
"""
)
gr.Image("https://github.com/sagawatatsuya/PLTNUM/blob/main/model-image.png?raw=true", label="Model Image")
# Model and Organism selection in the same row to avoid layout issues
with gr.Row():
model_choice = gr.Radio(
choices=["SaProt", "ESM-2"],
label="Select PLTNUM's base model.",
value="SaProt"
)
organism_choice = gr.Radio(
choices=["Mouse", "Human"],
label="Select the target organism.",
value="Mouse"
)
with gr.Tabs():
with gr.TabItem("Upload PDB File"):
gr.Markdown("### Upload your PDB file:")
pdb_file = gr.File(label="Upload PDB File")
output = get_foldseek_seq(pdb_file)
predict_button = gr.Button("Predict Stability")
prediction_output = gr.Textbox(label=str(output), interactive=False)
predict_button.click(fn=predict_stability, inputs=[model_choice, organism_choice, pdb_file], outputs=prediction_output)
with gr.TabItem("Enter Protein Sequence"):
gr.Markdown("### Enter the protein sequence:")
sequence = gr.Textbox(
label="Protein Sequence",
placeholder="Enter your protein sequence here...",
lines=8,
)
predict_button = gr.Button("Predict Stability")
prediction_output = gr.Textbox(label="Stability Prediction", interactive=False)
predict_button.click(fn=predict_stability, inputs=[model_choice, organism_choice, sequence], outputs=prediction_output)
gr.Markdown(
"""
### How to Use:
- **Select Model**: Choose between 'SaProt' or 'ESM-2' for your prediction.
- **Select Organism**: Choose between 'Mouse' or 'Human'.
- **Upload PDB File**: Choose the 'Upload PDB File' tab and upload your file.
- **Enter Sequence**: Alternatively, switch to the 'Enter Protein Sequence' tab and input your sequence.
- **Predict**: Click 'Predict Stability' to receive the prediction.
"""
)
gr.Markdown(
"""
### About the Tool
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.
"""
)
demo.launch()
|