Giter Site home page Giter Site logo

forfreedomgit / localtransform Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kaist-amsg/localtransform

0.0 0.0 0.0 109.71 MB

Predicting Organic Reactivity Based on Generalized Reaction Templates

License: Apache License 2.0

Python 6.03% Jupyter Notebook 93.97%

localtransform's Introduction

LocalTransform

LicenseDOI
Implementation of organic reactivity prediction with LocalTransform developed by prof. Yousung Jung group at KAIST (contact: [email protected]).

Contents

Developer

Shuan Chen ([email protected])

OS Requirements

This repository has been tested on both Linux and Windows operating systems.

Python Dependencies

  • Python (version >= 3.6)
  • Numpy (version >= 1.16.4)
  • PyTorch (version >= 1.0.0)
  • RDKit (version >= 2019)
  • DGL (version >= 0.5.2)
  • DGLLife (version >= 0.2.6)

Installation Guide

Create a virtual environment to run the code of LocalTransform.
Make sure to install pytorch with the cuda version that fits your device.
This process usually takes few munites to complete.

git clone https://github.com/kaist-amsg/LocalTransform.git
cd LocalTransform
conda create -c conda-forge -n rdenv  python=3.6 -y
conda activate rdenv
conda install pytorch cudatoolkit=11.3 -c pytorch -y
conda install -c conda-forge rdkit -y
conda install -c dglteam dgl-cuda11.3
pip install dgllife

Reproduce the results

[1] Download the raw data of USPTO-480k dataset

Download the data from https://github.com/wengong-jin/nips17-rexgen/blob/master/USPTO/ and move the data to ./data/USPTO_480k/.

[2] Data preprocessing

A two-step data preprocessing is needed to train the LocalTransform model.

1) Local reaction template derivation

First go to the data processing folder

cd preprocessing

and extract the reaction templates.

python Extract_from_train_data.py

This will give you four files, including (1) real_templates.csv (reaction templates for real bonds) (2) virtual_templates.csv (reaction templates for imaginary bonds) (3) template_infos.csv (including the hydrogen change, charge change and action information)

2) Assign the derived templates to raw data

By running

python Run_preprocessing.py

You can get four preprocessed files, including (1) preprocessed_train.csv (2) preprocessed_valid.csv (3) preprocessed_test.csv (4) labeled_data.csv

[3] Train LocalTransform model

Go to the main scripts folder

cd ../scripts

and run the following to train the model with reagent seperated or not (default: False)

python Train.py -sep True

The trained model will be saved at LocalTransform/models/LocalTransform_sep.pth

[4] Test LocalTransform model

To use the model to test on test set, simply run

python Test.py -sep True

to get the raw prediction file saved at LocalTransform/outputs/raw_prediction/LocalTransform_sep.txt
Finally you can get the reactants of each prediciton by decoding the raw prediction file

python Decode_predictions.py -sep True

The decoded reactants will be saved at LocalTransform/outputs/decoded_prediction/LocalTransform_sep.txt

[5] Exact match accuracy calculation

By using

python Calculate_topk_accuracy.py -m sep

the top-k accuracy will be calculated from the files generated at step [4]

Demo and human benchmark results

See Synthesis.ipynb for running instructions and expected output. Human benchmark results is also shown at the end of the notebook.
It takes approximately one second to predict a product from a set of given reactants.

Citation

A Generalized Template-Based Graph Neural Network for Accurate Organic Reactivity Prediction, Nat Mach Intell 2022

License

This project is covered under the Apache 2.0 License.

localtransform's People

Contributors

shuan4638 avatar

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.