Giter Club home page Giter Club logo

bionavi-np's Introduction

Introduction

Source code for the paper "Deep Learning Driven Biosynthesis Pathways Navigation for Natural Products with BioNavi-NP" in Nature Communications. The server can be found here.

bionavi

Setup

BioNavi-NP requires anaconda with python 3.7 or later, cudatoolkit=11.1.

You will wish to install BioNavi-NP in a virtual environment to prevent conflicting dependencies.

sudo apt-get install graphviz # for output visualization
conda create -n biosynthesis python==3.7
conda activate biosynthesis
cd multistep
sh install.sh

BioNavi-NP has been tested on Ubuntu 18.04, with four GPUs (Nvidia RTX3090). Installation should take no longer than 20 minutes on a modern server.

Planning

Demo code for multi-step planning has been placed inrun_biosynthesis.py.

Run

python run_biosynthesis.py

This demo now will take only 20 seconds with single GPU (Nvidia RTX3090). One need to first download the checkpoints and unzip under biosynthesis/singlestep/checkpoints/ to run the demo. The output will be visulized in viz_dir.

The key functions are shown in the following block, You may run your own molecule by changing the 'target_mol' in main_biosynthesis().

def main_biosynthesis():
    input_dict = {
        'target_mol': 'N[C@@H](CNC(=O)C(=O)O)C(=O)O', # input molecule
        'expansion_topk': 50,
        'max_depth': 10,
        'expansion_iters': 10,
        'route_topk': 5,
        #'building_blocks': ['N[C@@H](CO)C(=O)O'] # one can assign a specific building block with this command
        'building_blocks':'retro_star/dataset/bio_data/bio_building_blocks_all/building_block.csv'
    }
    

    res = run(input_dict)
    print(res)
  
def run(input_dict):
    os.environ['CUDA_VISIBLE_DEVICES'] = '0, 1, 2, 3'

    # canonicalization
    mol = Chem.MolToSmiles(Chem.MolFromSmarts(input_dict['target_mol']))
    # the trained checkpoints path, one can simply reduce the checkpotins to accelerate the prediction. 
    one_step_model_path = [                                          
        '../singlestep/checkpoints/np-like/model_step_30000.pt',
        '../singlestep/checkpoints/np-like/model_step_50000.pt',
        '../singlestep/checkpoints/np-like/model_step_80000.pt',
        '../singlestep/checkpoints/np-like/model_step_100000.pt'
    ]                                                             
    value_fn_model_path = './retro_star/saved_models/best_epoch_final_4.pt'
    viz_dir = os.path.join('viz_' + str(int(time.time()))) # the output path with visualization
    ret_file_path = os.path.join('./viz/tmp/', viz_dir + '.zip')
    planner = RSPlanner(
        gpu=get_avai_gpu(),
        use_value_fn=True,
        value_fn_model_path=value_fn_model_path,
        fp_dim=2048,
        iterations=input_dict['expansion_iters'],
        expansion_topk=input_dict['expansion_topk'],
        route_topk=input_dict['route_topk'],
        one_step_model_type='onmt',
        buliding_block_path=input_dict['building_blocks'],
        mlp_templates_path=None,
        one_step_model_path=one_step_model_path,
        beam_size=20,
        viz=True,
        viz_dir=viz_dir 
    )

    result = planner.plan(mol)

    return result

Testing on the test set

Our work on BioNavi-NP features an evaluation on our test-set. We automated this evaluation by

python run_batch_by_building_blocks.py

The whole process takes around 17 hours on four GPU (Nvidia RTX3090). One could modify the data_path and building_block_path in the script according to their own installation path.

Citation

Please cite the following paper if you use this code in your work.

Zheng, S., Zeng, T., Li, C. et al. Deep learning driven biosynthetic pathways navigation for natural products with BioNavi-NP. Nat Commun 13, 3342 (2022). https://doi.org/10.1038/s41467-022-30970-9

bionavi-np's People

Contributors

edgarzheng-hub avatar prokia 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bionavi-np's Issues

FileNotFoundError: [Errno 2] No such file or directory ?

Dear author,

I am trying to run your code. I did all the instruction you provided on Github.

When I run "python run_biosynthesis.py"

The, I get the following error:
FileNotFoundError: [Errno 2] No such file or directory: '../singlestep/checkpoints/np-like/model_step_30000.pt'

Any idea why? Thanks.

no module found error

Hi,

When I was running the model, I met the module not found error(see figure below).
it said the modulemlp_retrosyn can not be found, I checked the file and found the file is in a different folder, so I add the full path of this module to the python fileprepare_utils.py when import the mlp_retrosyn module. What I did is change the file prepare_utils.py line 9 from mlp_retrosyn.mlp_inference import MLPModel to from retro_star.packages.mlp_retrosyn.mlp_retrosyn.mlp_inference import MLPModel This problem was solved.
no_module_found

However, other modules still can not be found e.g.rdchiral (see figure). So I am wondering, instead of adding the full path to the python file mannually to import the missing module, is there a better solution?

Thanks in advance!

Single-step inference

Hi, I notice you have a fold named singlestep, do you have code to make single-step inference of retrosynthesis prediction?

Thanks

question when running

Hi,

When I was running the run_biosynthesis.py file, I got this error: pynvml.nvml.NVMLError_LibraryNotFound: NVML Shared Library Not Found and I thought this is because there is only cpu on my computer.

Could you help me figure out this problem and I wonder is there a cpu version to run your code?

Thanks!

Issue with install.sh

Hello,

I am trying to install on Ubuntu following the listed instructions under setup. Everything seems to work fine until it gets to setup.py for mlp-retrosyn. After that everything follows the same error code: 1. It says easy_install command is deprecated.

Thank you!

F6C47539-AA1F-4CF8-8D95-F22E71D6CCC5

Server down

Hi, thanks for this amazing work.
Nevertheless, lately as I would like to try the BioNavi server, it always said

Failed to submit! The server is under maintenance, Please try later.

Could you please help?
Best regards,

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.