File size: 2,684 Bytes
91f863a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
"""
utils.py - μƒμˆ˜ μ •μ˜ 및 μœ ν‹Έλ¦¬ν‹° ν•¨μˆ˜
"""
import os
from typing import Dict, List

# 데이터셋 섀정을 μœ„ν•œ Class name μ •μ˜
DIDB_FILTER_COLS = [
    "logP",
    "pKa",
    "solubility",
    "permeability", 
    "plasma_protein_binding",
    # "fm_in_vitro",
    "fu_in_vitro",
    # "CYP450_Enzyme"
]

LOAD_DATA_PATH = {
    "didb":"./dataset_v2/categorized_dataset/preprocessed_DIDBset.csv",
    "portal":"./dataset_v2/categorized_dataset/preprocessed_portal.csv",
    "kist":"./dataset_v2/categorized_dataset/convert_kist_data.csv",
    "all":"./dataset_v2/categorized_dataset/total.csv"
}

LOAD_PREPARED_DATA_PATH = {
    "didb":"./dataset_v2/prepared_set/didb",
    "portal":"./dataset_v2/prepared_set/portal",
    "kist":"./dataset_v2/prepared_set/kist",
    "all":"./dataset_v2/prepared_set/all",
    "all_clean":"./dataset_v2/prepared_set_outline/all",  # Outliers removed
    "all_rating":"./dataset_v2/prepared_set_rating/all",  # Balanced distributions (test outliers removed)
}

def get_task_list(task_type: str) -> List[str]:
    """
    νƒœμŠ€ν¬ μœ ν˜•κ³Ό 데이터 μœ ν˜•μ— λ”°λ₯Έ νƒœμŠ€ν¬ λͺ©λ‘μ„ λ°˜ν™˜ν•©λ‹ˆλ‹€.
    
    Args:
        task_type: νƒœμŠ€ν¬ μœ ν˜• ('cls' λ˜λŠ” 'reg' λ˜λŠ” 'multi_reg')
        
    Returns:
        νƒœμŠ€ν¬ λͺ©λ‘
    """
    y_cols_base = DIDB_FILTER_COLS
    
    # νƒœμŠ€ν¬ μœ ν˜•μ— λ”°λ₯Έ 좜λ ₯ 컬럼 μ„€μ •
    if task_type == 'cls':
        return [f'{x}.cls' for x in y_cols_base]
    else:  # reg and multi_reg
        return y_cols_base
    

def load_vocabs(data_folder: str, cls_targets: List[str]) -> Dict[str, Dict[str, int]]:
    """
    λΆ„λ₯˜ νƒœμŠ€ν¬μš© μ–΄νœ˜ 사전을 λ‘œλ“œν•©λ‹ˆλ‹€.
    
    Args:
        data_folder: 데이터 폴더 경둜
        cls_targets: λΆ„λ₯˜ νƒœμŠ€ν¬ λ ˆμ΄λΈ” λͺ©λ‘
        
    Returns:
        μ–΄νœ˜ 사전 (νƒœμŠ€ν¬λ³„ {λ ˆμ΄λΈ”: 인덱슀})
    """
    all_vocabs = {}
    
    for target in cls_targets:
        vocab_path = os.path.join(data_folder, f'vocabs/{target}.vocab')
        
        if target not in all_vocabs:
            all_vocabs[target] = {}
            
        try:
            with open(vocab_path, 'r', encoding='utf-8') as f:
                for line in f:
                    line = line.rstrip()
                    vocab, idx = line.split('\t')
                    idx = int(idx)
                    all_vocabs[target][vocab] = idx
        except FileNotFoundError:
            # 파일이 μ—†λŠ” 경우 κΈ°λ³Έκ°’ μ‚¬μš©
            print(f"Warning: Vocabulary file not found for {target}. Using default values.")
            all_vocabs[target] = {'inhibitor': 1, 'non-inhibitor': 0}
    
    return all_vocabs