dim_edge = DE.shape[3] dim_y = DY.shape[1] atom_list = ['B', 'C', 'N', 'O', 'F', 'Si', 'P', 'S', 'Cl', 'Se', 'Br', 'I'] bond_list = ['SINGLE', 'DOUBLE', 'TRIPLE'] bpatt_dim = [3, 3, 2, 1, 2, 1] print(':: preprocess data') scaler = StandardScaler() scaler.fit(DY) DY = scaler.transform(DY) mu_prior = np.mean(DY, 0) cov_prior = np.cov(DY.T) model = Model(n_node, dim_node, dim_edge, dim_y, atom_list, bpatt_dim, mu_prior, cov_prior) print(':: generate molecular graphs') with model.sess: model.saver.restore(model.sess, save_path) total_count, valid_count, novel_count, unique_count, genmols = model.test( 10000, 0, Dsmi) valid = valid_count / total_count unique = unique_count / valid_count novel = novel_count / valid_count print(':: Valid:', valid * 100, 'Unique:', unique * 100, 'Novel:', novel * 100, 'GMean:', 100 * (valid * unique * novel)**(1 / 3))
print(':: preprocess data') scaler = StandardScaler() scaler.fit(DY) DY = scaler.transform(DY) mu_prior=np.mean(DY,0) cov_prior=np.cov(DY.T) model = Model(n_node, dim_node, dim_edge, dim_y, mu_prior, cov_prior) print(':: generate molecular graphs') with model.sess: model.saver.restore(model.sess, save_path) # unconditional generation total_count, valid_count, novel_count, unique_count, genmols = model.test(10000, 0, Dsmi, atom_list) valid=valid_count/total_count unique=unique_count/valid_count novel=novel_count/valid_count list_Y=[] for m in genmols: mol = Chem.MolFromSmiles(m) if dim_edge == 3: Chem.Kekulize(mol) list_Y.append([Descriptors.ExactMolWt(mol), Descriptors.MolLogP(mol)]) print(':: unconditional generation results', len(genmols), np.mean(list_Y,0), np.std(list_Y,0)) print(':: Valid:', valid*100, 'Unique:', unique*100, 'Novel:', novel*100, 'GMean:', 100*(valid*unique*novel)**(1/3)) # conditional generation
print(':: preprocess data') scaler = StandardScaler() scaler.fit(DY) DY = scaler.transform(DY) mu_prior = np.mean(DY, 0) cov_prior = np.cov(DY.T) model = Model(n_node, dim_node, dim_edge, dim_y, mu_prior, cov_prior) np.set_printoptions(precision=3, suppress=True) with model.sess: model.saver.restore(model.sess, save_path) # unconditional generation total_count, genmols = model.test(10000, 0, Dsmi, atom_list) #print (total_count) #valid=valid_count/total_count #unique=unique_count/valid_count #novel=novel_count/valid_count #print(':: Valid:', valid*100, 'Unique:', unique*100, 'Novel:', novel*100, 'GMean:', 100*(valid*unique*novel)**(1/3)) list_Y = [] for mol in genmols: #if dim_edge == 3: Chem.Kekulize(mol) list_Y.append([isProperty(Chem.GetAdjacencyMatrix(mol))]) print(':: unconditional generation results', len(genmols),