Witold Wydmański commited on
Commit
3687063
1 Parent(s): 2316765

feat: add embeddings

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -38,6 +38,15 @@ def fold_prot_locally(sequence):
38
  pdb = convert_outputs_to_pdb(output)
39
  return pdb
40
 
 
 
 
 
 
 
 
 
 
41
  def suggest(option):
42
  if option == "Plastic degradation protein":
43
  suggestion = "MGSSHHHHHHSSGLVPRGSHMRGPNPTAASLEASAGPFTVRSFTVSRPSGYGAGTVYYPTNAGGTVGAIAIVPGYTARQSSIKWWGPRLASHGFVVITIDTNSTLDQPSSRSSQQMAALRQVASLNGTSSSPIYGKVDTARMGVMGWSMGGGGSLISAANNPSLKAAAPQAPWDSSTNFSSVTVPTLIFACENDSIAPVNSSALPIYDSMSRNAKQFLEINGGSHSCANSGNSNQALIGKKGVAWMKRFMDNDTRYSTFACENPNSTRVSDFRTANCSLEDPAANKARKEAELAAATAEQ"
@@ -153,8 +162,14 @@ with gr.Blocks() as demo:
153
  with gr.Column():
154
  out_mol = gr.HTML(label="3D Structure")
155
 
 
 
 
 
 
156
  name.change(fn=suggest, inputs=name, outputs=inp)
157
  btn.click(fold_prot_locally, inputs=[inp], outputs=[out], api_name="pdb")
 
158
  out.change(fn=molecule, inputs=[out], outputs=[out_mol], api_name="3d_fold")
159
 
160
  demo.launch()
 
38
  pdb = convert_outputs_to_pdb(output)
39
  return pdb
40
 
41
+ def get_esmfold_embeddings(sequence):
42
+ logger.info("Getting embeddings for: " + sequence)
43
+ tokenized_input = tokenizer([sequence], return_tensors="pt", add_special_tokens=False)['input_ids'].cuda()
44
+
45
+ with torch.no_grad():
46
+ output = model(tokenized_input)
47
+
48
+ return output["s_s"].cpu().numpy()
49
+
50
  def suggest(option):
51
  if option == "Plastic degradation protein":
52
  suggestion = "MGSSHHHHHHSSGLVPRGSHMRGPNPTAASLEASAGPFTVRSFTVSRPSGYGAGTVYYPTNAGGTVGAIAIVPGYTARQSSIKWWGPRLASHGFVVITIDTNSTLDQPSSRSSQQMAALRQVASLNGTSSSPIYGKVDTARMGVMGWSMGGGGSLISAANNPSLKAAAPQAPWDSSTNFSSVTVPTLIFACENDSIAPVNSSALPIYDSMSRNAKQFLEINGGSHSCANSGNSNQALIGKKGVAWMKRFMDNDTRYSTFACENPNSTRVSDFRTANCSLEDPAANKARKEAELAAATAEQ"
 
162
  with gr.Column():
163
  out_mol = gr.HTML(label="3D Structure")
164
 
165
+ with gr.Row(visible=False):
166
+ with gr.Column():
167
+ gr.Markdown("## Embeddings")
168
+ embs = gr.Code(label="Embeddings", interactive=False)
169
+
170
  name.change(fn=suggest, inputs=name, outputs=inp)
171
  btn.click(fold_prot_locally, inputs=[inp], outputs=[out], api_name="pdb")
172
+ btn.click(get_esmfold_embeddings, inputs=[inp], outputs=[embs], api_name="embeddings")
173
  out.change(fn=molecule, inputs=[out], outputs=[out_mol], api_name="3d_fold")
174
 
175
  demo.launch()