Exemple #1
0
def predict_RI(smiles, mode='SimiStdNP'):
    words = open('DeepEI/data/words.json', 'r').read()
    words = json.loads(words)
    if mode == 'SimiStdNP':
        model = load_model('Retention/models/SimiStdNP_CNN_multi_model.h5')
    elif mode == 'StdNP':
        model = load_model('Retention/models/StdNP_CNN_multi_model.h5')
    elif mode == 'StdPolar':
        model = load_model('Retention/models/StdPolar_CNN_multi_model.h5')
    else:
        return None

    X = []
    for i, smi in enumerate(smiles):
        xi = one_hot_coding(smi, words, max_len=100)
        X.append(xi.todense())
    X = np.array(X)
    pred = model.predict(X)
    return pred
Exemple #2
0
# -*- coding: utf-8 -*-
"""
Created on Wed Jul  3 10:20:36 2019

@author: hcji
"""

import os
import json
from tqdm import tqdm
from smiles_to_onehot.encoding import get_dict, one_hot_coding

with open('hmdb_smiles/hmdb_smiles.json', 'r') as js:
    hmdb_smiles = json.load(js)

words = get_dict(hmdb_smiles, save_path=os.getcwd())

x = []
for smi in tqdm(hmdb_smiles):
    xi = one_hot_coding(smi, words, max_len=100)
    x.append(xi)
Exemple #3
0
        K.clear_session()


if __name__ == '__main__':

    import json

    with open('DeepEI/data/split.json', 'r') as js:
        keep = np.array(json.load(js)['keep'])

    smiles = np.array(json.load(open('DeepEI/data/all_smiles.json')))[keep]
    rindex = np.load('DeepEI/data/retention.npy')[keep, :]

    words = get_dict(smiles, save_path='DeepEI/data/words.json')
    smiles = [
        one_hot_coding(smi, words, max_len=100).todense() for smi in smiles
    ]
    smiles = np.array(smiles)

    # simipolar
    i = np.where(~np.isnan(rindex[:, 0]))[0]
    mod = multi_CNN(smiles[i], rindex[i, 0])
    mod.train()
    mod.test()
    mod.save('Retention/models/SimiStdNP_CNN_multi_model.h5')

    # nonpolar
    i = np.where(~np.isnan(rindex[:, 1]))[0]
    mod = multi_CNN(smiles[i], rindex[i, 1])
    mod.train()
    mod.test()