Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -845,6 +845,69 @@ def combined_generation(name, strength, flexibility, speed, defense, size, abili
|
|
845 |
)
|
846 |
|
847 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
848 |
def process_chat_and_generate(message, history):
|
849 |
try:
|
850 |
# 1. ํ๋กฌํํธ ๋ถ์ ๋ฐ ํ๋ผ๋ฏธํฐ ์ค์
|
@@ -876,7 +939,15 @@ def process_chat_and_generate(message, history):
|
|
876 |
# 3. ์์ฑ ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
877 |
output_seq, output_pdb, structure_view, plddt_plot = next(generator)
|
878 |
|
879 |
-
# 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
880 |
explanation = f"""
|
881 |
์์ฒญํ์ ๊ธฐ๋ฅ์ ๋ง๋ ๋จ๋ฐฑ์ง์ ์์ฑํ์ต๋๋ค:
|
882 |
|
@@ -891,16 +962,16 @@ def process_chat_and_generate(message, history):
|
|
891 |
- ์์์ฑ ์ ์: {params['hydrophobic_target_score']}
|
892 |
"""
|
893 |
|
894 |
-
#
|
895 |
new_history = history + [
|
896 |
{"role": "user", "content": message},
|
897 |
{"role": "assistant", "content": explanation}
|
898 |
]
|
899 |
|
900 |
-
#
|
901 |
return (
|
902 |
new_history, # ์ฑ๋ด ํ์คํ ๋ฆฌ
|
903 |
-
create_radar_chart(
|
904 |
explanation, # ์ค๋ช
|
905 |
output_seq, # ๋จ๋ฐฑ์ง ์์ด
|
906 |
output_pdb, # PDB ํ์ผ
|
@@ -975,34 +1046,7 @@ def calculate_similarity(keywords, entry):
|
|
975 |
print("Entry:", entry)
|
976 |
return 0
|
977 |
|
978 |
-
|
979 |
-
"""์ฑ๋ด ์๋ต์์ ํ๋ผ๋ฏธํฐ ์ถ์ถ"""
|
980 |
-
try:
|
981 |
-
params = {
|
982 |
-
'sequence_length': 100,
|
983 |
-
'helix_bias': 0.02,
|
984 |
-
'strand_bias': 0.02,
|
985 |
-
'loop_bias': 0.1,
|
986 |
-
'hydrophobic_target_score': 0
|
987 |
-
}
|
988 |
-
|
989 |
-
# ์๋ต ํ
์คํธ์์ ๊ฐ ์ถ์ถ
|
990 |
-
if "๊ธธ์ด:" in chat_response:
|
991 |
-
length_match = re.search(r'๊ธธ์ด: (\d+)', chat_response)
|
992 |
-
if length_match:
|
993 |
-
params['sequence_length'] = int(length_match.group(1))
|
994 |
-
|
995 |
-
if "์ํ ํฌ๋ฆญ์ค ๋น์จ:" in chat_response:
|
996 |
-
helix_match = re.search(r'์ํ ํฌ๋ฆญ์ค ๋น์จ: ([\d.]+)', chat_response)
|
997 |
-
if helix_match:
|
998 |
-
params['helix_bias'] = float(helix_match.group(1)) / 100
|
999 |
-
|
1000 |
-
# ๋๋จธ์ง ํ๋ผ๋ฏธํฐ๋ ์ ์ฌํ๊ฒ ์ถ์ถ
|
1001 |
-
|
1002 |
-
return params
|
1003 |
-
except Exception as e:
|
1004 |
-
print(f"ํ๋ผ๋ฏธํฐ ์ถ์ถ ์ค ์ค๋ฅ: {str(e)}")
|
1005 |
-
return None
|
1006 |
|
1007 |
def download_checkpoint_files():
|
1008 |
"""ํ์ํ ์ฒดํฌํฌ์ธํธ ํ์ผ ๋ค์ด๋ก๋"""
|
|
|
845 |
)
|
846 |
|
847 |
|
848 |
+
def extract_parameters_from_chat(chat_response):
|
849 |
+
"""์ฑ๋ด ์๋ต์์ ํ๋ผ๋ฏธํฐ ์ถ์ถ"""
|
850 |
+
try:
|
851 |
+
params = {
|
852 |
+
'sequence_length': 100,
|
853 |
+
'helix_bias': 0.02,
|
854 |
+
'strand_bias': 0.02,
|
855 |
+
'loop_bias': 0.1,
|
856 |
+
'hydrophobic_target_score': 0
|
857 |
+
}
|
858 |
+
|
859 |
+
# ์๋ต ํ
์คํธ์์ ๊ฐ ์ถ์ถ
|
860 |
+
if "๊ธธ์ด:" in chat_response:
|
861 |
+
length_match = re.search(r'๊ธธ์ด: (\d+)', chat_response)
|
862 |
+
if length_match:
|
863 |
+
params['sequence_length'] = int(length_match.group(1))
|
864 |
+
|
865 |
+
if "์ํ ํฌ๋ฆญ์ค ๋น์จ:" in chat_response:
|
866 |
+
helix_match = re.search(r'์ํ ํฌ๋ฆญ์ค ๋น์จ: ([\d.]+)', chat_response)
|
867 |
+
if helix_match:
|
868 |
+
params['helix_bias'] = float(helix_match.group(1)) / 100
|
869 |
+
|
870 |
+
if "๋ฒ ํ ์ํธ ๋น์จ:" in chat_response:
|
871 |
+
strand_match = re.search(r'๋ฒ ํ ์ํธ ๋น์จ: ([\d.]+)', chat_response)
|
872 |
+
if strand_match:
|
873 |
+
params['strand_bias'] = float(strand_match.group(1)) / 100
|
874 |
+
|
875 |
+
if "๋ฃจํ ๊ตฌ์กฐ ๋น์จ:" in chat_response:
|
876 |
+
loop_match = re.search(r'๋ฃจํ ๊ตฌ์กฐ ๋น์จ: ([\d.]+)', chat_response)
|
877 |
+
if loop_match:
|
878 |
+
params['loop_bias'] = float(loop_match.group(1)) / 100
|
879 |
+
|
880 |
+
if "์์์ฑ ์ ์:" in chat_response:
|
881 |
+
hydro_match = re.search(r'์์์ฑ ์ ์: ([-\d.]+)', chat_response)
|
882 |
+
if hydro_match:
|
883 |
+
params['hydrophobic_target_score'] = float(hydro_match.group(1))
|
884 |
+
|
885 |
+
return params
|
886 |
+
except Exception as e:
|
887 |
+
print(f"ํ๋ผ๋ฏธํฐ ์ถ์ถ ์ค ์ค๋ฅ: {str(e)}")
|
888 |
+
return None
|
889 |
+
|
890 |
+
def update_protein_display(chat_response):
|
891 |
+
if "์์ฑ๋ ๋จ๋ฐฑ์ง ๋ถ์" in chat_response:
|
892 |
+
params = extract_parameters_from_chat(chat_response)
|
893 |
+
if params:
|
894 |
+
result = generate_protein(params)
|
895 |
+
stats = calculate_hero_stats(
|
896 |
+
helix_bias=params['helix_bias'],
|
897 |
+
strand_bias=params['strand_bias'],
|
898 |
+
loop_bias=params['loop_bias'],
|
899 |
+
hydrophobic_score=params['hydrophobic_target_score']
|
900 |
+
)
|
901 |
+
return {
|
902 |
+
hero_stats: create_radar_chart(stats),
|
903 |
+
hero_description: chat_response,
|
904 |
+
output_seq: result[0],
|
905 |
+
output_pdb: result[1],
|
906 |
+
output_viewer: display_pdb(result[1]),
|
907 |
+
plddt_plot: result[3]
|
908 |
+
}
|
909 |
+
return None
|
910 |
+
|
911 |
def process_chat_and_generate(message, history):
|
912 |
try:
|
913 |
# 1. ํ๋กฌํํธ ๋ถ์ ๋ฐ ํ๋ผ๋ฏธํฐ ์ค์
|
|
|
939 |
# 3. ์์ฑ ๊ฒฐ๊ณผ ๊ฐ์ ธ์ค๊ธฐ
|
940 |
output_seq, output_pdb, structure_view, plddt_plot = next(generator)
|
941 |
|
942 |
+
# 4. ํ์ด๋ก ๋ฅ๋ ฅ์น ๊ณ์ฐ
|
943 |
+
stats = calculate_hero_stats(
|
944 |
+
helix_bias=params['helix_bias'],
|
945 |
+
strand_bias=params['strand_bias'],
|
946 |
+
loop_bias=params['loop_bias'],
|
947 |
+
hydrophobic_score=params['hydrophobic_target_score']
|
948 |
+
)
|
949 |
+
|
950 |
+
# 5. ์ค๋ช
์์ฑ
|
951 |
explanation = f"""
|
952 |
์์ฒญํ์ ๊ธฐ๋ฅ์ ๋ง๋ ๋จ๋ฐฑ์ง์ ์์ฑํ์ต๋๋ค:
|
953 |
|
|
|
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 ํ์ผ
|
|
|
1046 |
print("Entry:", entry)
|
1047 |
return 0
|
1048 |
|
1049 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1050 |
|
1051 |
def download_checkpoint_files():
|
1052 |
"""ํ์ํ ์ฒดํฌํฌ์ธํธ ํ์ผ ๋ค์ด๋ก๋"""
|