Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -285,16 +285,15 @@ def display_pdb(path_to_pdb):
|
|
285 |
'''
|
286 |
|
287 |
|
288 |
-
|
289 |
-
# MOTIF SCAFFOLDING
|
290 |
def get_motif_preview(pdb_id, contigs):
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
|
|
|
|
|
|
295 |
|
296 |
-
# rewrite pdb
|
297 |
-
parse = parse_pdb(input_pdb)
|
298 |
#output_name = './rewrite_'+input_pdb.split('/')[-1]
|
299 |
#writepdb(output_name, torch.tensor(parse_og['xyz']),torch.tensor(parse_og['seq']))
|
300 |
#parse = parse_pdb(output_name)
|
@@ -330,6 +329,9 @@ def get_motif_preview(pdb_id, contigs):
|
|
330 |
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
331 |
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>""", output_name
|
332 |
|
|
|
|
|
|
|
333 |
def fetch_pdb(pdb_id=None):
|
334 |
if pdb_id is None or pdb_id == "":
|
335 |
return None
|
@@ -402,20 +404,20 @@ def msa_to_pssm(msa_file):
|
|
402 |
return outdir
|
403 |
|
404 |
def get_pssm(fasta_msa, input_pssm):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
fig, ax = plt.subplots(figsize=(15,6))
|
413 |
-
plt.imshow(torch.permute(torch.tensor(pssm),(1,0)))
|
414 |
-
|
415 |
-
return fig, outdir
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
|
420 |
# ํ์ด๋ก ๋ฅ๋ ฅ์น ๊ณ์ฐ ํจ์ ์ถ๊ฐ
|
421 |
def calculate_hero_stats(helix_bias, strand_bias, loop_bias, hydrophobic_score):
|
@@ -682,6 +684,10 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
|
|
682 |
visible=True
|
683 |
)
|
684 |
|
|
|
|
|
|
|
|
|
685 |
# ์๋ฏธ๋
ธ์ฐ ๊ตฌ์ฑ ์ค์ ์ถ๊ฐ
|
686 |
with gr.Accordion(label='๐งฌ DNA ๊ตฌ์ฑ ์ค์ ', open=False):
|
687 |
gr.Markdown("""
|
@@ -771,6 +777,10 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
|
|
771 |
rewrite_pdb = gr.File(label='ํ์ด๋ก DNA ํ์ผ')
|
772 |
preview_btn = gr.Button("๐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ", variant="secondary")
|
773 |
|
|
|
|
|
|
|
|
|
774 |
with gr.TabItem("๐ ํ์ด๋ก ๊ฐ๋ฌธ"):
|
775 |
gr.Markdown("""
|
776 |
### ๐ฐ ์๋ํ ํ์ด๋ก ๊ฐ๋ฌธ์ ์ ์ฐ
|
@@ -789,6 +799,11 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
|
|
789 |
pssm_view = gr.Plot(label='๊ฐ๋ฌธ ํน์ฑ ๋ถ์ ๊ฒฐ๊ณผ')
|
790 |
pssm_gen_btn = gr.Button("โจ ๊ฐ๋ฌธ ํน์ฑ ๋ถ์", variant="secondary")
|
791 |
|
|
|
|
|
|
|
|
|
|
|
792 |
with gr.Column():
|
793 |
gr.Markdown("## ๐ฆธโโ๏ธ ํ์ด๋ก ํ๋กํ")
|
794 |
|
@@ -823,11 +838,30 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
|
|
823 |
queue=False
|
824 |
)
|
825 |
|
826 |
-
|
|
|
|
|
827 |
preview_btn.click(get_motif_preview,[pdb_id_code, contigs],[preview_viewer, rewrite_pdb])
|
828 |
pssm_gen_btn.click(get_pssm,[fasta_msa,input_pssm],[pssm_view, pssm])
|
829 |
|
|
|
|
|
|
|
|
|
|
|
|
|
830 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
831 |
|
832 |
# generate_hero์ protein_diffusion_model์ combined_generation์ผ๋ก ํตํฉ
|
833 |
create_btn.click(
|
|
|
285 |
'''
|
286 |
|
287 |
|
|
|
|
|
288 |
def get_motif_preview(pdb_id, contigs):
|
289 |
+
try:
|
290 |
+
input_pdb = fetch_pdb(pdb_id=pdb_id.lower() if pdb_id else None)
|
291 |
+
if input_pdb is None:
|
292 |
+
return gr.HTML("PDB ID๋ฅผ ์
๋ ฅํด์ฃผ์ธ์"), None
|
293 |
+
|
294 |
+
parse = parse_pdb(input_pdb)
|
295 |
+
|
296 |
|
|
|
|
|
297 |
#output_name = './rewrite_'+input_pdb.split('/')[-1]
|
298 |
#writepdb(output_name, torch.tensor(parse_og['xyz']),torch.tensor(parse_og['seq']))
|
299 |
#parse = parse_pdb(output_name)
|
|
|
329 |
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
330 |
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>""", output_name
|
331 |
|
332 |
+
except Exception as e:
|
333 |
+
return gr.HTML(f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"), None
|
334 |
+
|
335 |
def fetch_pdb(pdb_id=None):
|
336 |
if pdb_id is None or pdb_id == "":
|
337 |
return None
|
|
|
404 |
return outdir
|
405 |
|
406 |
def get_pssm(fasta_msa, input_pssm):
|
407 |
+
try:
|
408 |
+
if input_pssm is not None:
|
409 |
+
outdir = input_pssm.name
|
410 |
+
elif fasta_msa is not None:
|
411 |
+
outdir = save_pssm(fasta_msa)
|
412 |
+
else:
|
413 |
+
return gr.Plot(label="ํ์ผ์ ์
๋ก๋ํด์ฃผ์ธ์"), None
|
414 |
|
415 |
+
pssm = np.loadtxt(outdir, delimiter=",", dtype=float)
|
416 |
+
fig, ax = plt.subplots(figsize=(15,6))
|
417 |
+
plt.imshow(torch.permute(torch.tensor(pssm),(1,0)))
|
418 |
+
return fig, outdir
|
419 |
+
except Exception as e:
|
420 |
+
return gr.Plot(label=f"์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"), None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
|
422 |
# ํ์ด๋ก ๋ฅ๋ ฅ์น ๊ณ์ฐ ํจ์ ์ถ๊ฐ
|
423 |
def calculate_hero_stats(helix_bias, strand_bias, loop_bias, hydrophobic_score):
|
|
|
684 |
visible=True
|
685 |
)
|
686 |
|
687 |
+
|
688 |
+
design_btn = gr.Button("๐งฌ DNA ์ค๊ณ ์์ฑ!", variant="primary", scale=2)
|
689 |
+
|
690 |
+
|
691 |
# ์๋ฏธ๋
ธ์ฐ ๊ตฌ์ฑ ์ค์ ์ถ๊ฐ
|
692 |
with gr.Accordion(label='๐งฌ DNA ๊ตฌ์ฑ ์ค์ ', open=False):
|
693 |
gr.Markdown("""
|
|
|
777 |
rewrite_pdb = gr.File(label='ํ์ด๋ก DNA ํ์ผ')
|
778 |
preview_btn = gr.Button("๐ ๋ฏธ๋ฆฌ๋ณด๊ธฐ", variant="secondary")
|
779 |
|
780 |
+
|
781 |
+
enhance_btn = gr.Button("โก ๊ฐํ๋ ํ์ด๋ก ์์ฑ!", variant="primary", scale=2)
|
782 |
+
|
783 |
+
|
784 |
with gr.TabItem("๐ ํ์ด๋ก ๊ฐ๋ฌธ"):
|
785 |
gr.Markdown("""
|
786 |
### ๐ฐ ์๋ํ ํ์ด๋ก ๊ฐ๋ฌธ์ ์ ์ฐ
|
|
|
799 |
pssm_view = gr.Plot(label='๊ฐ๋ฌธ ํน์ฑ ๋ถ์ ๊ฒฐ๊ณผ')
|
800 |
pssm_gen_btn = gr.Button("โจ ๊ฐ๋ฌธ ํน์ฑ ๋ถ์", variant="secondary")
|
801 |
|
802 |
+
inherit_btn = gr.Button("๐ ๊ฐ๋ฌธ์ ํ ๊ณ์น!", variant="primary", scale=2)
|
803 |
+
|
804 |
+
|
805 |
+
|
806 |
+
|
807 |
with gr.Column():
|
808 |
gr.Markdown("## ๐ฆธโโ๏ธ ํ์ด๋ก ํ๋กํ")
|
809 |
|
|
|
838 |
queue=False
|
839 |
)
|
840 |
|
841 |
+
|
842 |
+
|
843 |
+
# ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
844 |
preview_btn.click(get_motif_preview,[pdb_id_code, contigs],[preview_viewer, rewrite_pdb])
|
845 |
pssm_gen_btn.click(get_pssm,[fasta_msa,input_pssm],[pssm_view, pssm])
|
846 |
|
847 |
+
# ๊ฐ ํญ์ ์์ฑ ๋ฒํผ ์ฐ๊ฒฐ
|
848 |
+
design_btn.click(
|
849 |
+
combined_generation,
|
850 |
+
inputs=[...], # DNA ์ค๊ณ์ ํ์ํ ์
๋ ฅ๊ฐ๋ค
|
851 |
+
outputs=[...] # ํ์ํ ์ถ๋ ฅ๊ฐ๋ค
|
852 |
+
)
|
853 |
|
854 |
+
enhance_btn.click(
|
855 |
+
combined_generation,
|
856 |
+
inputs=[...], # ์ ์ ์ ๊ฐํ์ ํ์ํ ์
๋ ฅ๊ฐ๋ค
|
857 |
+
outputs=[...] # ํ์ํ ์ถ๋ ฅ๊ฐ๋ค
|
858 |
+
)
|
859 |
+
|
860 |
+
inherit_btn.click(
|
861 |
+
combined_generation,
|
862 |
+
inputs=[...], # ๊ฐ๋ฌธ ๊ณ์น์ ํ์ํ ์
๋ ฅ๊ฐ๋ค
|
863 |
+
outputs=[...] # ํ์ํ ์ถ๋ ฅ๊ฐ๋ค
|
864 |
+
)
|
865 |
|
866 |
# generate_hero์ protein_diffusion_model์ combined_generation์ผ๋ก ํตํฉ
|
867 |
create_btn.click(
|