colbyford commited on
Commit
2466cb5
·
1 Parent(s): 8505e9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -9
app.py CHANGED
@@ -65,7 +65,7 @@ def display_pdb(path_to_pdb):
65
  allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
66
  '''
67
 
68
- def make_uncond_seq(seq_len, model_type):
69
  if model_type == "EvoDiff-Seq-OADM 38M":
70
  checkpoint = OA_DM_38M()
71
  model, collater, tokenizer, scheme = checkpoint
@@ -76,21 +76,27 @@ def make_uncond_seq(seq_len, model_type):
76
  model, collater, tokenizer, scheme, timestep, Q_bar, Q = checkpoint
77
  tokeinzed_sample, generated_sequence = generate_d3pm(model, tokenizer, Q, Q_bar, timestep, seq_len, batch_size=1, device='cpu')
78
 
79
- path_to_pdb = predict_protein(generated_sequence)
80
- molhtml = display_pdb(path_to_pdb)
 
81
 
82
- return generated_sequence, molhtml
 
 
83
 
84
- def make_cond_seq(seq_len, msa_file, model_type):
85
  if model_type == "EvoDiff-MSA":
86
  checkpoint = MSA_OA_DM_MAXSUB()
87
  model, collater, tokenizer, scheme = checkpoint
88
  tokeinzed_sample, generated_sequence = generate_query_oadm_msa_simple(msa_file.name, model, tokenizer, n_sequences=64, seq_length=seq_len, device='cpu', selection_type='random')
89
 
90
- path_to_pdb = predict_protein(generated_sequence)
91
- molhtml = display_pdb(path_to_pdb)
 
92
 
93
- return generated_sequence, molhtml
 
 
94
 
95
  usg_app = gr.Interface(
96
  fn=make_uncond_seq,
@@ -111,7 +117,8 @@ csg_app = gr.Interface(
111
  inputs=[
112
  gr.Slider(10, 100, label = "Sequence Length"),
113
  gr.File(file_types=["a3m"], label = "MSA File"),
114
- gr.Dropdown(["EvoDiff-MSA"], value="EvoDiff-MSA", type="value", label = "Model")
 
115
  ],
116
  outputs=[
117
  "text",
 
65
  allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
66
  '''
67
 
68
+ def make_uncond_seq(seq_len, model_type, pred_structure):
69
  if model_type == "EvoDiff-Seq-OADM 38M":
70
  checkpoint = OA_DM_38M()
71
  model, collater, tokenizer, scheme = checkpoint
 
76
  model, collater, tokenizer, scheme, timestep, Q_bar, Q = checkpoint
77
  tokeinzed_sample, generated_sequence = generate_d3pm(model, tokenizer, Q, Q_bar, timestep, seq_len, batch_size=1, device='cpu')
78
 
79
+ if pred_structure:
80
+ path_to_pdb = predict_protein(generated_sequence)
81
+ molhtml = display_pdb(path_to_pdb)
82
 
83
+ return generated_sequence, molhtml
84
+ else:
85
+ return generated_sequence
86
 
87
+ def make_cond_seq(seq_len, msa_file, model_type, pred_structure):
88
  if model_type == "EvoDiff-MSA":
89
  checkpoint = MSA_OA_DM_MAXSUB()
90
  model, collater, tokenizer, scheme = checkpoint
91
  tokeinzed_sample, generated_sequence = generate_query_oadm_msa_simple(msa_file.name, model, tokenizer, n_sequences=64, seq_length=seq_len, device='cpu', selection_type='random')
92
 
93
+ if pred_structure:
94
+ path_to_pdb = predict_protein(generated_sequence)
95
+ molhtml = display_pdb(path_to_pdb)
96
 
97
+ return generated_sequence, molhtml
98
+ else:
99
+ return generated_sequence
100
 
101
  usg_app = gr.Interface(
102
  fn=make_uncond_seq,
 
117
  inputs=[
118
  gr.Slider(10, 100, label = "Sequence Length"),
119
  gr.File(file_types=["a3m"], label = "MSA File"),
120
+ gr.Dropdown(["EvoDiff-MSA"], value="EvoDiff-MSA", type="value", label = "Model"),
121
+ gr.Checkbox(value=False, label = "Predict Structure?")
122
  ],
123
  outputs=[
124
  "text",