aiqcamp commited on
Commit
7fa8b10
ยท
verified ยท
1 Parent(s): 2446683

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import os,sys
2
-
3
  # install required packages
4
  os.system('pip install plotly') # plotly ์„ค์น˜
5
  os.system('pip install matplotlib') # matplotlib ์„ค์น˜
@@ -909,6 +909,8 @@ def update_protein_display(chat_response):
909
  }
910
  return None
911
 
 
 
912
  def process_chat_and_generate(message, history):
913
  try:
914
  # 1. ํ”„๋กฌํ”„ํŠธ ๋ถ„์„ ๋ฐ ํŒŒ๋ผ๋ฏธํ„ฐ ์„ค์ •
@@ -926,7 +928,7 @@ def process_chat_and_generate(message, history):
926
  secondary_structure=None,
927
  aa_bias=None,
928
  aa_bias_potential=None,
929
- num_steps="25", # 25๋‹จ๊ณ„ ์„ค์ •
930
  noise="normal",
931
  hydrophobic_target_score=str(params['hydrophobic_target_score']),
932
  hydrophobic_potential="2",
@@ -937,15 +939,21 @@ def process_chat_and_generate(message, history):
937
  rewrite_pdb=None
938
  )
939
 
940
-
941
  # 3. ๋ชจ๋“  ๋‹จ๊ณ„์˜ ๊ฒฐ๊ณผ ์ˆ˜์ง‘
942
  final_result = None
943
- plddt_data = [] # plddt ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•  ๋ฆฌ์ŠคํŠธ ์ถ”๊ฐ€
 
 
 
 
 
 
 
 
944
 
945
  for result in generator:
946
  final_result = result
947
  if result[3]: # plddt_plot์ด ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ
948
- # matplotlib ๊ทธ๋ž˜ํ”„์—์„œ ๋ฐ์ดํ„ฐ ์ถ”์ถœ
949
  ax = result[3].gca()
950
  if ax.lines:
951
  line = ax.lines[0]
@@ -957,12 +965,7 @@ def process_chat_and_generate(message, history):
957
  {"role": "user", "content": message},
958
  {"role": "assistant", "content": f"๋‹จ๋ฐฑ์งˆ ์ƒ์„ฑ ์ค‘... {len(plddt_data)}๋‹จ๊ณ„ ์™„๋ฃŒ"}
959
  ],
960
- create_radar_chart(calculate_hero_stats(
961
- params['helix_bias'],
962
- params['strand_bias'],
963
- params['loop_bias'],
964
- params['hydrophobic_target_score']
965
- )),
966
  f"๋‹จ๋ฐฑ์งˆ ์ƒ์„ฑ ์ง„ํ–‰ ์ค‘... {len(plddt_data)}๋‹จ๊ณ„ ์™„๋ฃŒ",
967
  result[0], # output_seq
968
  result[1], # output_pdb
@@ -990,7 +993,7 @@ def process_chat_and_generate(message, history):
990
  - ์†Œ์ˆ˜์„ฑ ์ ์ˆ˜: {params['hydrophobic_target_score']}
991
 
992
  ์ƒ์„ฑ์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด {len(plddt_data)}๋‹จ๊ณ„์˜ ์ตœ์ ํ™”๋ฅผ ์ˆ˜ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.
993
- ์ตœ์ข… ์•ˆ์ •์„ฑ ์ ์ˆ˜: {np.mean(plddt_data):.2f}
994
  """
995
 
996
  # 6. ์ตœ์ข… ๊ฒฐ๊ณผ ๋ฐ˜ํ™˜
 
1
  import os,sys
2
+ import traceback # ์ƒ๋‹จ์— ์ถ”๊ฐ€
3
  # install required packages
4
  os.system('pip install plotly') # plotly ์„ค์น˜
5
  os.system('pip install matplotlib') # matplotlib ์„ค์น˜
 
909
  }
910
  return None
911
 
912
+
913
+
914
  def process_chat_and_generate(message, history):
915
  try:
916
  # 1. ํ”„๋กฌํ”„ํŠธ ๋ถ„์„ ๋ฐ ํŒŒ๋ผ๋ฏธํ„ฐ ์„ค์ •
 
928
  secondary_structure=None,
929
  aa_bias=None,
930
  aa_bias_potential=None,
931
+ num_steps="25",
932
  noise="normal",
933
  hydrophobic_target_score=str(params['hydrophobic_target_score']),
934
  hydrophobic_potential="2",
 
939
  rewrite_pdb=None
940
  )
941
 
 
942
  # 3. ๋ชจ๋“  ๋‹จ๊ณ„์˜ ๊ฒฐ๊ณผ ์ˆ˜์ง‘
943
  final_result = None
944
+ plddt_data = []
945
+
946
+ # ํžˆ์–ด๋กœ ๋Šฅ๋ ฅ์น˜ ๊ณ„์‚ฐ
947
+ stats = calculate_hero_stats(
948
+ helix_bias=params['helix_bias'],
949
+ strand_bias=params['strand_bias'],
950
+ loop_bias=params['loop_bias'],
951
+ hydrophobic_score=float(params['hydrophobic_target_score'])
952
+ )
953
 
954
  for result in generator:
955
  final_result = result
956
  if result[3]: # plddt_plot์ด ์กด์žฌํ•˜๋Š” ๊ฒฝ์šฐ
 
957
  ax = result[3].gca()
958
  if ax.lines:
959
  line = ax.lines[0]
 
965
  {"role": "user", "content": message},
966
  {"role": "assistant", "content": f"๋‹จ๋ฐฑ์งˆ ์ƒ์„ฑ ์ค‘... {len(plddt_data)}๋‹จ๊ณ„ ์™„๋ฃŒ"}
967
  ],
968
+ create_radar_chart(stats),
 
 
 
 
 
969
  f"๋‹จ๋ฐฑ์งˆ ์ƒ์„ฑ ์ง„ํ–‰ ์ค‘... {len(plddt_data)}๋‹จ๊ณ„ ์™„๋ฃŒ",
970
  result[0], # output_seq
971
  result[1], # output_pdb
 
993
  - ์†Œ์ˆ˜์„ฑ ์ ์ˆ˜: {params['hydrophobic_target_score']}
994
 
995
  ์ƒ์„ฑ์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด {len(plddt_data)}๋‹จ๊ณ„์˜ ์ตœ์ ํ™”๋ฅผ ์ˆ˜ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.
996
+ ์ตœ์ข… ์•ˆ์ •์„ฑ ์ ์ˆ˜: {np.mean(plddt_data) if plddt_data else 0:.2f}
997
  """
998
 
999
  # 6. ์ตœ์ข… ๊ฒฐ๊ณผ ๋ฐ˜ํ™˜