aiqcamp commited on
Commit
93008f1
ยท
verified ยท
1 Parent(s): 6f38a8f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -21
app.py CHANGED
@@ -925,7 +925,7 @@ def process_chat_and_generate(message, history):
925
  secondary_structure=None,
926
  aa_bias=None,
927
  aa_bias_potential=None,
928
- num_steps="25",
929
  noise="normal",
930
  hydrophobic_target_score=str(params['hydrophobic_target_score']),
931
  hydrophobic_potential="2",
@@ -936,8 +936,33 @@ def process_chat_and_generate(message, history):
936
  rewrite_pdb=None
937
  )
938
 
939
- # 3. ์ƒ์„ฑ ๊ฒฐ๊ณผ ๊ฐ€์ ธ์˜ค๊ธฐ
940
- output_seq, output_pdb, structure_view, plddt_plot = next(generator)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
941
 
942
  # 4. ํžˆ์–ด๋กœ ๋Šฅ๋ ฅ์น˜ ๊ณ„์‚ฐ
943
  stats = calculate_hero_stats(
@@ -947,7 +972,7 @@ def process_chat_and_generate(message, history):
947
  hydrophobic_score=params['hydrophobic_target_score']
948
  )
949
 
950
- # 5. ์„ค๋ช… ์ƒ์„ฑ
951
  explanation = f"""
952
  ์š”์ฒญํ•˜์‹  ๊ธฐ๋Šฅ์— ๋งž๋Š” ๋‹จ๋ฐฑ์งˆ์„ ์ƒ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค:
953
 
@@ -960,23 +985,22 @@ def process_chat_and_generate(message, history):
960
  - ๋ฒ ํƒ€ ์‹œํŠธ ๋น„์œจ: {params['strand_bias']*100:.1f}%
961
  - ๋ฃจํ”„ ๊ตฌ์กฐ ๋น„์œจ: {params['loop_bias']*100:.1f}%
962
  - ์†Œ์ˆ˜์„ฑ ์ ์ˆ˜: {params['hydrophobic_target_score']}
963
- """
964
 
965
- # 6. ์ฑ—๋ด‡ ํžˆ์Šคํ† ๋ฆฌ ์—…๋ฐ์ดํŠธ
966
- new_history = history + [
967
- {"role": "user", "content": message},
968
- {"role": "assistant", "content": explanation}
969
- ]
970
 
971
- # 7. ๋ชจ๋“  ๊ฒฐ๊ณผ ๋ฐ˜ํ™˜
972
  return (
973
- new_history, # ์ฑ—๋ด‡ ํžˆ์Šคํ† ๋ฆฌ
974
- create_radar_chart(stats), # ๋Šฅ๋ ฅ์น˜ ์ฐจํŠธ
975
- explanation, # ์„ค๋ช…
976
- output_seq, # ๋‹จ๋ฐฑ์งˆ ์„œ์—ด
977
- output_pdb, # PDB ํŒŒ์ผ
978
- structure_view, # 3D ๊ตฌ์กฐ
979
- plddt_plot # ์‹ ๋ขฐ๋„ ํ”Œ๋กฏ
 
 
 
980
  )
981
 
982
  except Exception as e:
@@ -1495,9 +1519,6 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
1495
  queue=False
1496
  )
1497
 
1498
-
1499
-
1500
-
1501
  # ์ฑ—๋ด‡ ์‘๋‹ต์— ๋”ฐ๋ฅธ ๊ฒฐ๊ณผ ์—…๋ฐ์ดํŠธ
1502
  msg.submit(
1503
  update_protein_display,
@@ -1514,6 +1535,26 @@ with gr.Blocks(theme='ParityError/Interstellar') as demo:
1514
  [chatbot])
1515
  clear.click(lambda: None, None, chatbot, queue=False)
1516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1517
  # ์‹คํ–‰
1518
  demo.queue()
1519
  demo.launch(debug=True)
 
925
  secondary_structure=None,
926
  aa_bias=None,
927
  aa_bias_potential=None,
928
+ num_steps="25", # 25๋‹จ๊ณ„ ์„ค์ •
929
  noise="normal",
930
  hydrophobic_target_score=str(params['hydrophobic_target_score']),
931
  hydrophobic_potential="2",
 
936
  rewrite_pdb=None
937
  )
938
 
939
+ # 3. ๋ชจ๋“  ๋‹จ๊ณ„์˜ ๊ฒฐ๊ณผ ์ˆ˜์ง‘
940
+ final_result = None
941
+ for result in generator:
942
+ final_result = result
943
+ # ์ค‘๊ฐ„ ๊ฒฐ๊ณผ ์—…๋ฐ์ดํŠธ (์„ ํƒ์ )
944
+ yield (
945
+ history + [
946
+ {"role": "user", "content": message},
947
+ {"role": "assistant", "content": f"๋‹จ๋ฐฑ์งˆ ์ƒ์„ฑ ์ค‘... {len(result[3].get_lines()) if result[3] else 0}๋‹จ๊ณ„ ์™„๋ฃŒ"}
948
+ ],
949
+ create_radar_chart(calculate_hero_stats(
950
+ params['helix_bias'],
951
+ params['strand_bias'],
952
+ params['loop_bias'],
953
+ params['hydrophobic_target_score']
954
+ )),
955
+ f"๋‹จ๋ฐฑ์งˆ ์ƒ์„ฑ ์ง„ํ–‰ ์ค‘... {len(result[3].get_lines()) if result[3] else 0}๋‹จ๊ณ„ ์™„๋ฃŒ",
956
+ result[0], # output_seq
957
+ result[1], # output_pdb
958
+ result[2], # structure_view
959
+ result[3] # plddt_plot
960
+ )
961
+
962
+ if final_result is None:
963
+ raise Exception("์ƒ์„ฑ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค")
964
+
965
+ output_seq, output_pdb, structure_view, plddt_plot = final_result
966
 
967
  # 4. ํžˆ์–ด๋กœ ๋Šฅ๋ ฅ์น˜ ๊ณ„์‚ฐ
968
  stats = calculate_hero_stats(
 
972
  hydrophobic_score=params['hydrophobic_target_score']
973
  )
974
 
975
+ # 5. ์ตœ์ข… ์„ค๋ช… ์ƒ์„ฑ
976
  explanation = f"""
977
  ์š”์ฒญํ•˜์‹  ๊ธฐ๋Šฅ์— ๋งž๋Š” ๋‹จ๋ฐฑ์งˆ์„ ์ƒ์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค:
978
 
 
985
  - ๋ฒ ํƒ€ ์‹œํŠธ ๋น„์œจ: {params['strand_bias']*100:.1f}%
986
  - ๋ฃจํ”„ ๊ตฌ์กฐ ๋น„์œจ: {params['loop_bias']*100:.1f}%
987
  - ์†Œ์ˆ˜์„ฑ ์ ์ˆ˜: {params['hydrophobic_target_score']}
 
988
 
989
+ ์ƒ์„ฑ์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด {len(plddt_plot.get_lines()) if plddt_plot else 0}๋‹จ๊ณ„์˜ ์ตœ์ ํ™”๋ฅผ ์ˆ˜ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.
990
+ """
 
 
 
991
 
992
+ # 6. ์ตœ์ข… ๊ฒฐ๊ณผ ๋ฐ˜ํ™˜
993
  return (
994
+ history + [
995
+ {"role": "user", "content": message},
996
+ {"role": "assistant", "content": explanation}
997
+ ],
998
+ create_radar_chart(stats),
999
+ explanation,
1000
+ output_seq,
1001
+ output_pdb,
1002
+ structure_view,
1003
+ plddt_plot
1004
  )
1005
 
1006
  except Exception as e:
 
1519
  queue=False
1520
  )
1521
 
 
 
 
1522
  # ์ฑ—๋ด‡ ์‘๋‹ต์— ๋”ฐ๋ฅธ ๊ฒฐ๊ณผ ์—…๋ฐ์ดํŠธ
1523
  msg.submit(
1524
  update_protein_display,
 
1535
  [chatbot])
1536
  clear.click(lambda: None, None, chatbot, queue=False)
1537
 
1538
+ # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ์ˆ˜์ •
1539
+ msg.submit(
1540
+ fn=process_chat_and_generate,
1541
+ inputs=[msg, chatbot],
1542
+ outputs=[
1543
+ chatbot,
1544
+ hero_stats,
1545
+ hero_description,
1546
+ output_seq,
1547
+ output_pdb,
1548
+ output_viewer,
1549
+ plddt_plot
1550
+ ],
1551
+ show_progress=True
1552
+ ).then(
1553
+ lambda: None, # ์ง„ํ–‰ ์ƒํƒœ ์ดˆ๊ธฐํ™”
1554
+ None,
1555
+ None
1556
+ )
1557
+
1558
  # ์‹คํ–‰
1559
  demo.queue()
1560
  demo.launch(debug=True)