Giter VIP home page Giter VIP logo

deepcoy's Introduction

DeepCoy - Generating Property-Matched Decoy Molecules Using Deep Learning

This repository contains our implementation of Generating Property-Matched Decoy Molecules Using Deep Learning (DeepCoy).

If you found DeepCoy useful, please cite our paper:

Imrie F, Bradley AR, Deane CM. Generating property-matched decoy molecules using deep learning. Bioinformatics. 2021

@article{Imrie2021DeepCoy,
    author = {Imrie, Fergus and Bradley, Anthony R and Deane, Charlotte M},
    title = "{Generating property-matched decoy molecules using deep learning}",
    journal = {Bioinformatics},
    year = {2021},
    month = {02},
    issn = {1367-4803},
    doi = {10.1093/bioinformatics/btab080},
    url = {https://doi.org/10.1093/bioinformatics/btab080},
    eprint = {https://academic.oup.com/bioinformatics/advance-article-pdf/doi/10.1093/bioinformatics/btab080/36297301/btab080.pdf},
}

Acknowledgements

We thank the authors of Constrained Graph Variational Autoencoders for Molecule Design for releasing their code. The code in this repository is based on their source code release (link). If you find this code useful, please consider citing their work.

Requirements

This code was tested in Python 3.6 with Tensorflow 1.10.

A yaml file containing all install requirements is provided. This can be readily setup using conda.

conda env create -f DeepCoy-env.yml
conda activate DeepCoy-env

To run our model using subgraph reweighted loss function, you need to download the subgraph frequency data from http://opig.stats.ox.ac.uk/resources. Note this is not required for generating molecules using pretrained models but is advised for training new models.

Data Extraction

We have prepared two training datasets based on different physicochemical properties. Both were created from a subset of the ZINC dataset.

To preprocess these datasets, please go to data directory and run prepare_data.py.

python prepare_data.py

Running DeepCoy

To train and generate molecules using DeepCoy, use:

python DeepCoy.py --dataset zinc --config '{"number_of_generation_per_valid": 100, "num_epochs": 10, "epoch_to_generate": 10, "train_file": "data/molecules_zinc_dekois_train.json", "valid_file": "data/molecules_zinc_dekois_valid.json", "subgraph_freq_file": "./freq_dict_zinc_250k_smarts.pkl"}'

To train and generate molecules using DeepCoy without the subgraph reweighted loss function, use:

python DeepCoy.py --dataset zinc --config '{"number_of_generation_per_valid": 100, "num_epochs": 10, "epoch_to_generate": 10, "train_file": "data/molecules_zinc_dekois_train.json", "valid_file": "data/molecules_zinc_dekois_valid.json", "use_subgraph_freq": false}'

To generate molecules with a pretrained model, use

python DeepCoy.py --restore models/DeepCoy_DUDE_model_e09.pickle --dataset zinc --config '{"generation": true, "number_of_generation_per_valid": 1000, "batch_size": 1, "train_file": "data/molecules_zinc_dekois_valid.json", "valid_file": "data/molecules_zinc_dekois_valid.json", "output_name": "output/DeepCoy_generated_decoys_zinc_dekois_valid.txt"}'

The output is of the following format:

Input molecule (SMILES) Generated molecule (SMILES)

More configurations can be found at function default_params in DeepCoy.py.

Evaluation

A script to evaluate the generated molecules and prepare a set of decoys is provided in evaluation directory. You can either specify a one file or a directory containing multiple files to process.

python select_and_evaluate_decoys.py --data_path PATH_TO_INPUT_FILE/DIRECTORY --output_path PATH_TO_OUTPUT --dataset_name dude --num_decoys_per_active 50 >> decoy_selection_log.txt

The input format should be of the following format:

Active molecule (SMILES) Possible decoy molecule (SMILES)

Pretrained Models and Generated Molecules

We provide two pretrained models based on different physicochemical properties (as described in our paper).

Due to GitHub file size constraints, these need to be downloaded from http://opig.stats.ox.ac.uk/resources:

models/DeepCoy_DUDE_model_e09.pickle
models/DeepCoy_DEKOIS_model_e10.pickle

In addition, we provide a model that incorporates phosphorus:

models/DeepCoy_DUDE_phosphorus_model_e10.pickle

Generated molecules can also be downloaded from the OPIG website.

Examples

An example Jupyter notbook demonstrating the use of DeepCoy to generate and select decoy molecule can be found in the examples directory.

Contact (Questions/Bugs/Requests)

Please submit a Github issue or contact either Fergus Imrie or the Oxford Protein Informatics Group (OPIG) [email protected].

deepcoy's People

Contributors

fimrie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

deepcoy's Issues

IndexError: list index out of range

Dear author,

I've used your code succesfully already, however now I am trying to use it again but I run into some errors and I cannot figure out what is wrong. In the first run, everything went fine, but I noticed that on my part, the smiles I input, didnt have the stereoisomer/enantiomer informations (@,/,\ signs). Now that I added them, DeepCoy is not able to generate the model anymore.
The error code is below:
IndexError Traceback (most recent call last)
in
1 # Setup model and generate molecules
----> 2 model = DenseGGNNChemModel(args)
3 model.train()
4 # Free up some memory
5 model = ''

/data/projects/discovery.science/applic/DeepCoy/DeepCoy.py in init(self, args)
53 class DenseGGNNChemModel(ChemModel):
54 def init(self, args):
---> 55 super().init(args)
56
57 @classmethod

/data/projects/discovery.science/applic/DeepCoy/GGNN_DeepCoy.py in init(self, args)
66 self.annotation_size = 0
67 self.train_data = self.load_data(params['train_file'], is_training_data=True)
---> 68 self.valid_data = self.load_data(params['valid_file'], is_training_data=False)
69
70 # Build the actual model

/data/projects/discovery.science/applic/DeepCoy/GGNN_DeepCoy.py in load_data(self, file_name, is_training_data)
107 self.annotation_size = max(self.annotation_size, len(data[0]["node_features_in"][0]))
...
---> 13 if neighbor != node_in_focus and color[neighbor] < 2 and
14 not check_adjacent_sparse(adj_mat, node_in_focus, neighbor)[0]:
15 min_valence = min(valences[node_in_focus], valences[neighbor], 3)

IndexError: list index out of range

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.