aiqcamp commited on
Commit
72b6bdd
·
verified ·
1 Parent(s): 25d992f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -12
app.py CHANGED
@@ -50,6 +50,12 @@ from utils.sampler import HuggingFace_sampler
50
  from utils.parsers_inference import parse_pdb
51
  from model.util import writepdb
52
  from utils.inpainting_util import *
 
 
 
 
 
 
53
 
54
  # Hugging Face 토큰 설정
55
  ACCESS_TOKEN = os.getenv("HF_TOKEN")
@@ -329,19 +335,23 @@ def generate_explanation(result, params):
329
  """
330
  return explanation
331
 
 
332
 
333
 
334
  def protein_diffusion_model(sequence, seq_len, helix_bias, strand_bias, loop_bias,
335
  secondary_structure, aa_bias, aa_bias_potential,
336
  num_steps, noise, hydrophobic_target_score, hydrophobic_potential,
337
  contigs, pssm, seq_mask, str_mask, rewrite_pdb):
338
-
339
 
340
- dssp_checkpoint = './SEQDIFF_230205_dssp_hotspots_25mask_EQtasks_mod30.pt'
341
- og_checkpoint = './SEQDIFF_221219_equalTASKS_nostrSELFCOND_mod30.pt'
342
-
 
 
 
343
  model_args = copy.deepcopy(args)
344
 
 
345
  # make sampler
346
  S = HuggingFace_sampler(args=model_args)
347
 
@@ -902,23 +912,32 @@ def calculate_similarity(keywords, entry):
902
  """키워드와 데이터셋 항목 간의 유사도 계산"""
903
  try:
904
  score = 0
905
- # 시퀀스 특성 검사
906
- sequence = entry['sequence'].lower()
 
 
 
 
 
907
  for keyword in keywords:
908
- if keyword in entry.get('description', '').lower():
 
 
909
  score += 2
910
  if keyword in sequence:
911
  score += 1
912
- if 'secondary_structure' in entry:
913
- if keyword in ['helix'] and 'H' in entry['secondary_structure']:
 
914
  score += 1
915
- if keyword in ['sheet'] and 'E' in entry['secondary_structure']:
916
  score += 1
917
- if keyword in ['loop'] and 'L' in entry['secondary_structure']:
918
  score += 1
919
  return score
920
  except Exception as e:
921
- print(f"유사도 계산 중 오류: {str(e)}")
 
922
  return 0
923
 
924
  def extract_parameters_from_chat(chat_response):
 
50
  from utils.parsers_inference import parse_pdb
51
  from model.util import writepdb
52
  from utils.inpainting_util import *
53
+ import os
54
+
55
+ # 현재 스크립트의 디렉토리를 기준으로 체크포인트 파일 경로 설정
56
+ current_dir = os.path.dirname(os.path.abspath(__file__))
57
+ dssp_checkpoint = os.path.join(current_dir, 'SEQDIFF_230205_dssp_hotspots_25mask_EQtasks_mod30.pt')
58
+ og_checkpoint = os.path.join(current_dir, 'SEQDIFF_221219_equalTASKS_nostrSELFCOND_mod30.pt')
59
 
60
  # Hugging Face 토큰 설정
61
  ACCESS_TOKEN = os.getenv("HF_TOKEN")
 
335
  """
336
  return explanation
337
 
338
+ # 체크포인트 파일 경로를 절대 경로로 수정
339
 
340
 
341
  def protein_diffusion_model(sequence, seq_len, helix_bias, strand_bias, loop_bias,
342
  secondary_structure, aa_bias, aa_bias_potential,
343
  num_steps, noise, hydrophobic_target_score, hydrophobic_potential,
344
  contigs, pssm, seq_mask, str_mask, rewrite_pdb):
 
345
 
346
+ # 체크포인트 파일 존재 확인
347
+ if not os.path.exists(dssp_checkpoint):
348
+ raise FileNotFoundError(f"DSSP checkpoint file not found at: {dssp_checkpoint}")
349
+ if not os.path.exists(og_checkpoint):
350
+ raise FileNotFoundError(f"OG checkpoint file not found at: {og_checkpoint}")
351
+
352
  model_args = copy.deepcopy(args)
353
 
354
+
355
  # make sampler
356
  S = HuggingFace_sampler(args=model_args)
357
 
 
912
  """키워드와 데이터셋 항목 간의 유사도 계산"""
913
  try:
914
  score = 0
915
+ # 데이터셋 구조 확인 및 안전한 접근
916
+ sequence = entry.get('sequence', '').lower() if isinstance(entry, dict) else str(entry).lower()
917
+
918
+ # 데이터셋 구조 디버깅
919
+ print("Entry structure:", type(entry))
920
+ print("Entry content:", entry)
921
+
922
  for keyword in keywords:
923
+ # 안전한 접근을 위한 수정
924
+ description = entry.get('description', '') if isinstance(entry, dict) else ''
925
+ if keyword in description.lower():
926
  score += 2
927
  if keyword in sequence:
928
  score += 1
929
+ if isinstance(entry, dict) and 'secondary_structure' in entry:
930
+ sec_structure = entry['secondary_structure']
931
+ if keyword in ['helix'] and 'H' in sec_structure:
932
  score += 1
933
+ if keyword in ['sheet'] and 'E' in sec_structure:
934
  score += 1
935
+ if keyword in ['loop'] and 'L' in sec_structure:
936
  score += 1
937
  return score
938
  except Exception as e:
939
+ print(f"유사도 계산 중 상세 오류: {str(e)}")
940
+ print("Entry:", entry)
941
  return 0
942
 
943
  def extract_parameters_from_chat(chat_response):