TianlaiChen commited on
Commit
9fec676
1 Parent(s): 45539e9
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -54,11 +54,11 @@ def generate_peptide(protein_seq, peptide_length, top_k, num_binders):
54
 
55
  # Compute PPL for the generated binder
56
  ppl_value = compute_pseudo_perplexity(model, tokenizer, protein_seq, generated_binder)
57
- binders_with_ppl.append((generated_binder, ppl_value))
58
 
59
- # Formatting the output
60
- output = "\n".join([f"Binder: {binder}, PPL: {ppl:.2f}" for binder, ppl in binders_with_ppl])
61
- return output
 
62
 
63
  # Define the Gradio interface
64
  interface = gr.Interface(
@@ -67,9 +67,13 @@ interface = gr.Interface(
67
  gr.Textbox(label="Protein Sequence", info="Enter protein sequence here", type="text"),
68
  gr.Slider(3, 50, value=15, label="Peptide Length", step=1, info='Default value is 15'),
69
  gr.Slider(1, 10, value=3, label="Top K Value", step=1, info='Default value is 3'),
70
- gr.Dropdown(choices=[1, 2, 4, 8, 16, 32], label="Number of Binders", value=4)
71
  ],
72
- outputs=gr.outputs.Textbox(label="Binders (with Perplexity)"),
 
 
 
 
73
  title="PepMLM: Target Sequence-Conditioned Generation of Peptide Binders via Masked Language Modeling"
74
  )
75
 
 
54
 
55
  # Compute PPL for the generated binder
56
  ppl_value = compute_pseudo_perplexity(model, tokenizer, protein_seq, generated_binder)
 
57
 
58
+ # Add the generated binder and its PPL to the results list
59
+ binders_with_ppl.append([generated_binder, ppl_value])
60
+
61
+ return binders_with_ppl
62
 
63
  # Define the Gradio interface
64
  interface = gr.Interface(
 
67
  gr.Textbox(label="Protein Sequence", info="Enter protein sequence here", type="text"),
68
  gr.Slider(3, 50, value=15, label="Peptide Length", step=1, info='Default value is 15'),
69
  gr.Slider(1, 10, value=3, label="Top K Value", step=1, info='Default value is 3'),
70
+ gr.Dropdown(choices=[1, 2, 4, 8, 16, 32], label="Number of Binders", default=1)
71
  ],
72
+ outputs=gr.Dataframe(
73
+ headers=["Binder", "Perplexity"],
74
+ datatype=["str", "number"],
75
+ col_count=(2, "fixed")
76
+ ),
77
  title="PepMLM: Target Sequence-Conditioned Generation of Peptide Binders via Masked Language Modeling"
78
  )
79