Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,7 +33,24 @@ from accelerate import Accelerator
|
|
| 33 |
# Imports specific to the custom peft lora model
|
| 34 |
from peft import get_peft_config, PeftModel, PeftConfig, get_peft_model, LoraConfig, TaskType
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
# Helper Functions and Data Preparation
|
| 38 |
def truncate_labels(labels, max_length):
|
| 39 |
"""Truncate labels to the specified max_length."""
|
|
@@ -374,13 +391,33 @@ with demo:
|
|
| 374 |
value=PEFT_MODEL_OPTIONS[0],
|
| 375 |
label="PEFT Model Name",
|
| 376 |
interactive = True,
|
| 377 |
-
)
|
| 378 |
-
with gr.Column(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
finetune_button = gr.Button(
|
| 380 |
value="Finetune Pre-trained Model",
|
| 381 |
interactive=True,
|
| 382 |
variant="primary",
|
| 383 |
)
|
|
|
|
| 384 |
with gr.Row():
|
| 385 |
finetune_output_text = gr.Textbox(
|
| 386 |
lines=1,
|
|
@@ -388,7 +425,18 @@ with demo:
|
|
| 388 |
label="Finetune Status",
|
| 389 |
placeholder="Finetune Status Shown Here",
|
| 390 |
)
|
| 391 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
# "Finetune Pre-trained Model" actions
|
| 393 |
finetune_button.click(
|
| 394 |
fn = train_function_no_sweeps,
|
|
@@ -396,5 +444,7 @@ with demo:
|
|
| 396 |
outputs = [finetune_output_text],
|
| 397 |
)
|
| 398 |
|
| 399 |
-
|
|
|
|
|
|
|
| 400 |
demo.launch()
|
|
|
|
| 33 |
# Imports specific to the custom peft lora model
|
| 34 |
from peft import get_peft_config, PeftModel, PeftConfig, get_peft_model, LoraConfig, TaskType
|
| 35 |
|
| 36 |
+
from plot_pdb import plot_struc
|
| 37 |
+
|
| 38 |
+
def suggest(option):
|
| 39 |
+
if option == "Plastic degradation protein":
|
| 40 |
+
suggestion = "MGSSHHHHHHSSGLVPRGSHMRGPNPTAASLEASAGPFTVRSFTVSRPSGYGAGTVYYPTNAGGTVGAIAIVPGYTARQSSIKWWGPRLASHGFVVITIDTNSTLDQPSSRSSQQMAALRQVASLNGTSSSPIYGKVDTARMGVMGWSMGGGGSLISAANNPSLKAAAPQAPWDSSTNFSSVTVPTLIFACENDSIAPVNSSALPIYDSMSRNAKQFLEINGGSHSCANSGNSNQALIGKKGVAWMKRFMDNDTRYSTFACENPNSTRVSDFRTANCSLEDPAANKARKEAELAAATAEQ"
|
| 41 |
+
elif option == "Default protein":
|
| 42 |
+
#suggestion = "MAPLRKTYVLKLYVAGNTPNSVRALKTLNNILEKEFKGVYALKVIDVLKNPQLAEEDKILATPTLAKVLPPPVRRIIGDLSNREKVLIGLDLLYEEIGDQAEDDLGLE"
|
| 43 |
+
suggestion = "MAVPETRPNHTIYINNLNEKIKKDELKKSLHAIFSRFGQILDILVSRSLKMRGQAFVIFKEVSSATNALRSMQGFPFYDKPMRIQYAKTDSDIIAKMKGT"
|
| 44 |
+
elif option == "Antifreeze protein":
|
| 45 |
+
suggestion = "QCTGGADCTSCTGACTGCGNCPNAVTCTNSQHCVKANTCTGSTDCNTAQTCTNSKDCFEANTCTDSTNCYKATACTNSSGCPGH"
|
| 46 |
+
elif option == "AI Generated protein":
|
| 47 |
+
suggestion = "MSGMKKLYEYTVTTLDEFLEKLKEFILNTSKDKIYKLTITNPKLIKDIGKAIAKAAEIADVDPKEIEEMIKAVEENELTKLVITIEQTDDKYVIKVELENEDGLVHSFEIYFKNKEEMEKFLELLEKLISKLSGS"
|
| 48 |
+
elif option == "7-bladed propeller fold":
|
| 49 |
+
suggestion = "VKLAGNSSLCPINGWAVYSKDNSIRIGSKGDVFVIREPFISCSHLECRTFFLTQGALLNDKHSNGTVKDRSPHRTLMSCPVGEAPSPYNSRFESVAWSASACHDGTSWLTIGISGPDNGAVAVLKYNGIITDTIKSWRNNILRTQESECACVNGSCFTVMTDGPSNGQASYKIFKMEKGKVVKSVELDAPNYHYEECSCYPNAGEITCVCRDNWHGSNRPWVSFNQNLEYQIGYICSGVFGDNPRPNDGTGSCGPVSSNGAYGVKGFSFKYGNGVWIGRTKSTNSRSGFEMIWDPNGWTETDSSFSVKQDIVAITDWSGYSGSFVQHPELTGLDCIRPCFWVELIRGRPKESTIWTSGSSISFCGVNSDTVGWSWPDGAELPFTIDK"
|
| 50 |
+
else:
|
| 51 |
+
suggestion = ""
|
| 52 |
+
return suggestion
|
| 53 |
+
|
| 54 |
# Helper Functions and Data Preparation
|
| 55 |
def truncate_labels(labels, max_length):
|
| 56 |
"""Truncate labels to the specified max_length."""
|
|
|
|
| 391 |
value=PEFT_MODEL_OPTIONS[0],
|
| 392 |
label="PEFT Model Name",
|
| 393 |
interactive = True,
|
| 394 |
+
)
|
| 395 |
+
with gr.Column(variant="compact"):
|
| 396 |
+
name = gr.Dropdown(
|
| 397 |
+
label="Choose a Sample Protein",
|
| 398 |
+
value="Default protein",
|
| 399 |
+
choices=["Default protein", "Antifreeze protein", "Plastic degradation protein", "AI Generated protein", "7-bladed propeller fold", "custom"]
|
| 400 |
+
)
|
| 401 |
+
gr.Markdown(
|
| 402 |
+
"""Predict binding site and Plot structure for selected protein sequence:"""
|
| 403 |
+
)
|
| 404 |
+
with gr.Row():
|
| 405 |
+
with gr.Column(variant="compact", scale = 8):
|
| 406 |
+
input_seq = gr.Textbox(
|
| 407 |
+
lines=1,
|
| 408 |
+
max_lines=12,
|
| 409 |
+
label="Protein sequency to be predicted:",
|
| 410 |
+
value="MAVPETRPNHTIYINNLNEKIKKDELKKSLHAIFSRFGQILDILVSRSLKMRGQAFVIFKEVSSATNALRSMQGFPFYDKPMRIQYAKTDSDIIAKMKGT",
|
| 411 |
+
placeholder="Paste your protein sequence here...",
|
| 412 |
+
interactive = True,
|
| 413 |
+
)
|
| 414 |
+
with gr.Column(variant="compact", scale = 2):
|
| 415 |
finetune_button = gr.Button(
|
| 416 |
value="Finetune Pre-trained Model",
|
| 417 |
interactive=True,
|
| 418 |
variant="primary",
|
| 419 |
)
|
| 420 |
+
plot_struc_btn = gr.Button(value = "Plot ESMFold Predicted Structure ", variant="primary")
|
| 421 |
with gr.Row():
|
| 422 |
finetune_output_text = gr.Textbox(
|
| 423 |
lines=1,
|
|
|
|
| 425 |
label="Finetune Status",
|
| 426 |
placeholder="Finetune Status Shown Here",
|
| 427 |
)
|
| 428 |
+
with gr.Row():
|
| 429 |
+
output_viewer = gr.HTML()
|
| 430 |
+
output_file = gr.File(
|
| 431 |
+
label="Download as Text File",
|
| 432 |
+
file_count="single",
|
| 433 |
+
type="filepath",
|
| 434 |
+
interactive=False,
|
| 435 |
+
)
|
| 436 |
+
|
| 437 |
+
# select protein sample
|
| 438 |
+
name.change(fn=suggest, inputs=name, outputs=input_seq)
|
| 439 |
+
|
| 440 |
# "Finetune Pre-trained Model" actions
|
| 441 |
finetune_button.click(
|
| 442 |
fn = train_function_no_sweeps,
|
|
|
|
| 444 |
outputs = [finetune_output_text],
|
| 445 |
)
|
| 446 |
|
| 447 |
+
# plot protein structure
|
| 448 |
+
plot_struc_btn.click(fn=plot_struc, inputs=input_seq, outputs=[output_file, output_viewer])
|
| 449 |
+
|
| 450 |
demo.launch()
|