Example #1
0
def main():
    decoded_file = GRAMMAR_WEIGHTS.split(".")[0] + "_decRes.txt"
    priors_file = GRAMMAR_WEIGHTS.split(".")[0] + "_priorsRes.txt"
    generation_file = GRAMMAR_WEIGHTS.split(".")[0] + "_generationRes.txt"
    grammar_model = molecule_vae.ZincCharacterModel(GRAMMAR_WEIGHTS)


    XTE = read_zinc()
    XTE = XTE[0:5000]
    # rember to comment and uncomment the line  in the #moelcule_vae file
    decoded_result = reconstruction(grammar_model, XTE)
    save_decoded_results(XTE, decoded_result, decoded_file)
    # decoded_priors = prior(grammar_model)
    # save_decoded_priors(decoded_priors, priors_file)
    decoded_generation = generation(grammar_model)
    save_decoded_priors(decoded_generation, generation_file)
Example #2
0
def main():
    char_weights = '../../Dropbox/model/zinc_vae_str_L56_E100_val.hdf5'
    accuracy_save_file = char_weights + '.reconstruct_accuracy.txt'
    decode_result_save_file = char_weights + '.reconstruct_decode_result.txt'
    model = molecule_vae.ZincCharacterModel(char_weights)

    decode_result = reconstruct(model, smiles)
    accuracy = cal_accuracy(decode_result)

    print('accuracy:', accuracy)

    save_result = True
    if save_result:
        with open(accuracy_save_file, 'w') as fout:
            print('accuracy:', accuracy, file=fout)

        save_decode_result(decode_result, decode_result_save_file)
Example #3
0
    print 'Train RMSE: ', error
    print 'Train ll: ', trainll

    # We load the decoder to obtain the molecules

    from rdkit.Chem import MolFromSmiles, MolToSmiles
    from rdkit.Chem import Draw
    import image
    import copy
    import time

    import sys
    sys.path.insert(0, '../../../')
    import molecule_vae
    grammar_weights = '../../../pretrained/zinc_vae_str_L56_E100_val.hdf5'
    grammar_model = molecule_vae.ZincCharacterModel(grammar_weights)

    # We pick the next 50 inputs

    next_inputs = sgp.batched_greedy_ei(50, np.min(X_train, 0),
                                        np.max(X_train, 0))

    valid_smiles_final = decode_from_latent_space(next_inputs, grammar_model)

    from rdkit.Chem import Descriptors
    from rdkit.Chem import MolFromSmiles, MolToSmiles

    new_features = next_inputs

    save_object(valid_smiles_final,
                "results/valid_smiles{}.dat".format(iteration))