Spaces:
Running
Running
Update inference.py
Browse files- inference.py +9 -9
inference.py
CHANGED
|
@@ -113,7 +113,7 @@ class Inference(object):
|
|
| 113 |
|
| 114 |
def decoder_load(self, dictionary_name):
|
| 115 |
''' Loading the atom and bond decoders'''
|
| 116 |
-
with open("
|
| 117 |
return pickle.load(f)
|
| 118 |
|
| 119 |
|
|
@@ -139,16 +139,16 @@ class Inference(object):
|
|
| 139 |
self.restore_model(self.submodel, self.inference_model)
|
| 140 |
|
| 141 |
# smiles data for metrics calculation.
|
| 142 |
-
chembl_smiles = [line for line in open("
|
| 143 |
-
chembl_test = [line for line in open("
|
| 144 |
-
drug_smiles = [line for line in open("
|
| 145 |
drug_mols = [Chem.MolFromSmiles(smi) for smi in drug_smiles]
|
| 146 |
drug_vecs = [AllChem.GetMorganFingerprintAsBitVect(x, 2, nBits=1024) for x in drug_mols if x is not None]
|
| 147 |
|
| 148 |
|
| 149 |
# Make directories if not exist.
|
| 150 |
-
if not os.path.exists("
|
| 151 |
-
os.makedirs("
|
| 152 |
|
| 153 |
|
| 154 |
self.G.eval()
|
|
@@ -197,7 +197,7 @@ class Inference(object):
|
|
| 197 |
if molecules is None:
|
| 198 |
none_counter += 1
|
| 199 |
|
| 200 |
-
with open("
|
| 201 |
for molecules in inference_drugs:
|
| 202 |
if molecules is not None:
|
| 203 |
molecules = molecules.replace("*", "C")
|
|
@@ -245,9 +245,9 @@ if __name__=="__main__":
|
|
| 245 |
|
| 246 |
# Data configuration.
|
| 247 |
parser.add_argument('--inf_dataset_file', type=str, default='chembl45_test.pt')
|
| 248 |
-
parser.add_argument('--inf_raw_file', type=str, default='
|
| 249 |
parser.add_argument('--inf_batch_size', type=int, default=1, help='Batch size for inference')
|
| 250 |
-
parser.add_argument('--mol_data_dir', type=str, default='
|
| 251 |
parser.add_argument('--features', type=str2bool, default=False, help='features dimension for nodes')
|
| 252 |
|
| 253 |
# Model configuration.
|
|
|
|
| 113 |
|
| 114 |
def decoder_load(self, dictionary_name):
|
| 115 |
''' Loading the atom and bond decoders'''
|
| 116 |
+
with open("data/decoders/" + dictionary_name + "_" + self.dataset_name + '.pkl', 'rb') as f:
|
| 117 |
return pickle.load(f)
|
| 118 |
|
| 119 |
|
|
|
|
| 139 |
self.restore_model(self.submodel, self.inference_model)
|
| 140 |
|
| 141 |
# smiles data for metrics calculation.
|
| 142 |
+
chembl_smiles = [line for line in open("data/chembl_train.smi", 'r').read().splitlines()]
|
| 143 |
+
chembl_test = [line for line in open("data/chembl_test.smi", 'r').read().splitlines()]
|
| 144 |
+
drug_smiles = [line for line in open("data/akt_inhibitors.smi", 'r').read().splitlines()]
|
| 145 |
drug_mols = [Chem.MolFromSmiles(smi) for smi in drug_smiles]
|
| 146 |
drug_vecs = [AllChem.GetMorganFingerprintAsBitVect(x, 2, nBits=1024) for x in drug_mols if x is not None]
|
| 147 |
|
| 148 |
|
| 149 |
# Make directories if not exist.
|
| 150 |
+
if not os.path.exists("experiments/inference/{}".format(self.submodel)):
|
| 151 |
+
os.makedirs("experiments/inference/{}".format(self.submodel))
|
| 152 |
|
| 153 |
|
| 154 |
self.G.eval()
|
|
|
|
| 197 |
if molecules is None:
|
| 198 |
none_counter += 1
|
| 199 |
|
| 200 |
+
with open("experiments/inference/{}/inference_drugs.txt".format(self.submodel), "a") as f:
|
| 201 |
for molecules in inference_drugs:
|
| 202 |
if molecules is not None:
|
| 203 |
molecules = molecules.replace("*", "C")
|
|
|
|
| 245 |
|
| 246 |
# Data configuration.
|
| 247 |
parser.add_argument('--inf_dataset_file', type=str, default='chembl45_test.pt')
|
| 248 |
+
parser.add_argument('--inf_raw_file', type=str, default='data/chembl_test.smi')
|
| 249 |
parser.add_argument('--inf_batch_size', type=int, default=1, help='Batch size for inference')
|
| 250 |
+
parser.add_argument('--mol_data_dir', type=str, default='data')
|
| 251 |
parser.add_argument('--features', type=str2bool, default=False, help='features dimension for nodes')
|
| 252 |
|
| 253 |
# Model configuration.
|