simonduerr commited on
Commit
82648e3
1 Parent(s): 2fb3d01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -26,6 +26,9 @@ from alphafold.model import data
26
  from alphafold.model import config
27
  from alphafold.model import model
28
 
 
 
 
29
 
30
  def update_seqs(choice):
31
  return gr.Textbox.update(choice)
@@ -123,7 +126,9 @@ def update_protGPT2(inp, length):
123
  generated_seqs = run_protgpt2(startsequence, seqlen)
124
  gen_seqs = [x["generated_text"] for x in generated_seqs]
125
  print(gen_seqs)
126
- return gr.Radio.update(gen_seqs)
 
 
127
 
128
 
129
  def update(inp):
@@ -312,6 +317,8 @@ def molecule(pdb):
312
  allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
313
  allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
314
 
 
 
315
 
316
  proteindream = gr.Blocks()
317
 
@@ -333,14 +340,10 @@ with proteindream:
333
  length = gr.Number(value=50, label="Target sequence length")
334
  btn = gr.Button("Predict sequences using protGPT2")
335
 
336
- seqs = []
337
- # "MTAEADPAPLAANPPAPVRPIQFHDVSVRYEARPWLRALWDVASGSFIGLLGASGAGKSTCVDLLNGVRKPSSGERFVRGQPSRGRKGRFNRRVAMVFQDVRHQLFSRSVAREIAFGLENLPTSAAAIDRRVS",
338
- # "MTAGIVAGGIAGGVAGYKAKKHRKAVKATMIAAGVSGGIGGGYIGEKFNRRLAKHEDRVRRSAPRHKKHSSYSKSSGEGGGILGKLFGR",
339
- # "MTAVLVAIALEMQNPHRMALAAVLCGQFTVAVAAEPFAPEGVAEGLNPLGDLLAESPLLEVVSATLALLVALGTATSLSWISGPVSALPAPSFQSSETPYPQRPIERESFDQDSREEDPWDRL",
340
- # "MTARVRNRSSSRSYVLDFADLADGQREVLLPESRGNASEVDLPAGTTVNVTIDVTASGTGTLTARTPDGADVVSNEYELTVERDTDLTRVETESPQVAAGETATVTGTAENVGTVAGEREVTAYVDGE",
341
- # "MTAAGWREEGTPFARIARQLGRHVTSVRQAAGRVRQQMGLTSPDPADPPRSGPTPTIPIEQERA",
342
- seqChoice = gr.Radio(seqs, label="Generated sequences")
343
- btn.click(fn=update_protGPT2, inputs=[inp, length], outputs=seqChoice)
344
  gr.Markdown("## AlphaFold")
345
  gr.Markdown(
346
  "Select a generated sequence above for structure prediction using AlphaFold2."
@@ -355,7 +358,7 @@ with proteindream:
355
  plot = gr.Plot(label="pLDDT")
356
  gr.Markdown(
357
  """## Acknowledgements
358
- This was a fun demo using Gradio, Huggingface and ColabFold. More information about the used algorithms can be found below.
359
 
360
  All code is available on [Github]() and licensed under MIT license.
361
 
 
26
  from alphafold.model import config
27
  from alphafold.model import model
28
 
29
+ data = {'id': [], 'sequence': [],'length': []}
30
+
31
+ sequencesdf = pd.DataFrame.from_dict(data)
32
 
33
  def update_seqs(choice):
34
  return gr.Textbox.update(choice)
 
126
  generated_seqs = run_protgpt2(startsequence, seqlen)
127
  gen_seqs = [x["generated_text"] for x in generated_seqs]
128
  print(gen_seqs)
129
+ data = {'id': range(len(gen_seqs), 'sequence': gen_seqs,'length': [len(x) for x in gen_seqs]}
130
+ sequencesdf = pd.DataFrame.from_dict(data)
131
+ return sequencesdf
132
 
133
 
134
  def update(inp):
 
317
  allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
318
  allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
319
 
320
+ def change_sequence(chosenSeq):
321
+ return chosenSeq
322
 
323
  proteindream = gr.Blocks()
324
 
 
340
  length = gr.Number(value=50, label="Target sequence length")
341
  btn = gr.Button("Predict sequences using protGPT2")
342
 
343
+ results = gr.Dataframe(sequences, label="Results", headers=["id","sequence", "length"])
344
+ seqChoice = gr.Radio(["sequence 1", "sequence 2", "sequence 3","sequence 4","sequence 5"], label="Choose a sequence")
345
+ btn.click(fn=update_protGPT2, inputs=[inp, length], outputs=results)
346
+ seqChoice.change(fn=chosenSeq, inputs=seqChoice, outputs=chosenSeq)
 
 
 
 
347
  gr.Markdown("## AlphaFold")
348
  gr.Markdown(
349
  "Select a generated sequence above for structure prediction using AlphaFold2."
 
358
  plot = gr.Plot(label="pLDDT")
359
  gr.Markdown(
360
  """## Acknowledgements
361
+ This was a fun demo using Gradio, Huggingface Spaces and ColabFold as inspiration. More information about the used algorithms can be found below.
362
 
363
  All code is available on [Github]() and licensed under MIT license.
364