File size: 6,016 Bytes
7c46397
 
 
 
 
 
 
 
 
 
 
 
 
a1af661
 
 
7c46397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import json
import sys
import os
import torch
from utils.data_loader import GDA_Dataset
from sklearn.model_selection import train_test_split
from sklearn.model_selection import KFold
import numpy as np
import pandas as pd

sys.path.append("../")

class DisGeNETProcessor:
    def __init__(self,input_csv_path):
        train_data = pd.read_csv('data/downstream/GDA_Data/train.csv')
        valid_data = pd.read_csv('data/downstream/GDA_Data/valid.csv')
        test_data = pd.read_csv(input_csv_path)
        
        # test_data = pd.read_csv('/nfs/dpa_pretrain/data/downstream/GDA_Data/test.csv')
        # valid_data, test_data = train_test_split(valid_data, test_size=1/3, random_state=42)
        # train_data = pd.read_csv('/nfs/dpa_pretrain/data/downstream/test/train.csv')
        # valid_data = pd.read_csv('/nfs/dpa_pretrain/data/downstream/test/valid.csv')

        
        # train_data = pd.read_csv('/nfs/dpa_pretrain/data/downstream/disgenet_finetune.csv')
        # train_data, valid_data = train_test_split(train_data, test_size=0.2, random_state=42)
        # valid_data, test_data = train_test_split(valid_data, test_size=1/3, random_state=42)
        
        # alzheimer and stomach dataset use [["proteinSeq", "diseaseDes", "Y"]].dropna()
        
        self.name = "DisGeNET"
        self.train_dataset_df = train_data[["proteinSeq", "diseaseDes", "score"]].dropna()
        self.val_dataset_df = valid_data[["proteinSeq", "diseaseDes", "score"]].dropna()
        self.test_dataset_df = test_data[["proteinSeq", "diseaseDes", "score"]].dropna()
        # self.test_dataset_df = test_data[["proteinSeq", "diseaseDes", "Y"]].dropna()

        
    def get_train_examples(self, test=False):
        """get training examples

        Args:
            test (bool, optional): test can be int or bool. If test>1, will take test as the number of test examples. Defaults to False.

        Returns:
            _type_: _description_
        """
        if test == 1:  # Small testing set, to reduce the running time
            return (
                self.train_dataset_df["proteinSeq"].values[:4096],
                self.train_dataset_df["diseaseDes"].values[:4096],
                self.train_dataset_df["score"].values[:4096],
            )
        elif test > 1:
            return (
                self.train_dataset_df["proteinSeq"].values[:test],
                self.train_dataset_df["diseaseDes"].values[:test],
                self.train_dataset_df["score"].values[:test],
            )
        else:
            return GDA_Dataset( (
                self.train_dataset_df["proteinSeq"].values,
                self.train_dataset_df["diseaseDes"].values,
                self.train_dataset_df["score"].values,
            ))

    def get_val_examples(self, test=False):
        """get validation examples

        Args:
            test (bool, optional): test can be int or bool. If test>1, will take test as the number of test examples. Defaults to False.

        Returns:
            _type_: _description_

        """
        if test == 1:  # Small testing set, to reduce the running time
            return (
                self.val_dataset_df["proteinSeq"].values[:1024],
                self.val_dataset_df["diseaseDes"].values[:1024],
                self.val_dataset_df["score"].values[:1024],
            )
        elif test > 1:
            return (
                self.val_dataset_df["proteinSeq"].values[:test],
                self.val_dataset_df["diseaseDes"].values[:test],
                self.val_dataset_df["score"].values[:test],
            )
        else:
            return GDA_Dataset((
                self.val_dataset_df["proteinSeq"].values,
                self.val_dataset_df["diseaseDes"].values,
                self.val_dataset_df["score"].values,
            ))

#     def get_test_examples(self, test=False):
#         """get test examples

#         Args:
#             test (bool, optional): test can be int or bool. If test>1, will take test as the number of test examples. Defaults to False.

#         Returns:
#             _type_: _description_
#         """
#         if test == 1:  # Small testing set, to reduce the running time
#             return (
#                 self.test_dataset_df["proteinSeq"].values[:1024],
#                 self.test_dataset_df["diseaseDes"].values[:1024],
#                 self.test_dataset_df["Y"].values[:1024],
#             )
#         elif test > 1:
#             return (
#                 self.test_dataset_df["proteinSeq"].values[:test],
#                 self.test_dataset_df["diseaseDes"].values[:test],
#                 self.test_dataset_df["Y"].values[:test],
#             )
#         else:
#             return GDA_Dataset( (
#                 self.test_dataset_df["proteinSeq"].values,
#                 self.test_dataset_df["diseaseDes"].values,
#                 self.test_dataset_df["Y"].values,
#             ))
    def get_test_examples(self, test=False):
        """get test examples

        Args:
            test (bool, optional): test can be int or bool. If test>1, will take test as the number of test examples. Defaults to False.

        Returns:
            _type_: _description_
        """
        if test == 1:  # Small testing set, to reduce the running time
            return (
                self.test_dataset_df["proteinSeq"].values[:1024],
                self.test_dataset_df["diseaseDes"].values[:1024],
                self.test_dataset_df["score"].values[:1024],
            )
        elif test > 1:
            return (
                self.test_dataset_df["proteinSeq"].values[:test],
                self.test_dataset_df["diseaseDes"].values[:test],
                self.test_dataset_df["score"].values[:test],
            )
        else:
            return GDA_Dataset( (
                self.test_dataset_df["proteinSeq"].values,
                self.test_dataset_df["diseaseDes"].values,
                self.test_dataset_df["score"].values,
            ))