binghong-ml / retro_star

Retro*: Learning Retrosynthetic Planning with Neural Guided A* Search
MIT License
127 stars 29 forks source link

Run the model just for one-step planning #4

Closed h-midlothian closed 3 years ago

h-midlothian commented 3 years ago

Hi, thanks for your code and paper. I just wonder if I can run a retrosyn prediction for a molecule with only a one-step route as the output, instead of the default multi-step routes given in the example?

binghong-ml commented 3 years ago

Retro* uses trained models for one-step retrosynthesis prediction, so you can use our codebase to do one-step predictions as well.

The problem is that the one-step interface is not exposed and you may need to write extra code for it to work. To do that, you need to first load the learned one-step model from disk using the one_step = prepare_mlp(mlp_templates, mlp_model_dump) function, and call the model via result = one_step(product_smiles). The result you will obtain is a dictionary containing scores, reactants, templates keys, through which you can access the probabilities, reactant smiles, and reaction templates of up to k candidates respectively.

Examples: https://github.com/binghong-ml/retro_star/blob/master/retro_star/api.py#L31 https://github.com/binghong-ml/retro_star/blob/master/retro_star/alg/molstar.py#L37

h-midlothian commented 3 years ago

Retro* uses trained models for one-step retrosynthesis prediction, so you can use our codebase to do one-step predictions as well.

The problem is that the one-step interface is not exposed and you may need to write extra code for it to work. To do that, you need to first load the learned one-step model from disk using the one_step = prepare_mlp(mlp_templates, mlp_model_dump) function, and call the model via result = one_step(product_smiles). The result you will obtain is a dictionary containing scores, reactants, templates keys, through which you can access the probabilities, reactant smiles, and reaction templates of up to k candidates respectively.

Examples: https://github.com/binghong-ml/retro_star/blob/master/retro_star/api.py#L31 https://github.com/binghong-ml/retro_star/blob/master/retro_star/alg/molstar.py#L37

Solved my problem. Thanks a lot