-
Notifications
You must be signed in to change notification settings - Fork 0
/
React_v2.py
57 lines (42 loc) · 1.51 KB
/
React_v2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 29 10:09:27 2023
@author: chingchinglam
"""
import os
import sys
sys.path.insert(1, os.getcwd()+'/scripts/')
import pickle
import training_prepare_v5 as tp
from rdkit import Chem
from rdkit.Chem import AllChem
class reactivity:
def __init__(self, data='yr1', model_file='RF_model_yr1_28122023.sav'):
if data == 'yr1':
model_file= 'RF_model_yr1_28122023.sav'
elif data == 'da':
model_file= 'RF_model_da_11062024.sav'
elif data == 'cyclo':
model_file = 'RF_model_cyclo_11062024.sav'
elif data == 'green':
model_file = 'RF_model_green_11062024.sav'
elif data == 'rgd':
model_file = 'RF_model_rgd_11062024.sav'
elif data == 'Bmix':
model_file = 'RF_model_Bmix_11062024.sav'
elif data == 'Cmix':
model_file = 'RF_model_Cmix_11062024.sav'
elif data == 'all':
model_file = 'RF_model_all_11062024.sav'
self.model = pickle.load(open(model_file, 'rb'))
def make_prediction(self,input_mol):
mol=Chem.MolFromSmiles(input_mol)
mol_H=Chem.AddHs(mol)
#generate the descriptor
descriptors_ls=tp.descriptors_from_mol(mol_H)
#make the prediction
self.pred=self.model.predict(descriptors_ls)
#for visualisation
self.mol_H_visual=Chem.Mol(mol_H)
AllChem.Compute2DCoords(self.mol_H_visual)