forked from chaohaoyuan/PAAG
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataset.py
More file actions
35 lines (24 loc) · 856 Bytes
/
dataset.py
File metadata and controls
35 lines (24 loc) · 856 Bytes
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
import json
import torch
from torch.utils.data import DataLoader, Dataset, IterableDataset
import pandas as pd
import csv
from collections import defaultdict
import re
import os
from Bio import SeqIO
class TextSeqPair(Dataset):
def __init__(self, json_file):
self.json_file = json_file
def __getitem__(self, idx):
return self.json_file.iloc[idx, 4]['value'], self.json_file.iloc[idx, 1]
def __len__(self):
return len(self.json_file)
class Uniprot_LocationDataset(Dataset):
def __init__(self, json_file):
self.json_file = json_file
def __getitem__(self, idx):
# print(self.json_file.iloc[idx, ])
return self.json_file.iloc[idx, 4]['value'], self.json_file.iloc[idx, 1], self.json_file.iloc[idx, 2] # seq, text, location
def __len__(self):
return len(self.json_file)