kexinhuang12345 / DeepPurpose

A Deep Learning Toolkit for DTI, Drug Property, PPI, DDI, Protein Function Prediction (Bioinformatics)
https://doi.org/10.1093/bioinformatics/btaa1005
BSD 3-Clause "New" or "Revised" License
974 stars 272 forks source link

AttributeError in virtual_screening #17

Closed navanchauhan closed 4 years ago

navanchauhan commented 4 years ago

Code

X_drug = []
X_drug_names = []
file = open("./data/drugs.csv")
for aline in file:
  values = aline.split(",")
  X_drug.append(values[-1])
  print("Loaidng Drug",values[0])
  X_drug_names.append(values[0])
file.close()

target, target_name = dataset.load_SARS_CoV2_Protease_3CL()

net = models.model_pretrained(model = 'Transformer_CNN_BindingDB')
net.config

models.virtual_screening(X_drug, target, net, X_drug_names, target_name)

Error

virtual screening...
in total: 133 drug-target pairs
encoding drug...
unique drugs: 124
drug encoding finished...
encoding protein...
unique target sequence: 1
protein encoding finished...
Done.
predicting...
---------------
Virtual Screening Result
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-76-a764e04fe067> in <module>()
----> 1 models.virtual_screening(X_drug, target, net, X_drug_names, target_name)

/content/DeepPurpose/DeepPurpose/models.py in virtual_screening(X_repurpose, target, model, drug_names, target_names, result_folder, convert_y, output_num_max, verbose)
    459                         f_d = max([len(o) for o in drug_names]) + 1
    460                         f_p = max([len(o) for o in target_names]) + 1
--> 461                         for i in range(target.shape[0]):
    462                                 if model.binary:
    463                                         if y_pred[i] > 0.5:

AttributeError: 'str' object has no attribute 'shape'

I haven't gone through the entire codebase yet but should it be length of the string rather than its shape?

kexinhuang12345 commented 4 years ago

You are right, see this commit for the fix.