Spaces:
Running
Running
Update new_dataloader.py
Browse files- new_dataloader.py +8 -8
new_dataloader.py
CHANGED
|
@@ -59,19 +59,19 @@ class DruggenDataset(InMemoryDataset):
|
|
| 59 |
print('Created bonds encoder and decoder with {} bond types and 1 PAD symbol!'.format(
|
| 60 |
self.bond_num_types - 1))
|
| 61 |
#dataset_names = str(self.dataset_name)
|
| 62 |
-
with open("
|
| 63 |
pickle.dump(self.atom_encoder_m,atom_encoders)
|
| 64 |
|
| 65 |
|
| 66 |
-
with open("
|
| 67 |
pickle.dump(self.atom_decoder_m,atom_decoders)
|
| 68 |
|
| 69 |
|
| 70 |
-
with open("
|
| 71 |
pickle.dump(self.bond_encoder_m,bond_encoders)
|
| 72 |
|
| 73 |
|
| 74 |
-
with open("
|
| 75 |
pickle.dump(self.bond_decoder_m,bond_decoders)
|
| 76 |
|
| 77 |
|
|
@@ -118,11 +118,11 @@ class DruggenDataset(InMemoryDataset):
|
|
| 118 |
return np.vstack((features, np.zeros((max_length - features.shape[0], features.shape[1]))))
|
| 119 |
|
| 120 |
def decoder_load(self, dictionary_name, file):
|
| 121 |
-
with open("
|
| 122 |
return pickle.load(f)
|
| 123 |
|
| 124 |
def drugs_decoder_load(self, dictionary_name):
|
| 125 |
-
with open("
|
| 126 |
return pickle.load(f)
|
| 127 |
|
| 128 |
def matrices2mol(self, node_labels, edge_labels, strict=True, file_name=None):
|
|
@@ -151,7 +151,7 @@ class DruggenDataset(InMemoryDataset):
|
|
| 151 |
|
| 152 |
''' Loading the atom and bond decoders '''
|
| 153 |
|
| 154 |
-
with open("
|
| 155 |
|
| 156 |
return pickle.load(f)
|
| 157 |
def matrices2mol_drugs(self, node_labels, edge_labels, strict=True, file_name=None):
|
|
@@ -291,5 +291,5 @@ class DruggenDataset(InMemoryDataset):
|
|
| 291 |
|
| 292 |
|
| 293 |
if __name__ == '__main__':
|
| 294 |
-
data = DruggenDataset("
|
| 295 |
|
|
|
|
| 59 |
print('Created bonds encoder and decoder with {} bond types and 1 PAD symbol!'.format(
|
| 60 |
self.bond_num_types - 1))
|
| 61 |
#dataset_names = str(self.dataset_name)
|
| 62 |
+
with open("data/encoders/" +"atom_" + self.dataset_name + ".pkl","wb") as atom_encoders:
|
| 63 |
pickle.dump(self.atom_encoder_m,atom_encoders)
|
| 64 |
|
| 65 |
|
| 66 |
+
with open("data/decoders/" +"atom_" + self.dataset_name + ".pkl","wb") as atom_decoders:
|
| 67 |
pickle.dump(self.atom_decoder_m,atom_decoders)
|
| 68 |
|
| 69 |
|
| 70 |
+
with open("data/encoders/" +"bond_" + self.dataset_name + ".pkl","wb") as bond_encoders:
|
| 71 |
pickle.dump(self.bond_encoder_m,bond_encoders)
|
| 72 |
|
| 73 |
|
| 74 |
+
with open("data/decoders/" +"bond_" + self.dataset_name + ".pkl","wb") as bond_decoders:
|
| 75 |
pickle.dump(self.bond_decoder_m,bond_decoders)
|
| 76 |
|
| 77 |
|
|
|
|
| 118 |
return np.vstack((features, np.zeros((max_length - features.shape[0], features.shape[1]))))
|
| 119 |
|
| 120 |
def decoder_load(self, dictionary_name, file):
|
| 121 |
+
with open("data/decoders/" + dictionary_name + "_" + file + '.pkl', 'rb') as f:
|
| 122 |
return pickle.load(f)
|
| 123 |
|
| 124 |
def drugs_decoder_load(self, dictionary_name):
|
| 125 |
+
with open("data/decoders/" + dictionary_name +'.pkl', 'rb') as f:
|
| 126 |
return pickle.load(f)
|
| 127 |
|
| 128 |
def matrices2mol(self, node_labels, edge_labels, strict=True, file_name=None):
|
|
|
|
| 151 |
|
| 152 |
''' Loading the atom and bond decoders '''
|
| 153 |
|
| 154 |
+
with open("data/decoders/" + dictionary_name +"_" + file +'.pkl', 'rb') as f:
|
| 155 |
|
| 156 |
return pickle.load(f)
|
| 157 |
def matrices2mol_drugs(self, node_labels, edge_labels, strict=True, file_name=None):
|
|
|
|
| 291 |
|
| 292 |
|
| 293 |
if __name__ == '__main__':
|
| 294 |
+
data = DruggenDataset("data")
|
| 295 |
|