DRUGNAME_2_DRUGBANKID_FILE = os.path.join(DRUG_DATA_DIR, 'drugname2drugbankid.tsv') | DRUGNAME_2_DRUGBANKID_FILE = os.path.join(DRUG_DATA_DIR, 'drugname2drugbankid.tsv') | ||||
CELL_FEAT_FILE = os.path.join(CELL_DATA_DIR, 'cell_feat.npy') | CELL_FEAT_FILE = os.path.join(CELL_DATA_DIR, 'cell_feat.npy') | ||||
CELL2ID_FILE = os.path.join(CELL_DATA_DIR, 'cell2id.tsv') | CELL2ID_FILE = os.path.join(CELL_DATA_DIR, 'cell2id.tsv') | ||||
Drug2FP_FILE = os.path.join(PROJ_DIR, 'drug/data/drug2FP_synergy.csv') | |||||
import torch.nn.functional as F | import torch.nn.functional as F | ||||
import os | import os | ||||
import sys | import sys | ||||
import pandas as pd | |||||
PROJ_DIR = os.path.dirname(os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..'))) | PROJ_DIR = os.path.dirname(os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..'))) | ||||
from drug.models import GCN | from drug.models import GCN | ||||
from drug.datasets import DDInteractionDataset | from drug.datasets import DDInteractionDataset | ||||
from model.utils import get_FP_by_negative_index | from model.utils import get_FP_by_negative_index | ||||
from const import Drug2FP_FILE | |||||
super(Connector, self).__init__() | super(Connector, self).__init__() | ||||
# self.ddiDataset = DDInteractionDataset(gpu_id = gpu_id) | # self.ddiDataset = DDInteractionDataset(gpu_id = gpu_id) | ||||
self.gcn = None | self.gcn = None | ||||
self.drug2FP_df = pd.read_csv(Drug2FP_FILE) | |||||
#Cell line features | #Cell line features | ||||
# np.load('cell_feat.npy') | # np.load('cell_feat.npy') | ||||
drug2_feat = drug2_feat.cuda(self.gpu_id) | drug2_feat = drug2_feat.cuda(self.gpu_id) | ||||
for i, x in enumerate(drug1_idx): | for i, x in enumerate(drug1_idx): | ||||
if x < 0: | if x < 0: | ||||
drug1_feat[i] = get_FP_by_negative_index(x) | drug1_feat[i] = get_FP_by_negative_index(x,self.drug2FP_df) | ||||
for i, x in enumerate(drug2_idx): | for i, x in enumerate(drug2_idx): | ||||
if x < 0: | if x < 0: | ||||
drug2_feat[i] = get_FP_by_negative_index(x) | drug2_feat[i] = get_FP_by_negative_index(x,self.drug2FP_df) | ||||
feat = torch.cat([drug1_feat, drug2_feat, cell_feat], 1) | feat = torch.cat([drug1_feat, drug2_feat, cell_feat], 1) | ||||
return feat | return feat | ||||
import pandas as pd | import pandas as pd | ||||
import numpy as np | import numpy as np | ||||
from const import SYNERGY_FILE, CELL_FEAT_FILE, CELL2ID_FILE, OUTPUT_DIR, DRUGNAME_2_DRUGBANKID_FILE, DRUGN2ID_FILE | from const import DRUGNAME_2_DRUGBANKID_FILE, DRUGN2ID_FILE, Drug2FP_FILE | ||||
def calc_stat(numbers): | def calc_stat(numbers): | ||||
mu = sum(numbers) / len(numbers) | mu = sum(numbers) / len(numbers) | ||||
return drug_index | return drug_index | ||||
def get_FP_by_negative_index(index): | def get_FP_by_negative_index(index, drug2FP_df = None): | ||||
index = index.item() | index = index.item() | ||||
project_path = os.path.dirname(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) | if drug2FP_df.empty: | ||||
drug2FP_file = os.path.join(project_path, 'drug/data/drug2FP_synergy.csv') | print("load Drug2FP_FILE") | ||||
drug2FP_df = pd.read_csv(drug2FP_file) | drug2FP_df = pd.read_csv(Drug2FP_FILE) | ||||
array = np.array(list(drug2FP_df.iloc[-index])[1:]) | array = np.array(list(drug2FP_df.iloc[-index])[1:]) | ||||
return torch.tensor(array, dtype=torch.float32) | return torch.tensor(array, dtype=torch.float32) |