Spaces:
Runtime error
Runtime error
Commit
·
cec3465
1
Parent(s):
32cc43e
query -> promps
Browse files
app.py
CHANGED
|
@@ -23,14 +23,14 @@ protein_calmodulin = "MADQLTEEQIAEFKEAFSLFDKDGDGTITTKELGTVMRSLGQNPTEAELQDMISELDQ
|
|
| 23 |
protein_calcineurin = "MSSKLLLAGLDIERVLAEKNFYKEWDTWIIEAMNVGDEEVDRIKEFKEDEIFEEAKTLGTAEMQEYKKQKLEEAIEGAFDIFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIRQMWDQNGDWDRIKELKFGEIKKLSAKDTRGTIFIKVFENLGTGVDSEYEDVSKYMLKHQ"
|
| 24 |
|
| 25 |
|
| 26 |
-
def
|
| 27 |
# Formatting prompt to match pre-training syntax
|
| 28 |
return f"<@TOKENIZER-TYPE=AA><BINDING_AFFINITY_CLASS><SENTINEL_ID_0><MOLECULAR_ENTITY><MOLECULAR_ENTITY_GENERAL_PROTEIN><SEQUENCE_NATURAL_START>{prot1}<SEQUENCE_NATURAL_END><MOLECULAR_ENTITY><MOLECULAR_ENTITY_GENERAL_PROTEIN><SEQUENCE_NATURAL_START>{prot2}<SEQUENCE_NATURAL_END><EOS>"
|
| 29 |
|
| 30 |
-
def
|
| 31 |
# Create and load sample
|
| 32 |
sample_dict = dict()
|
| 33 |
-
sample_dict[ENCODER_INPUTS_STR] =
|
| 34 |
|
| 35 |
# Tokenize
|
| 36 |
sample_dict=tokenizer_op(
|
|
@@ -58,9 +58,9 @@ def run_query(query):
|
|
| 58 |
|
| 59 |
return generated_output,score
|
| 60 |
|
| 61 |
-
def
|
| 62 |
-
|
| 63 |
-
res=
|
| 64 |
return res
|
| 65 |
|
| 66 |
def create_application():
|
|
@@ -92,16 +92,16 @@ Given two protein sequences, estimate if the proteins interact or not.
|
|
| 92 |
value=protein_calcineurin,
|
| 93 |
)
|
| 94 |
with gr.Row():
|
| 95 |
-
run_mammal = gr.Button("Run Mammal
|
| 96 |
with gr.Row():
|
| 97 |
-
|
| 98 |
|
| 99 |
with gr.Row():
|
| 100 |
decoded = gr.Textbox(label="Mammal output")
|
| 101 |
run_mammal.click(
|
| 102 |
-
fn=
|
| 103 |
inputs=[prot1,prot2],
|
| 104 |
-
outputs=[
|
| 105 |
)
|
| 106 |
with gr.Row():
|
| 107 |
gr.Markdown("```<SENTINEL_ID_0>``` contains the binding affinity class, which is ```<1>``` for interating and ```<0>``` for non-interating")
|
|
|
|
| 23 |
protein_calcineurin = "MSSKLLLAGLDIERVLAEKNFYKEWDTWIIEAMNVGDEEVDRIKEFKEDEIFEEAKTLGTAEMQEYKKQKLEEAIEGAFDIFDKDGNGYISAAELRHVMTNLGEKLTDEEVDEMIRQMWDQNGDWDRIKELKFGEIKKLSAKDTRGTIFIKVFENLGTGVDSEYEDVSKYMLKHQ"
|
| 24 |
|
| 25 |
|
| 26 |
+
def format_prompt(prot1,prot2):
|
| 27 |
# Formatting prompt to match pre-training syntax
|
| 28 |
return f"<@TOKENIZER-TYPE=AA><BINDING_AFFINITY_CLASS><SENTINEL_ID_0><MOLECULAR_ENTITY><MOLECULAR_ENTITY_GENERAL_PROTEIN><SEQUENCE_NATURAL_START>{prot1}<SEQUENCE_NATURAL_END><MOLECULAR_ENTITY><MOLECULAR_ENTITY_GENERAL_PROTEIN><SEQUENCE_NATURAL_START>{prot2}<SEQUENCE_NATURAL_END><EOS>"
|
| 29 |
|
| 30 |
+
def run_prompt(prompt):
|
| 31 |
# Create and load sample
|
| 32 |
sample_dict = dict()
|
| 33 |
+
sample_dict[ENCODER_INPUTS_STR] = prompt
|
| 34 |
|
| 35 |
# Tokenize
|
| 36 |
sample_dict=tokenizer_op(
|
|
|
|
| 58 |
|
| 59 |
return generated_output,score
|
| 60 |
|
| 61 |
+
def create_and_run_prompt(prot1, prot2):
|
| 62 |
+
prompt = format_prompt(prot1, prot2)
|
| 63 |
+
res=prompt, *run_prompt(prompt=prompt)
|
| 64 |
return res
|
| 65 |
|
| 66 |
def create_application():
|
|
|
|
| 92 |
value=protein_calcineurin,
|
| 93 |
)
|
| 94 |
with gr.Row():
|
| 95 |
+
run_mammal = gr.Button("Run Mammal prompt for Protein-Protein Interaction",variant='primary')
|
| 96 |
with gr.Row():
|
| 97 |
+
prompt_box = gr.Textbox(label="Mammal prompt",lines=5)
|
| 98 |
|
| 99 |
with gr.Row():
|
| 100 |
decoded = gr.Textbox(label="Mammal output")
|
| 101 |
run_mammal.click(
|
| 102 |
+
fn=create_and_run_prompt,
|
| 103 |
inputs=[prot1,prot2],
|
| 104 |
+
outputs=[prompt_box,decoded,gr.Number(label='PPI score')]
|
| 105 |
)
|
| 106 |
with gr.Row():
|
| 107 |
gr.Markdown("```<SENTINEL_ID_0>``` contains the binding affinity class, which is ```<1>``` for interating and ```<0>``` for non-interating")
|