aiqcamp commited on
Commit
96198c4
Β·
verified Β·
1 Parent(s): a57ea9b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -13
app.py CHANGED
@@ -40,6 +40,7 @@ if not os.path.exists('./SEQDIFF_221219_equalTASKS_nostrSELFCOND_mod30.pt'):
40
  os.system('wget http://files.ipd.uw.edu/pub/sequence_diffusion/checkpoints/SEQDIFF_221219_equalTASKS_nostrSELFCOND_mod30.pt')
41
  print('Successfully Downloaded')
42
 
 
43
  from openai import OpenAI
44
  import gradio as gr
45
  import json # json λͺ¨λ“ˆ μΆ”κ°€
@@ -58,6 +59,9 @@ from model.util import writepdb
58
  from utils.inpainting_util import *
59
  import os
60
 
 
 
 
61
  # args λ‘œλ“œ
62
  with open('./tmp/args.json', 'r') as f:
63
  args = json.load(f)
@@ -1028,10 +1032,15 @@ def process_chat_and_generate(message, history):
1028
  None, None, None, None, None, None
1029
  )
1030
 
 
 
 
 
 
 
1031
  def extract_keywords(analysis):
1032
  """뢄석 ν…μŠ€νŠΈμ—μ„œ ν‚€μ›Œλ“œ μΆ”μΆœ"""
1033
  try:
1034
- # κΈ°λ³Έ ν‚€μ›Œλ“œ μΆ”μΆœ
1035
  keywords = []
1036
  # μ£Όμš” κΈ°λŠ₯ ν‚€μ›Œλ“œ
1037
  if "치료" in analysis: keywords.extend(["therapeutic", "binding"])
@@ -1048,7 +1057,7 @@ def extract_keywords(analysis):
1048
  if "베타" in analysis or "μ‹œνŠΈ" in analysis: keywords.append("sheet")
1049
  if "루프" in analysis: keywords.append("loop")
1050
 
1051
- return list(set(keywords)) # 쀑볡 제거
1052
  except Exception as e:
1053
  print(f"ν‚€μ›Œλ“œ μΆ”μΆœ 쀑 였λ₯˜: {str(e)}")
1054
  return []
@@ -1057,21 +1066,18 @@ def calculate_similarity(keywords, entry):
1057
  """ν‚€μ›Œλ“œμ™€ 데이터셋 ν•­λͺ© κ°„μ˜ μœ μ‚¬λ„ 계산"""
1058
  try:
1059
  score = 0
1060
- # 데이터셋 ꡬ쑰 확인 및 μ•ˆμ „ν•œ μ ‘κ·Ό
1061
- sequence = entry.get('sequence', '').lower() if isinstance(entry, dict) else str(entry).lower()
1062
-
1063
- # 데이터셋 ꡬ쑰 디버깅
1064
- print("Entry structure:", type(entry))
1065
- print("Entry content:", entry)
1066
 
1067
  for keyword in keywords:
1068
- # μ•ˆμ „ν•œ 접근을 μœ„ν•œ μˆ˜μ •
1069
- description = entry.get('description', '') if isinstance(entry, dict) else ''
1070
  if keyword in description.lower():
1071
  score += 2
1072
  if keyword in sequence:
1073
  score += 1
1074
- if isinstance(entry, dict) and 'secondary_structure' in entry:
1075
  sec_structure = entry['secondary_structure']
1076
  if keyword in ['helix'] and 'H' in sec_structure:
1077
  score += 1
@@ -1081,10 +1087,24 @@ def calculate_similarity(keywords, entry):
1081
  score += 1
1082
  return score
1083
  except Exception as e:
1084
- print(f"μœ μ‚¬λ„ 계산 쀑 상세 였λ₯˜: {str(e)}")
1085
- print("Entry:", entry)
1086
  return 0
1087
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1088
 
1089
 
1090
  def download_checkpoint_files():
 
40
  os.system('wget http://files.ipd.uw.edu/pub/sequence_diffusion/checkpoints/SEQDIFF_221219_equalTASKS_nostrSELFCOND_mod30.pt')
41
  print('Successfully Downloaded')
42
 
43
+
44
  from openai import OpenAI
45
  import gradio as gr
46
  import json # json λͺ¨λ“ˆ μΆ”κ°€
 
59
  from utils.inpainting_util import *
60
  import os
61
 
62
+ rom Bio import SeqIO, Align
63
+ from Bio.Seq import Seq
64
+
65
  # args λ‘œλ“œ
66
  with open('./tmp/args.json', 'r') as f:
67
  args = json.load(f)
 
1032
  None, None, None, None, None, None
1033
  )
1034
 
1035
+ # ν•„μš”ν•œ λͺ¨λ“ˆ μΆ”κ°€
1036
+ import json
1037
+ from Bio import SeqIO, Align
1038
+ from Bio.Seq import Seq
1039
+
1040
+ # μ‹œμž‘ 뢀뢄에 μΆ”κ°€
1041
  def extract_keywords(analysis):
1042
  """뢄석 ν…μŠ€νŠΈμ—μ„œ ν‚€μ›Œλ“œ μΆ”μΆœ"""
1043
  try:
 
1044
  keywords = []
1045
  # μ£Όμš” κΈ°λŠ₯ ν‚€μ›Œλ“œ
1046
  if "치료" in analysis: keywords.extend(["therapeutic", "binding"])
 
1057
  if "베타" in analysis or "μ‹œνŠΈ" in analysis: keywords.append("sheet")
1058
  if "루프" in analysis: keywords.append("loop")
1059
 
1060
+ return list(set(keywords))
1061
  except Exception as e:
1062
  print(f"ν‚€μ›Œλ“œ μΆ”μΆœ 쀑 였λ₯˜: {str(e)}")
1063
  return []
 
1066
  """ν‚€μ›Œλ“œμ™€ 데이터셋 ν•­λͺ© κ°„μ˜ μœ μ‚¬λ„ 계산"""
1067
  try:
1068
  score = 0
1069
+ if not entry or not isinstance(entry, dict):
1070
+ return 0
1071
+
1072
+ sequence = entry.get('sequence', '').lower()
1073
+ description = entry.get('description', '')
 
1074
 
1075
  for keyword in keywords:
 
 
1076
  if keyword in description.lower():
1077
  score += 2
1078
  if keyword in sequence:
1079
  score += 1
1080
+ if 'secondary_structure' in entry:
1081
  sec_structure = entry['secondary_structure']
1082
  if keyword in ['helix'] and 'H' in sec_structure:
1083
  score += 1
 
1087
  score += 1
1088
  return score
1089
  except Exception as e:
1090
+ print(f"μœ μ‚¬λ„ 계산 쀑 였λ₯˜: {str(e)}")
 
1091
  return 0
1092
 
1093
+ # plddt_data λ³€μˆ˜ μΆ”κ°€
1094
+ plddt_data = []
1095
+
1096
+ # 예제 ν”„λ‘¬ν”„νŠΈ 처리 ν•¨μˆ˜ μˆ˜μ •
1097
+ def use_example(example):
1098
+ try:
1099
+ if example:
1100
+ return example
1101
+ return ""
1102
+ except Exception as e:
1103
+ print(f"예제 처리 쀑 였λ₯˜: {str(e)}")
1104
+ return ""
1105
+
1106
+ # 이벀트 ν•Έλ“€λŸ¬μ—μ„œ ν•„μš”ν•œ λ³€μˆ˜λ“€ μ •μ˜
1107
+ current_protein_result = None
1108
 
1109
 
1110
  def download_checkpoint_files():