plt.xlabel('epoch')
plt.legend(['train forward', 'train reverse', 'test forward', 'test reverse'],
           loc='upper left')
plt.show()

model_json = model.to_json()
save_path = 'Model/RIKEN_PlaSMA_Pos_10'
with open(save_path + '.json', "w") as json_file:
    json_file.write(model_json)
model.save_weights(save_path + '.h5')

result = pd.DataFrame(
    columns=['idx', 'smiles', 'DeepFrag', 'CFM_10', 'CFM_20', 'CFM_40'])
for i in tqdm(test_index):
    try:
        smi = smiles[i]
        ms_cfm = cfm_predict(smi)
        ms_real = ms[i]
        ms_pred = model_predict(smi, model)
        trans = ms_correlation(ms_real, ms_pred)
        cfm_10 = ms_correlation(ms_real, ms_cfm['low_energy'])
        cfm_20 = ms_correlation(ms_real, ms_cfm['medium_energy'])
        cfm_40 = ms_correlation(ms_real, ms_cfm['high_energy'])
    except:
        continue
    '''
    plot_compare_ms(ms_real, ms_cfm['medium_energy'])
    plot_compare_ms(ms_real, ms_pred)
    '''
    result.loc[len(result)] = [i, smi, trans, cfm_10, cfm_20, cfm_40]
result.to_csv('Result/RIKEN_PlaSMA_Pos_10.csv')
Esempio n. 2
0
File: test.py Progetto: hcji/PyCFMID
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 17:06:01 2019

@author: hcji
"""

import pandas as pd
from PyCFMID.PyCFMID import fraggraph_gen, cfm_predict, cfm_id_database

fragments = fraggraph_gen('CCCCN')
pred_ms = cfm_predict('CCCCN')

spectra = pd.DataFrame({
    'mz': [223.106608, 251.101730],
    'intensity': [100.000000, 40.722900]
})
cfm_id_database(spectra, formula='C17H22FN3O4S', database='pubchem')
Esempio n. 3
0
    data.columns = ['mz', 'intensity']
    modes.append(ion_mode)
    ms.append(data)
    smiles.append(smi)
    energies.append(energy)
summary = pd.DataFrame({'smiles': smiles, 'ion_mode': modes, 'energy': energies})


# example 2
idx = 551
smi = smiles[idx]
mol = Chem.MolFromSmiles(smi)
t1 = time.time()
ms_pred = model_predict(smi, model)
t2 = time.time()
ms_cfm = cfm_predict(smi, ionization_mode='-')
t3 = time.time()
ms_pretrain = model_predict(smi, pretrain)
ms_real = ms[idx]
plot_compare_ms(ms_real, ms_pretrain)
plot_compare_ms(ms_pretrain, ms_cfm['low_energy'])
plot_compare_ms(ms_real, ms_pred)
plot_compare_ms(ms_real, ms_cfm['low_energy'])
print ('computing time of CFM is: ' + str(t3-t2) + ' s')
print ('computing time of DeepFrag is: ' + str(t2-t1) + ' s')


## precursor
Chem.MolFromSmiles('OCC1OC(C(O)C(O)C1O)C1=C(O)C2=C(OC(=CC2=O)C2=CC(O)=C(O)C=C2)C=C1O')

## Suppress