Spaces:
Running
Running
Update new_dataloader.py
Browse files- new_dataloader.py +8 -8
new_dataloader.py
CHANGED
|
@@ -88,19 +88,19 @@ class DruggenDataset(InMemoryDataset):
|
|
| 88 |
print('Created bonds encoder and decoder with {} bond types and 1 PAD symbol!'.format(
|
| 89 |
self.bond_num_types - 1))
|
| 90 |
#dataset_names = str(self.dataset_name)
|
| 91 |
-
with open("
|
| 92 |
pickle.dump(self.atom_encoder_m,atom_encoders)
|
| 93 |
|
| 94 |
|
| 95 |
-
with open("
|
| 96 |
pickle.dump(self.atom_decoder_m,atom_decoders)
|
| 97 |
|
| 98 |
|
| 99 |
-
with open("
|
| 100 |
pickle.dump(self.bond_encoder_m,bond_encoders)
|
| 101 |
|
| 102 |
|
| 103 |
-
with open("
|
| 104 |
pickle.dump(self.bond_decoder_m,bond_decoders)
|
| 105 |
|
| 106 |
return max_length, smiles_list # data is filtered now
|
|
@@ -147,11 +147,11 @@ class DruggenDataset(InMemoryDataset):
|
|
| 147 |
return np.vstack((features, np.zeros((max_length - features.shape[0], features.shape[1]))))
|
| 148 |
|
| 149 |
def decoder_load(self, dictionary_name, file):
|
| 150 |
-
with open("
|
| 151 |
return pickle.load(f)
|
| 152 |
|
| 153 |
def drugs_decoder_load(self, dictionary_name):
|
| 154 |
-
with open("
|
| 155 |
return pickle.load(f)
|
| 156 |
|
| 157 |
def matrices2mol(self, node_labels, edge_labels, strict=True, file_name=None):
|
|
@@ -180,7 +180,7 @@ class DruggenDataset(InMemoryDataset):
|
|
| 180 |
|
| 181 |
''' Loading the atom and bond decoders '''
|
| 182 |
|
| 183 |
-
with open("
|
| 184 |
|
| 185 |
return pickle.load(f)
|
| 186 |
def matrices2mol_drugs(self, node_labels, edge_labels, strict=True, file_name=None):
|
|
@@ -307,5 +307,5 @@ class DruggenDataset(InMemoryDataset):
|
|
| 307 |
|
| 308 |
|
| 309 |
if __name__ == '__main__':
|
| 310 |
-
data = DruggenDataset("
|
| 311 |
|
|
|
|
| 88 |
print('Created bonds encoder and decoder with {} bond types and 1 PAD symbol!'.format(
|
| 89 |
self.bond_num_types - 1))
|
| 90 |
#dataset_names = str(self.dataset_name)
|
| 91 |
+
with open("data/encoders/" +"atom_" + self.dataset_name + ".pkl","wb") as atom_encoders:
|
| 92 |
pickle.dump(self.atom_encoder_m,atom_encoders)
|
| 93 |
|
| 94 |
|
| 95 |
+
with open("data/decoders/" +"atom_" + self.dataset_name + ".pkl","wb") as atom_decoders:
|
| 96 |
pickle.dump(self.atom_decoder_m,atom_decoders)
|
| 97 |
|
| 98 |
|
| 99 |
+
with open("data/encoders/" +"bond_" + self.dataset_name + ".pkl","wb") as bond_encoders:
|
| 100 |
pickle.dump(self.bond_encoder_m,bond_encoders)
|
| 101 |
|
| 102 |
|
| 103 |
+
with open("data/decoders/" +"bond_" + self.dataset_name + ".pkl","wb") as bond_decoders:
|
| 104 |
pickle.dump(self.bond_decoder_m,bond_decoders)
|
| 105 |
|
| 106 |
return max_length, smiles_list # data is filtered now
|
|
|
|
| 147 |
return np.vstack((features, np.zeros((max_length - features.shape[0], features.shape[1]))))
|
| 148 |
|
| 149 |
def decoder_load(self, dictionary_name, file):
|
| 150 |
+
with open("data/decoders/" + dictionary_name + "_" + file + '.pkl', 'rb') as f:
|
| 151 |
return pickle.load(f)
|
| 152 |
|
| 153 |
def drugs_decoder_load(self, dictionary_name):
|
| 154 |
+
with open("data/decoders/" + dictionary_name +'.pkl', 'rb') as f:
|
| 155 |
return pickle.load(f)
|
| 156 |
|
| 157 |
def matrices2mol(self, node_labels, edge_labels, strict=True, file_name=None):
|
|
|
|
| 180 |
|
| 181 |
''' Loading the atom and bond decoders '''
|
| 182 |
|
| 183 |
+
with open("data/decoders/" + dictionary_name +"_" + file +'.pkl', 'rb') as f:
|
| 184 |
|
| 185 |
return pickle.load(f)
|
| 186 |
def matrices2mol_drugs(self, node_labels, edge_labels, strict=True, file_name=None):
|
|
|
|
| 307 |
|
| 308 |
|
| 309 |
if __name__ == '__main__':
|
| 310 |
+
data = DruggenDataset("data")
|
| 311 |
|