aiqcamp commited on
Commit
1b950bb
ยท
verified ยท
1 Parent(s): a71505c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +135 -152
app.py CHANGED
@@ -1,15 +1,25 @@
1
  import os,sys
 
 
 
 
 
 
 
 
 
 
2
 
3
  # install required packages
4
- os.system('pip install plotly') # plotly ์„ค์น˜
5
- os.system('pip install matplotlib') # matplotlib ์„ค์น˜
6
  os.system('pip install dgl==1.0.2+cu116 -f https://data.dgl.ai/wheels/cu116/repo.html')
7
  os.environ["DGLBACKEND"] = "pytorch"
8
  print('Modules installed')
9
 
 
10
  import plotly.graph_objects as go
11
  import numpy as np
12
- import gradio as gr
13
  import py3Dmol
14
  from io import StringIO
15
  import json
@@ -21,59 +31,56 @@ from utils.parsers_inference import parse_pdb
21
  from model.util import writepdb
22
  from utils.inpainting_util import *
23
 
24
- # install environment goods
25
- #os.system("pip -q install dgl -f https://data.dgl.ai/wheels/cu113/repo.html")
26
- os.system('pip install dgl==1.0.2+cu116 -f https://data.dgl.ai/wheels/cu116/repo.html')
27
- #os.system('pip install gradio')
28
- os.environ["DGLBACKEND"] = "pytorch"
29
- #os.system(f'pip install -r ./PROTEIN_GENERATOR/requirements.txt')
30
- print('Modules installed')
31
-
32
- #os.system('pip install --force gradio==3.36.1')
33
- #os.system('pip install gradio_client==0.2.7')
34
- #os.system('pip install \"numpy<2\"')
35
- #os.system('pip install numpy --upgrade')
36
- #os.system('pip install --force numpy==1.24.1')
37
-
38
-
39
- if not os.path.exists('./SEQDIFF_230205_dssp_hotspots_25mask_EQtasks_mod30.pt'):
40
- print('Downloading model weights 1')
41
- os.system('wget http://files.ipd.uw.edu/pub/sequence_diffusion/checkpoints/SEQDIFF_230205_dssp_hotspots_25mask_EQtasks_mod30.pt')
42
- print('Successfully Downloaded')
43
-
44
- if not os.path.exists('./SEQDIFF_221219_equalTASKS_nostrSELFCOND_mod30.pt'):
45
- print('Downloading model weights 2')
46
- os.system('wget http://files.ipd.uw.edu/pub/sequence_diffusion/checkpoints/SEQDIFF_221219_equalTASKS_nostrSELFCOND_mod30.pt')
47
- print('Successfully Downloaded')
48
-
49
- import numpy as np
50
- import gradio as gr
51
- import py3Dmol
52
- from io import StringIO
53
- import json
54
- import secrets
55
- import copy
56
- import matplotlib.pyplot as plt
57
- from utils.sampler import HuggingFace_sampler
58
- from utils.parsers_inference import parse_pdb
59
- from model.util import writepdb
60
- from utils.inpainting_util import *
61
-
62
-
63
- plt.rcParams.update({'font.size': 13})
64
-
65
- with open('./tmp/args.json','r') as f:
66
- args = json.load(f)
 
 
 
 
 
 
67
 
68
- # manually set checkpoint to load
69
- args['checkpoint'] = None
70
- args['dump_trb'] = False
71
- args['dump_args'] = True
72
- args['save_best_plddt'] = True
73
- args['T'] = 25
74
- args['strand_bias'] = 0.0
75
- args['loop_bias'] = 0.0
76
- args['helix_bias'] = 0.0
77
 
78
  def protein_diffusion_model(sequence, seq_len, helix_bias, strand_bias, loop_bias,
79
  secondary_structure, aa_bias, aa_bias_potential,
@@ -543,11 +550,21 @@ def combined_generation(name, strength, flexibility, speed, defense, size, abili
543
  None
544
  )
545
 
 
546
  with gr.Blocks(theme='ParityError/Interstellar') as demo:
547
  with gr.Row():
548
- with gr.Column():
549
- gr.Markdown("# ๐Ÿฆธโ€โ™‚๏ธ ์Šˆํผํžˆ์–ด๋กœ ๋‹จ๋ฐฑ์งˆ ๋งŒ๋“ค๊ธฐ")
550
-
 
 
 
 
 
 
 
 
 
551
  with gr.Tabs():
552
  with gr.TabItem("๐Ÿฆธโ€โ™‚๏ธ ํžˆ์–ด๋กœ ๋””์ž์ธ"):
553
  gr.Markdown("""
@@ -616,9 +633,6 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
616
  # ์ƒ์„ฑ ๋ฒ„ํŠผ
617
  create_btn = gr.Button("๐Ÿงฌ ํžˆ์–ด๋กœ ์ƒ์„ฑ!", variant="primary", scale=2)
618
 
619
-
620
-
621
-
622
  with gr.TabItem("๐Ÿงฌ ํžˆ์–ด๋กœ DNA ์„ค๊ณ„"):
623
  gr.Markdown("""
624
  ### ๐Ÿงช ํžˆ์–ด๋กœ DNA ๊ณ ๊ธ‰ ์„ค์ •
@@ -681,7 +695,6 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
681
  visible=True
682
  )
683
 
684
- # ์•„๋ฏธ๋…ธ์‚ฐ ๊ตฌ์„ฑ ์„ค์ • ์ถ”๊ฐ€
685
  with gr.Accordion(label='๐Ÿงฌ DNA ๊ตฌ์„ฑ ์„ค์ •', open=False):
686
  gr.Markdown("""
687
  ํŠน์ • ์•„๋ฏธ๋…ธ์‚ฐ์˜ ๋น„์œจ์„ ์กฐ์ ˆํ•˜์—ฌ ํžˆ์–ด๋กœ์˜ ํŠน์„ฑ์„ ๊ฐ•ํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
@@ -699,7 +712,6 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
699
  placeholder='1.0-5.0 ์‚ฌ์ด ๊ฐ’ ์ž…๋ ฅ'
700
  )
701
 
702
- # ํ™˜๊ฒฝ ์ ์‘๋ ฅ ์„ค์ • ์ถ”๊ฐ€
703
  with gr.Accordion(label='๐ŸŒ ํ™˜๊ฒฝ ์ ์‘๋ ฅ ์„ค์ •', open=False):
704
  gr.Markdown("""
705
  ํžˆ์–ด๋กœ์˜ ํ™˜๊ฒฝ ์ ์‘๋ ฅ์„ ์กฐ์ ˆํ•ฉ๋‹ˆ๋‹ค.
@@ -717,7 +729,6 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
717
  placeholder='1.0-2.0 ์‚ฌ์ด ๊ฐ’ ์ž…๋ ฅ'
718
  )
719
 
720
- # ํ™•์‚ฐ ๋งค๊ฐœ๋ณ€์ˆ˜ ์„ค์ •
721
  with gr.Accordion(label='โš™๏ธ ๊ณ ๊ธ‰ ์„ค์ •', open=False):
722
  gr.Markdown("""
723
  DNA ์ƒ์„ฑ ๊ณผ์ •์˜ ์„ธ๋ถ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์กฐ์ •ํ•ฉ๋‹ˆ๋‹ค.
@@ -734,9 +745,7 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
734
  value='normal'
735
  )
736
 
737
- design_btn = gr.Button("๐Ÿงฌ DNA ์„ค๊ณ„ ์ƒ์„ฑ!", variant="primary", scale=2)
738
-
739
-
740
 
741
  with gr.TabItem("๐Ÿงช ํžˆ์–ด๋กœ ์œ ์ „์ž ๊ฐ•ํ™”"):
742
  gr.Markdown("""
@@ -792,21 +801,14 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
792
  pssm = gr.File(label='๋ถ„์„๋œ ๊ฐ€๋ฌธ ํŠน์„ฑ')
793
  pssm_view = gr.Plot(label='๊ฐ€๋ฌธ ํŠน์„ฑ ๋ถ„์„ ๊ฒฐ๊ณผ')
794
  pssm_gen_btn = gr.Button("โœจ ๊ฐ€๋ฌธ ํŠน์„ฑ ๋ถ„์„", variant="secondary")
795
- inherit_btn = gr.Button("๐Ÿ‘‘ ๊ฐ€๋ฌธ์˜ ํž˜ ๊ณ„์Šน!", variant="primary", scale=2)
796
-
797
 
798
-
799
-
800
-
801
- with gr.Column():
802
  gr.Markdown("## ๐Ÿฆธโ€โ™‚๏ธ ํžˆ์–ด๋กœ ํ”„๋กœํ•„")
803
-
804
- # ๋Šฅ๋ ฅ์น˜ ๋ ˆ์ด๋” ์ฐจํŠธ
805
  hero_stats = gr.Plot(label="๋Šฅ๋ ฅ์น˜ ๋ถ„์„")
806
-
807
- # ํžˆ์–ด๋กœ ์„ค๋ช…
808
  hero_description = gr.Textbox(label="ํžˆ์–ด๋กœ ํŠน์„ฑ", lines=3)
809
-
810
  gr.Markdown("## ๐Ÿงฌ ํžˆ์–ด๋กœ DNA ๋ถ„์„ ๊ฒฐ๊ณผ")
811
  gr.Markdown("#### โšก DNA ์•ˆ์ •์„ฑ ์ ์ˆ˜")
812
  plddt_plot = gr.Plot(label='์•ˆ์ •์„ฑ ๋ถ„์„')
@@ -818,6 +820,11 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
818
  output_viewer = gr.HTML()
819
 
820
  # ์ด๋ฒคํŠธ ์—ฐ๊ฒฐ
 
 
 
 
 
821
  seq_opt.change(
822
  fn=toggle_seq_input,
823
  inputs=[seq_opt],
@@ -832,85 +839,61 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
832
  queue=False
833
  )
834
 
835
- preview_btn.click(get_motif_preview,[pdb_id_code, contigs],[preview_viewer, rewrite_pdb])
836
- pssm_gen_btn.click(get_pssm,[fasta_msa,input_pssm],[pssm_view, pssm])
837
-
838
- # ๊ฐ ํƒญ์˜ ์ƒ์„ฑ ๋ฒ„ํŠผ ์—ฐ๊ฒฐ
839
- create_btn.click(
840
- combined_generation,
841
- inputs=[
842
- hero_name, strength, flexibility, speed, defense, hero_size, special_ability,
843
- sequence, seq_len, helix_bias, strand_bias, loop_bias,
844
- secondary_structure, aa_bias, aa_bias_potential,
845
- num_steps, noise, hydrophobic_target_score, hydrophobic_potential,
846
- contigs, pssm, seq_mask, str_mask, rewrite_pdb
847
- ],
848
- outputs=[
849
- hero_stats,
850
- hero_description,
851
- output_seq,
852
- output_pdb,
853
- output_viewer,
854
- plddt_plot
855
- ]
856
  )
857
 
858
- design_btn.click(
859
- combined_generation,
860
- inputs=[
861
- hero_name, strength, flexibility, speed, defense, hero_size, special_ability,
862
- sequence, seq_len, helix_bias, strand_bias, loop_bias,
863
- secondary_structure, aa_bias, aa_bias_potential,
864
- num_steps, noise, hydrophobic_target_score, hydrophobic_potential,
865
- contigs, pssm, seq_mask, str_mask, rewrite_pdb
866
- ],
867
- outputs=[
868
- hero_stats,
869
- hero_description,
870
- output_seq,
871
- output_pdb,
872
- output_viewer,
873
- plddt_plot
874
- ]
875
  )
876
 
877
- enhance_btn.click(
878
- combined_generation,
879
- inputs=[
880
- hero_name, strength, flexibility, speed, defense, hero_size, special_ability,
881
- sequence, seq_len, helix_bias, strand_bias, loop_bias,
882
- secondary_structure, aa_bias, aa_bias_potential,
883
- num_steps, noise, hydrophobic_target_score, hydrophobic_potential,
884
- contigs, pssm, seq_mask, str_mask, rewrite_pdb
885
- ],
886
- outputs=[
887
- hero_stats,
888
- hero_description,
889
- output_seq,
890
- output_pdb,
891
- output_viewer,
892
- plddt_plot
893
- ]
894
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
895
 
896
- inherit_btn.click(
897
- combined_generation,
898
- inputs=[
899
- hero_name, strength, flexibility, speed, defense, hero_size, special_ability,
900
- sequence, seq_len, helix_bias, strand_bias, loop_bias,
901
- secondary_structure, aa_bias, aa_bias_potential,
902
- num_steps, noise, hydrophobic_target_score, hydrophobic_potential,
903
- contigs, pssm, seq_mask, str_mask, rewrite_pdb
904
- ],
905
- outputs=[
906
- hero_stats,
907
- hero_description,
908
- output_seq,
909
- output_pdb,
910
- output_viewer,
911
- plddt_plot
912
- ]
913
  )
914
 
 
915
  demo.queue()
916
- demo.launch(debug=True)
 
1
  import os,sys
2
+ from transformers import pipeline
3
+ from datasets import load_dataset
4
+ import gradio as gr
5
+ from dotenv import load_dotenv
6
+
7
+ # ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ๋กœ๋“œ
8
+ load_dotenv()
9
+ HF_TOKEN = os.getenv("HF_TOKEN")
10
+ if not HF_TOKEN:
11
+ raise ValueError("HF_TOKEN not found in environment variables")
12
 
13
  # install required packages
14
+ os.system('pip install plotly')
15
+ os.system('pip install matplotlib')
16
  os.system('pip install dgl==1.0.2+cu116 -f https://data.dgl.ai/wheels/cu116/repo.html')
17
  os.environ["DGLBACKEND"] = "pytorch"
18
  print('Modules installed')
19
 
20
+ # ๊ธฐ์กด import๋ฌธ๋“ค ์œ ์ง€
21
  import plotly.graph_objects as go
22
  import numpy as np
 
23
  import py3Dmol
24
  from io import StringIO
25
  import json
 
31
  from model.util import writepdb
32
  from utils.inpainting_util import *
33
 
34
+ # ์ƒˆ๋กœ์šด ๋ชจ๋ธ๊ณผ ๋ฐ์ดํ„ฐ์…‹ ๋กœ๋“œ
35
+ pipe = pipeline("text-generation",
36
+ model="CohereForAI/c4ai-command-r-plus-08-2024",
37
+ token=HF_TOKEN)
38
+ ds = load_dataset("lamm-mit/protein_secondary_structure_from_PDB",
39
+ token=HF_TOKEN)
40
+
41
+ # ์ฑ—๋ด‡ ๋ฐ ๋‹จ๋ฐฑ์งˆ ์ƒ์„ฑ ๊ด€๋ จ ํ•จ์ˆ˜๋“ค
42
+ def process_chat(message, history):
43
+ messages = [{"role": "user", "content": message}]
44
+ response = pipe(messages)[0]['generated_text']
45
+
46
+ if any(keyword in message.lower() for keyword in ['protein', 'generate', '๋‹จ๋ฐฑ์งˆ', '์ƒ์„ฑ']):
47
+ relevant_data = search_protein_data(message)
48
+ params = extract_parameters(response, relevant_data)
49
+ protein_result = generate_protein(params)
50
+ explanation = generate_explanation(protein_result, params)
51
+ return response + "\n\n" + explanation
52
+
53
+ return response
54
+
55
+ def search_protein_data(query):
56
+ relevant_entries = []
57
+ for entry in ds['train']:
58
+ if any(keyword in entry['sequence'].lower() for keyword in query.lower().split()):
59
+ relevant_entries.append(entry)
60
+ return relevant_entries
61
+
62
+ def extract_parameters(llm_response, dataset_info):
63
+ params = {
64
+ 'sequence_length': 100,
65
+ 'helix_bias': 0.02,
66
+ 'strand_bias': 0.02,
67
+ 'loop_bias': 0.1,
68
+ 'hydrophobic_target_score': 0
69
+ }
70
+ return params
71
+
72
+ def generate_explanation(result, params):
73
+ explanation = f"""
74
+ ์ƒ์„ฑ๋œ ๋‹จ๋ฐฑ์งˆ ๋ถ„์„:
75
+ - ๊ธธ์ด: {params['sequence_length']} ์•„๋ฏธ๋…ธ์‚ฐ
76
+ - ๊ตฌ์กฐ์  ํŠน์ง•:
77
+ * ์•ŒํŒŒ ๋‚˜์„  ๋น„์œจ: {params['helix_bias']*100}%
78
+ * ๋ฒ ํƒ€ ์‹œํŠธ ๋น„์œจ: {params['strand_bias']*100}%
79
+ * ๋ฃจํ”„ ๊ตฌ์กฐ ๋น„์œจ: {params['loop_bias']*100}%
80
+ - ํŠน์ˆ˜ ๊ธฐ๋Šฅ: {result.get('special_features', '์—†์Œ')}
81
+ """
82
+ return explanation
83
 
 
 
 
 
 
 
 
 
 
84
 
85
  def protein_diffusion_model(sequence, seq_len, helix_bias, strand_bias, loop_bias,
86
  secondary_structure, aa_bias, aa_bias_potential,
 
550
  None
551
  )
552
 
553
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ˆ˜์ •
554
  with gr.Blocks(theme='ParityError/Interstellar') as demo:
555
  with gr.Row():
556
+ # ์™ผ์ชฝ ์—ด: ์ฑ—๋ด‡ ๋ฐ ์ปจํŠธ๋กค ํŒจ๋„
557
+ with gr.Column(scale=1):
558
+ # ์ฑ—๋ด‡ ์ธํ„ฐํŽ˜์ด์Šค
559
+ gr.Markdown("# ๐Ÿค– AI ๋‹จ๋ฐฑ์งˆ ์„ค๊ณ„ ๋„์šฐ๋ฏธ")
560
+ chatbot = gr.Chatbot()
561
+ msg = gr.Textbox(
562
+ label="๋ช…๋ น์„ ์ž…๋ ฅํ•˜์„ธ์š” (์˜ˆ: COVID-19๋ฅผ ์น˜๋ฃŒํ•  ์ˆ˜ ์žˆ๋Š” ๋‹จ๋ฐฑ์งˆ์„ ์ƒ์„ฑํ•ด์ฃผ์„ธ์š”)",
563
+ placeholder="์—ฌ๊ธฐ์— ์ž…๋ ฅํ•˜์„ธ์š”..."
564
+ )
565
+ clear = gr.Button("๋Œ€ํ™” ๋‚ด์šฉ ์ง€์šฐ๊ธฐ")
566
+
567
+ # ํƒญ ์ธํ„ฐํŽ˜์ด์Šค
568
  with gr.Tabs():
569
  with gr.TabItem("๐Ÿฆธโ€โ™‚๏ธ ํžˆ์–ด๋กœ ๋””์ž์ธ"):
570
  gr.Markdown("""
 
633
  # ์ƒ์„ฑ ๋ฒ„ํŠผ
634
  create_btn = gr.Button("๐Ÿงฌ ํžˆ์–ด๋กœ ์ƒ์„ฑ!", variant="primary", scale=2)
635
 
 
 
 
636
  with gr.TabItem("๐Ÿงฌ ํžˆ์–ด๋กœ DNA ์„ค๊ณ„"):
637
  gr.Markdown("""
638
  ### ๐Ÿงช ํžˆ์–ด๋กœ DNA ๊ณ ๊ธ‰ ์„ค์ •
 
695
  visible=True
696
  )
697
 
 
698
  with gr.Accordion(label='๐Ÿงฌ DNA ๊ตฌ์„ฑ ์„ค์ •', open=False):
699
  gr.Markdown("""
700
  ํŠน์ • ์•„๋ฏธ๋…ธ์‚ฐ์˜ ๋น„์œจ์„ ์กฐ์ ˆํ•˜์—ฌ ํžˆ์–ด๋กœ์˜ ํŠน์„ฑ์„ ๊ฐ•ํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
 
712
  placeholder='1.0-5.0 ์‚ฌ์ด ๊ฐ’ ์ž…๋ ฅ'
713
  )
714
 
 
715
  with gr.Accordion(label='๐ŸŒ ํ™˜๊ฒฝ ์ ์‘๋ ฅ ์„ค์ •', open=False):
716
  gr.Markdown("""
717
  ํžˆ์–ด๋กœ์˜ ํ™˜๊ฒฝ ์ ์‘๋ ฅ์„ ์กฐ์ ˆํ•ฉ๋‹ˆ๋‹ค.
 
729
  placeholder='1.0-2.0 ์‚ฌ์ด ๊ฐ’ ์ž…๋ ฅ'
730
  )
731
 
 
732
  with gr.Accordion(label='โš™๏ธ ๊ณ ๊ธ‰ ์„ค์ •', open=False):
733
  gr.Markdown("""
734
  DNA ์ƒ์„ฑ ๊ณผ์ •์˜ ์„ธ๋ถ€ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์กฐ์ •ํ•ฉ๋‹ˆ๋‹ค.
 
745
  value='normal'
746
  )
747
 
748
+ design_btn = gr.Button("๐Ÿงฌ DNA ์„ค๊ณ„ ์ƒ์„ฑ!", variant="primary", scale=2)
 
 
749
 
750
  with gr.TabItem("๐Ÿงช ํžˆ์–ด๋กœ ์œ ์ „์ž ๊ฐ•ํ™”"):
751
  gr.Markdown("""
 
801
  pssm = gr.File(label='๋ถ„์„๋œ ๊ฐ€๋ฌธ ํŠน์„ฑ')
802
  pssm_view = gr.Plot(label='๊ฐ€๋ฌธ ํŠน์„ฑ ๋ถ„์„ ๊ฒฐ๊ณผ')
803
  pssm_gen_btn = gr.Button("โœจ ๊ฐ€๋ฌธ ํŠน์„ฑ ๋ถ„์„", variant="secondary")
804
+ inherit_btn = gr.Button("๐Ÿ‘‘ ๊ฐ€๋ฌธ์˜ ํž˜ ๊ณ„์Šน!", variant="primary", scale=2)
 
805
 
806
+ # ์˜ค๋ฅธ์ชฝ ์—ด: ๊ฒฐ๊ณผ ํ‘œ์‹œ
807
+ with gr.Column(scale=1):
 
 
808
  gr.Markdown("## ๐Ÿฆธโ€โ™‚๏ธ ํžˆ์–ด๋กœ ํ”„๋กœํ•„")
 
 
809
  hero_stats = gr.Plot(label="๋Šฅ๋ ฅ์น˜ ๋ถ„์„")
 
 
810
  hero_description = gr.Textbox(label="ํžˆ์–ด๋กœ ํŠน์„ฑ", lines=3)
811
+
812
  gr.Markdown("## ๐Ÿงฌ ํžˆ์–ด๋กœ DNA ๋ถ„์„ ๊ฒฐ๊ณผ")
813
  gr.Markdown("#### โšก DNA ์•ˆ์ •์„ฑ ์ ์ˆ˜")
814
  plddt_plot = gr.Plot(label='์•ˆ์ •์„ฑ ๋ถ„์„')
 
820
  output_viewer = gr.HTML()
821
 
822
  # ์ด๋ฒคํŠธ ์—ฐ๊ฒฐ
823
+ # ์ฑ—๋ด‡ ์ด๋ฒคํŠธ
824
+ msg.submit(process_chat, [msg, chatbot], [chatbot])
825
+ clear.click(lambda: None, None, chatbot, queue=False)
826
+
827
+ # UI ์ปจํŠธ๋กค ์ด๋ฒคํŠธ
828
  seq_opt.change(
829
  fn=toggle_seq_input,
830
  inputs=[seq_opt],
 
839
  queue=False
840
  )
841
 
842
+ preview_btn.click(
843
+ get_motif_preview,
844
+ inputs=[pdb_id_code, contigs],
845
+ outputs=[preview_viewer, rewrite_pdb]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
846
  )
847
 
848
+ pssm_gen_btn.click(
849
+ get_pssm,
850
+ inputs=[fasta_msa, input_pssm],
851
+ outputs=[pssm_view, pssm]
 
 
 
 
 
 
 
 
 
 
 
 
 
852
  )
853
 
854
+ # ์ฑ—๋ด‡ ๊ธฐ๋ฐ˜ ๋‹จ๋ฐฑ์งˆ ์ƒ์„ฑ ๊ฒฐ๊ณผ ์—…๋ฐ์ดํŠธ
855
+ def update_protein_display(chat_response):
856
+ if "์ƒ์„ฑ๋œ ๋‹จ๋ฐฑ์งˆ ๋ถ„์„" in chat_response:
857
+ params = extract_parameters_from_chat(chat_response)
858
+ result = generate_protein(params)
859
+ return {
860
+ hero_stats: create_radar_chart(calculate_hero_stats(params)),
861
+ hero_description: chat_response,
862
+ output_seq: result[0],
863
+ output_pdb: result[1],
864
+ output_viewer: display_pdb(result[1]),
865
+ plddt_plot: result[3]
866
+ }
867
+ return None
868
+
869
+ # ๊ฐ ์ƒ์„ฑ ๋ฒ„ํŠผ ์ด๋ฒคํŠธ ์—ฐ๊ฒฐ
870
+ for btn in [create_btn, design_btn, enhance_btn, inherit_btn]:
871
+ btn.click(
872
+ combined_generation,
873
+ inputs=[
874
+ hero_name, strength, flexibility, speed, defense, hero_size, special_ability,
875
+ sequence, seq_len, helix_bias, strand_bias, loop_bias,
876
+ secondary_structure, aa_bias, aa_bias_potential,
877
+ num_steps, noise, hydrophobic_target_score, hydrophobic_potential,
878
+ contigs, pssm, seq_mask, str_mask, rewrite_pdb
879
+ ],
880
+ outputs=[
881
+ hero_stats,
882
+ hero_description,
883
+ output_seq,
884
+ output_pdb,
885
+ output_viewer,
886
+ plddt_plot
887
+ ]
888
+ )
889
 
890
+ # ์ฑ—๋ด‡ ์‘๋‹ต์— ๋”ฐ๋ฅธ ๊ฒฐ๊ณผ ์—…๋ฐ์ดํŠธ
891
+ msg.submit(
892
+ update_protein_display,
893
+ inputs=[chatbot],
894
+ outputs=[hero_stats, hero_description, output_seq, output_pdb, output_viewer, plddt_plot]
 
 
 
 
 
 
 
 
 
 
 
 
895
  )
896
 
897
+ # ์‹คํ–‰
898
  demo.queue()
899
+ demo.launch(debug=True)