MolecularAI / aizynthfinder

A tool for retrosynthetic planning
https://molecularai.github.io/aizynthfinder/
MIT License
580 stars 134 forks source link

different result using python interface with using third party website #138

Closed hongxianglics closed 1 year ago

hongxianglics commented 1 year ago

Hi,

I am interested in this tool and I previously tried to use it in some third party website, one is retrobiocat website:https://retrobiocat.com/ another is rxn4chemistry https://rxn.app.accelerate.science/rxn/sign-in, I tried with a simple molecule, with the smiles CC(C)NC(C)Cc1ccccc1 and I can get the transformation in the figure below.

屏幕截图 2023-09-25 145710

However, when I install the aizynthfinder and run with python interface, I can not get this transformation. I am using the code in the figure below to run aizynthfinder:

屏幕截图 2023-09-25 150124

I understand that the third party may have some modification of aizynthfinder, but I guess the main algorithm remains the same, and I checked that both precursor exsited in my starting materials database. So I am writing to ask that is there anything wrong in my python code that leads to the loss of some transformations, or how can I get as much as possible transformations for one compound using the python interface. I appreciate for your help in advance!

Best,

A-Thakkar commented 1 year ago

Hi,

rxn4chemistry does not use an up-to-date version of aizynthfinder.

The algorithm used in the rxn4chemistry version corresponds to aizynthfinder v1. So if you want to replicate the aizynthfinder implementation you see in rxn4chemistry then you need to downgrade.

I would recommend using the latest aizynthfinder version as @SGenheden and team have been hard at work on improvements, and the python interface will allow you to obtain the most flexibility and transformations.

@willfinnigan should be able to give you some more insight on retrobiocat

Otherwise will leave you in the hands of @SGenheden and team.

Amol

SGenheden commented 1 year ago

Hello,

As @A-Thakkar pointed out, a lot of things has changed since v1. Not at least the models that were completely retrained and re-released last year. It is highly recommended to use that latest models.

The implementation in retrobiocat is also using old models and rules.

As far a your code codes, I believe it is slightly inefficient. You would not need to and it is not recommended to create the AiZynthFinder class instances for every target molecule. This will give you a huge overhead in loading and re-loading the stock and models. Furthermore, you would not need to compute the time yourself. The tree_search method you are using is returning the time passed to do the retrosynthesis analysis.

So my code would look something like this

filename = "config.yml"
finder = AiZynthFinder(configfile=filename)
finder.stock.select("stock")
finder.expansion_policy.select("uspto")
finder.filter_policy.select("uspto")

for chem_target in target:
     time_list = []
     finder.target_smiles = chem_target
     chem_time = finder.tree_search()
     finder.build_routes()
     ..
     time_list.append(chem_time)
willfinnigan commented 1 year ago

Time to update retrobiocat with the new models!!

hongxianglics commented 1 year ago

Hi,

Many thanks for the detailed explanation and efforts in improving my code! I appreciate the team's work to update the model and thanks for answering my question!