Giter Club home page Giter Club logo

aizynthfinder's People

Contributors

0x2b3bfa0 avatar churnikov avatar dependabot[bot] avatar lakshidaa avatar n-yoshikawa avatar sgenheden 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  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  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  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

aizynthfinder's Issues

how to set the atom occurrences limitations correctly

Hi,
I wanna break down a target compound into very small molecules. So I limit the occurrence of atom "C" as 4. But there always seems to be a complex compound that can't be broken down further in the route, how can I do to figure it out?thanks.
下载

Minor bug in preprocess_rollout.py

When re-running preprocess_rollout.py, if the library file specified in default_training.yml exists and library_headers doesn't include 'template_code' then it fails in _save_unique_templates because in this case template_code would be set in _filter_dataset which isn't called and when the library is read in we have 'names=config["library_headers"]', so the template_code column isn't read even if it's present. The workaround is obviously to delete the library file whenever I edit the raw library file and re-run; but if I forget, the error is only caught after the three preceding steps, which take some time on a large raw library.

Viewing Reaction Tree

In the documentation under [Command Line Interface --> Analyzing Output], code is provided to generate images for reaction trees. Importing ReactionTree errors with the code written in the documentation:

from aizynthfinder.analysis import ReactionTree

I think this was a typo and should say:

from aizynthfinder.reactiontree import ReactionTree

Replacing this line I was able to successfully generate reaction pathway images. Very useful software though! Thanks!

ImportError: dlopen: cannot load any more object with static TLS

Hey everyone,

I got the following error message when trying to execute aizynthfinder on a linux workstation with an older OS:

from sklearn.cluster import AgglomerativeClustering
  File "/SW/python/miniconda3/x86_64/envs/aizynth-dev/lib/python3.7/site-packages/sklearn/__init__.py", line 83, in <module>
    from .utils._show_versions import show_versions
  File "/SW/python/miniconda3/x86_64/envs/aizynth-dev/lib/python3.7/site-packages/sklearn/utils/_show_versions.py", line 12, in <module>
    from ._openmp_helpers import _openmp_parallelism_enabled
ImportError: dlopen: cannot load any more object with static TLS

But it works on newer linux workstations.

My assumptions is that the error is related to the import order of sklearn and tensorflow.
If someone else encounter this, a workaround would be to add import sklearn to aizynthfinder/interfaces/aizynthapp.py and aizynthfinder/interfaces/aizynthcli.py before the specific aizynthfinder imports.

Issue with checking stock and cyclic condition

hi there,
seems there is a minor bug in your backpropagate function
it seems you dont track the visited nodes in the tree and I guess with cyclic graph output it does get trapped in repeating pattern.
I guess one option is to check for visited nodes and if visited then terminate the search.

Are there any detailed instructions to get those trained policy network from scratch?

Hi,I wanna train policy network by myself using your data named 'dummy_raw_template_library', but when I tried to use 'preprocess_expansion' command, just three npz files were produced, and raised some error messages 'raise MoleculeException(f"Unable to sanitize molecule ({self.smiles})")
aizynthfinder.chem.MoleculeException: Unable to sanitize molecule (c1ccccc1(C)(C))'.
Do u have any ideas? Thank u very much.

Might be better to skip incorrect molecules?

Hi, I got this error for a molecule (a nitro group drawn incorrectly) this lead to a subsequent file not found error.

Traceback (most recent call last):
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/chem/mol.py", line 175, in sanitize
AllChem.SanitizeMol(self.rd_mol)
rdkit.Chem.rdchem.AtomValenceException: Explicit valence for atom # 19 N, 4, is greater than permitted

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/chrisswain/miniconda3/envs/aizynth-env/bin/aizynthcli", line 8, in
sys.exit(main())
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/interfaces/aizynthcli.py", line 270, in main
func(
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/interfaces/aizynthcli.py", line 183, in _process_multi_smiles
search_time = finder.tree_search()
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/aizynthfinder.py", line 187, in tree_search
is_solved = self.tree.one_iteration()
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/search/mcts/search.py", line 116, in one_iteration
leaf.expand()
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/search/mcts/node.py", line 234, in expand
) = self._expansion_policy(self.state.expandable_mols)
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/context/policy/policies.py", line 50, in call
return self.get_actions(molecules)
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/context/policy/policies.py", line 68, in get_actions
possible_actions, priors = self[name].get_actions(molecules)
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/context/policy/expansion_strategies.py", line 120, in get_actions
all_transforms_prop = self._predict(mol, model)
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/context/policy/expansion_strategies.py", line 161, in _predict
fp_arr = _make_fingerprint(mol, model)
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/context/policy/utils.py", line 18, in _make_fingerprint
fingerprint = obj.fingerprint(radius=2, nbits=len(model))
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/chem/mol.py", line 128, in fingerprint
self.sanitize()
File "/Users/chrisswain/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/chem/mol.py", line 179, in sanitize
raise MoleculeException(f"Unable to sanitize molecule ({self.smiles})")
aizynthfinder.utils.exceptions.MoleculeException: Unable to sanitize molecule (n1(c(=O)[nH]c2c(c1=O)c(c(s2)C(=O)N(C)C)C)c1c(N(=O)O)cccc1 ID20001)

Can Tree Search run on GPU?

Hi,
When running several search at the same time, it costs much more time or even breaks down. So I'm wondering if it can run on GPU to speed it up.
Thanks for any advice!

Simple Environment?

Hi, Thank you so much for providing this tool (including all the documentation)!

Do you maybe have a minimal environment (e.g., w/o pymongo) which could work in most cases? I am trying to run a more complex single-step model. When I first create the conda environment and include the packages I need in addition (e.g., torchdrug) everything installs, including the poetry steps afterwards. However, I do not manage to run my model in general in this environment and neither get it to run in aizynthfinder (resolving dependencies fails already, especially importing torchdrug), but get exceptions such as the below one. Now I think it would be worth to try with a minimal configuration. Or do you maybe have an idea which could be the critical packages? Thank you so much already!

libc++abi: terminating with uncaught exception of type std::length_error: vector
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Search procedure stuck

image
When analyze above structure, the progress bar is stuck and the output is not complete.
image
It seems has some kind of bugs inside the app.

Apple Silicon

Hi,

This installs and runs perfectly on my intel Mac, but it does not install on my Apple Silicon Mac

Collecting tensorflow-serving-api<3.0.0,>=2.1.0
Downloading tensorflow_serving_api-2.8.0-py2.py3-none-any.whl (37 kB)

Pip subprocess error:
ERROR: Could not find a version that satisfies the requirement tensorflow<3.0.0,>=2.8.0 (from aizynthfinder) (from versions: none)
ERROR: No matching distribution found for tensorflow<3.0.0,>=2.8.0

failed

CondaEnvException: Pip failed

I was wondering if anyone had managed to install perhaps using the details here?

https://makeoptim.com/en/deep-learning/tensorflow-metal

Graphviz installation description in Readme

Installation on Windows worked as described, including Graphviz.
On Linux (2 different machines, Ubuntu 18 resp. 20) Graphviz installs but is not registered. Seems to be a rather common issue with Graphviz in particular.
suggestions are to install with either

conda install -c anaconda graphviz
or
conda install python-graphviz

I personally only got it to work with on Linux with

pip install graphviz
(which isn't preferred for separate environments).

My suggestion is to update the Readme with at least with a comment, thank you.

CUDA warnings when running aizynthcli (previously known as: The batch mode doesn't work.)

Hi,

Thank you for having shared AiZynthFinder.
I am working on Linux Centos 7.
I tested the GUI application, it works.
However, if I launch the batch mode from a console (see below), many errors appears but finally it works.
Certainly because of that it is not possible to launch it from a Jupyter notebook.

Do you have the same phenomena?
If not, how to avoid that ?

Sincerely.

Pascal KREZEL

(aizynth-env) [krezel@localhost Notebooks]$ aizynthcli --config config.yml --smiles smiles.txt
2021-05-10 11:39:52.415791: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/yourusername/VTK:/home/yourusername/VTK/jni::/home/pkrezel/Programmes/rDock_2013.1_src/lib
2021-05-10 11:39:52.415836: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Loading expansion policy model from /home/pkrezel/Documents/Projets/001_CEA_retrosynthesis/Notebooks/uspto_model.hdf5 to uspto
2021-05-10 11:39:54.125856: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-05-10 11:39:54.126600: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1
2021-05-10 11:39:54.130630: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:02:00.0 name: Quadro K4000 computeCapability: 3.0
coreClock: 0.8105GHz coreCount: 4 deviceMemorySize: 2.95GiB deviceMemoryBandwidth: 125.53GiB/s
2021-05-10 11:39:54.130798: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/yourusername/VTK:/home/yourusername/VTK/jni::/home/pkrezel/Programmes/rDock_2013.1_src/lib
2021-05-10 11:39:54.130910: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcublas.so.11'; dlerror: libcublas.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/yourusername/VTK:/home/yourusername/VTK/jni::/home/pkrezel/Programmes/rDock_2013.1_src/lib
2021-05-10 11:39:54.131013: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcublasLt.so.11'; dlerror: libcublasLt.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/yourusername/VTK:/home/yourusername/VTK/jni::/home/pkrezel/Programmes/rDock_2013.1_src/lib
2021-05-10 11:39:54.131118: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcufft.so.10'; dlerror: libcufft.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/yourusername/VTK:/home/yourusername/VTK/jni::/home/pkrezel/Programmes/rDock_2013.1_src/lib
2021-05-10 11:39:54.131233: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcurand.so.10'; dlerror: libcurand.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/yourusername/VTK:/home/yourusername/VTK/jni::/home/pkrezel/Programmes/rDock_2013.1_src/lib
2021-05-10 11:39:54.131338: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcusolver.so.10'; dlerror: libcusolver.so.10: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/yourusername/VTK:/home/yourusername/VTK/jni::/home/pkrezel/Programmes/rDock_2013.1_src/lib
2021-05-10 11:39:54.131442: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcusparse.so.11'; dlerror: libcusparse.so.11: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/yourusername/VTK:/home/yourusername/VTK/jni::/home/pkrezel/Programmes/rDock_2013.1_src/lib
2021-05-10 11:39:54.131543: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudnn.so.8'; dlerror: libcudnn.so.8: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/yourusername/VTK:/home/yourusername/VTK/jni::/home/pkrezel/Programmes/rDock_2013.1_src/lib
2021-05-10 11:39:54.131574: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1757] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2021-05-10 11:39:54.132495: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
2021-05-10 11:39:54.132536: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-05-10 11:39:54.132560: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267]
Loading templates from /home/pkrezel/Documents/Projets/001_CEA_retrosynthesis/Notebooks/uspto_templates.hdf5 to uspto
Loading filter policy model from /home/pkrezel/Documents/Projets/001_CEA_retrosynthesis/Notebooks/uspto_filter_model.hdf5 to uspto
Loading stock from /home/pkrezel/Documents/Projets/001_CEA_retrosynthesis/Notebooks/zinc_stock.hdf5 to zinc
Selected as stock: zinc
Compounds in stock: 17422831
Selected as expansion policy: uspto
2021-05-10 11:40:01.245333: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2)
2021-05-10 11:40:01.245759: I tensorflow/core/platform/profile_utils/cpu_utils.cc:112] CPU Frequency: 3691235000 Hz

Python kernel do not launch in Jupyter

Hi,

First of all, I would like to congratulate you for the superb tool you have developped for organic chemists.

I have hard times launching Python kernel through Jupyter. I don't know why. I am not proficient in coding nor python.
Can you please help me in order to launch Aizynthfinder?

Herein the error message I have when starting Python kernel in Jupyter :

ERROR:asyncio:Exception in callback <TaskWakeupMethWrapper object at 0x00000278AFD9E340>(<Future finis...C: 1\r\n\r\n'>)
handle: <Handle <TaskWakeupMethWrapper object at 0x00000278AFD9E340>(<Future finis...C: 1\r\n\r\n'>)>
Traceback (most recent call last):
File "C:\Users\Mo.conda\envs\aizynth-env\lib\asyncio\events.py", line 81, in _run
self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <Task pending name='Task-9' coro=<HTTP1ServerConnection._server_request_loop() running at C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\tornado\http1connection.py:823> wait_for=<Future finished result=b'GET /kernel...PC: 1\r\n\r\n'> cb=[IOLoop.add_future..() at C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\tornado\ioloop.py:688]> while another task <Task pending name='Task-2' coro=<KernelManager._async_start_kernel() running at C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\jupyter_client\manager.py:336>> is being executed.
ERROR:asyncio:Exception in callback <TaskWakeupMethWrapper object at 0x00000278ACB511F0>(<Future finis...C: 1\r\n\r\n'>)
handle: <Handle <TaskWakeupMethWrapper object at 0x00000278ACB511F0>(<Future finis...C: 1\r\n\r\n'>)>
Traceback (most recent call last):
File "C:\Users\Mo.conda\envs\aizynth-env\lib\asyncio\events.py", line 81, in _run
self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <Task pending name='Task-36' coro=<HTTP1ServerConnection._server_request_loop() running at C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\tornado\http1connection.py:823> wait_for=<Future finished result=b'GET /api/co...PC: 1\r\n\r\n'> cb=[IOLoop.add_future..() at C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\tornado\ioloop.py:688]> while another task <Task pending name='Task-2' coro=<KernelManager._async_start_kernel() running at C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\jupyter_client\manager.py:336>> is being executed.
[I 20:01:11.760 NotebookApp] Kernel started: 51374adc-d6d5-4612-837b-7c2e68270955, name: python3
Traceback (most recent call last):
File "C:\Users\Mo.conda\envs\aizynth-env\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Mo.conda\envs\aizynth-env\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\ipykernel_launcher.py", line 16, in
app.launch_new_instance()
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance
app.initialize(argv)
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\traitlets\config\application.py", line 87, in inner
return method(app, *args, **kwargs)
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\ipykernel\kernelapp.py", line 625, in initialize
self.write_connection_file()
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\ipykernel\kernelapp.py", line 234, in write_connection_file
write_connection_file(cf, ip=self.ip, key=self.session.key, transport=self.transport,
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\jupyter_client\connect.py", line 164, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\Mo.conda\envs\aizynth-env\lib\contextlib.py", line 113, in enter
return next(self.gen)
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\jupyter_core\paths.py", line 461, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed while importing win32api: Le module spécifié est introuvable.
[I 20:01:14.761 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Traceback (most recent call last):
File "C:\Users\Mo.conda\envs\aizynth-env\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Mo.conda\envs\aizynth-env\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\ipykernel_launcher.py", line 16, in
app.launch_new_instance()
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\traitlets\config\application.py", line 844, in launch_instance
app.initialize(argv)
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\traitlets\config\application.py", line 87, in inner
return method(app, *args, **kwargs)
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\ipykernel\kernelapp.py", line 625, in initialize
self.write_connection_file()
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\ipykernel\kernelapp.py", line 234, in write_connection_file
write_connection_file(cf, ip=self.ip, key=self.session.key, transport=self.transport,
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\jupyter_client\connect.py", line 164, in write_connection_file
with secure_write(fname) as f:
File "C:\Users\Mo.conda\envs\aizynth-env\lib\contextlib.py", line 113, in enter
return next(self.gen)
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\jupyter_core\paths.py", line 461, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\Mo.conda\envs\aizynth-env\lib\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed while importing win32api: Le module spécifié est introuvable.

Thank you in advance,
Mo

'preprocess_expansion config.yml' command can not create a file that ends with unique_templates.hdf5

Hi. I wanna retrain aizynthfinder by myself based on a part of USPTO datasets. And I have created a CSV file through rdchiral, which has all five mandatory columns. When I set the config.yml well and tried to use the command 'preprocess_expansion', an error was raised below and the unique_templates.hdf5 file was not created:
2021-03-04 14:51:11.569134: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-03-04 14:51:11.569341: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Dataset filtered/loaded, generating labels...
Labels created and splitted, generating inputs...
Inputs created and splitted, splitting full Dataset...
Full Dataset splitted, creating unique template set
Traceback (most recent call last):
File "d:\software\anaconda\lib\site-packages\pandas\core\indexes\base.py", line 2895, in get_loc
return self._engine.get_loc(casted_key)
File "pandas_libs\index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\hashtable_class_helper.pxi", line 1675, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas_libs\hashtable_class_helper.pxi", line 1683, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'classification'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "d:\software\anaconda\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "d:\software\anaconda\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "D:\software\anaconda\Scripts\preprocess_expansion.exe_main
.py", line 7, in
File "d:\software\anaconda\lib\site-packages\aizynthfinder\training\preprocess_expansion.py", line 102, in main
_save_unique_templates(dataset, config)
File "d:\software\anaconda\lib\site-packages\aizynthfinder\training\preprocess_expansion.py", line 66, in _save_unique_templates
dataset["classification"].fillna("-", inplace=True)
File "d:\software\anaconda\lib\site-packages\pandas\core\frame.py", line 2902, in getitem
indexer = self.columns.get_loc(key)
File "d:\software\anaconda\lib\site-packages\pandas\core\indexes\base.py", line 2897, in get_loc
raise KeyError(key) from err
KeyError: 'classification'

Additionally, my config.yml setting is:
library_headers: ["reaction_hash", "reactants", "products","retro_template", "template_hash","template_code"]
metadata_headers: ["template_hash"]
output_path: "."
file_prefix: "test1"
split_size:
training: 0.6
testing: 0.2
validation: 0.2

Any help would be appreciated.

AttributeError: 'str' object has no attribute 'items'

hi,
Sorry, there was an error in the problem submission on the last closed issue. So I reopened an issue. The problem was not described. When I execute the "app = aizynthapp (" / path / to / configFile. Yaml ")" statement, the following problems occur when loading the template. I tried to update the setuptools library, but I didn't solve the corresponding problem, so let's ask if there is any solution.

Loading expansion policy model from D:/py_project/AiZynthFinder/aizynthfinder/data/full_uspto_model.hdf5 to full_uspto
Loading templates from D:/py_project/AiZynthFinder/aizynthfinder/data/full_uspto_templates.hdf5 to full_uspto

AttributeError Traceback (most recent call last)
in
1 from aizynthfinder.interfaces import AiZynthApp
2 configfile=r"D:\py_project\AiZynthFinder\aizynthfinder\config.yml"
----> 3 app = AiZynthApp(configfile)

D:\Program Files (x86)\Anaconda3\lib\site-packages\aizynthfinder\interfaces\aizynthapp.py in init(self, configfile, setup)
56 def init(self, configfile: str, setup: bool = True) -> None:
57 setup_logger(logging.INFO)
---> 58 self.finder = AiZynthFinder(configfile=configfile)
59 self._input: StrDict = dict()
60 self._output: StrDict = dict()

D:\Program Files (x86)\Anaconda3\lib\site-packages\aizynthfinder\aizynthfinder.py in init(self, configfile, configdict)
46
47 if configfile:
---> 48 self.config = Configuration.from_file(configfile)
49 elif configdict:
50 self.config = Configuration.from_dict(configdict)

D:\Program Files (x86)\Anaconda3\lib\site-packages\aizynthfinder\context\config.py in from_file(cls, filename)
110 with open(filename, "r") as fileobj:
111 _config = yaml.load(fileobj.read(), Loader=yaml.SafeLoader)
--> 112 return Configuration.from_dict(_config)
113
114 def update(self, **settings: Any) -> None:

D:\Program Files (x86)\Anaconda3\lib\site-packages\aizynthfinder\context\config.py in from_dict(cls, source)
93 **source.get("filter", {}).get("files", {})
94 )
---> 95 config_obj.stock.load_from_config(**source.get("stock", {}))
96 config_obj.scorers.load_from_config(**source.get("scorer", {}))
97

D:\Program Files (x86)\Anaconda3\lib\site-packages\aizynthfinder\context\stock.py in load_from_config(self, **config)
305 self.set_stop_criteria(config["stop_criteria"])
306
--> 307 for key, stockfile in config.get("files", {}).items():
308 self.load(stockfile, key)
309

AttributeError: 'str' object has no attribute 'items'

Could not Reorder by 'Sum of prices' in the GUI?

Hi. I wanna reorder by 'Sum of prices' to show reactions, but there seems no such item in the drop down list. And I also notice that there is no price information in the provided zinc_stock.hdf5 file. Do I need to modify the source code of scoring.py or stock.py in a folder named 'context' besides adding price information to the stock file? Any help would be appreciated.

Can Tree Search run on GPU?

Hi,
When running several search at the same time, it costs much more time or even breaks down. So I'm wondering if it can run on GPU to speed it up.

Reading in raw template library

I am generating template_hash with python's hash function which should return an integer but for some reason doesn't always. This causes a problem in preprocess_rollout.py in read_csv in _filter_dataset. The same problem could occur with mixed types in reaction_hash and other columns. I fixed this by using low_memory=False.

Compounds to Procure doesn't shown

Describe
I am trying to use AiZynthApp in jupyter notebook. after show reactions, I can't see a Compounds to Procure.but Solved and Steps are shown correctly.
The procure file (png) exists in the directory (/ tmp / tmp49t5ya0a) but is not displayed. It may be due to the character encoding, but it may be another reason.
I'm not sure what is wrong. I would be grateful for any help.
Thank you!

Compounds to Procure
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/IPython/core/display.py in _data_and_metadata(self, always_both)
   1292         try:
-> 1293             b64_data = b2a_base64(self.data).decode('ascii')
   1294         except TypeError:

TypeError: a bytes-like object is required, not 'Image'

During handling of the above exception, another exception occurred:

FileNotFoundError                         Traceback (most recent call last)
/usr/local/lib/python3.8/dist-packages/IPython/core/formatters.py in __call__(self, obj, include, exclude)
    968 
    969             if method is not None:
--> 970                 return method(include=include, exclude=exclude)
    971             return None
    972         else:

/usr/local/lib/python3.8/dist-packages/IPython/core/display.py in _repr_mimebundle_(self, include, exclude)
   1281         if self.embed:
   1282             mimetype = self._mimetype
-> 1283             data, metadata = self._data_and_metadata(always_both=True)
   1284             if metadata:
   1285                 metadata = {mimetype: metadata}

/usr/local/lib/python3.8/dist-packages/IPython/core/display.py in _data_and_metadata(self, always_both)
   1293             b64_data = b2a_base64(self.data).decode('ascii')
   1294         except TypeError:
-> 1295             raise FileNotFoundError(
   1296                 "No such file or directory: '%s'" % (self.data))
   1297         md = {}

FileNotFoundError: No such file or directory: '<PIL.Image.Image image mode=RGBA size=1200x200 at 0x7F63A1559820>'

Configuration:

RDKit version: 2020.09.5(Build from source)
Host OS: CentOS 7.4
Docker Container:ubuntu 20.04
Python version : 3.8.5
AiZynthFinder version : 2.4.0

Commands:
I installed boost-1.69.0 from source and it looks like it's working properly.

git clone https://github.com/boostorg/boost.git
cd boost
git checkout boost-1.69.0
git submodule update --init --recursive
./bootstrap.sh --with-python=/usr/bin/python3
./b2 --prefix=/usr/local -j18
./b2 install --prefix=/usr/local -j18

I also installed rdkit_2020_09_05(from source) and aizynthfinder 2.4.0.

# install rdkit
RDBASE=/usr/local/src/rdkit
RDKIT_BRANCH=Release_2020_09_5
git clone https://github.com/rdkit/rdkit.git
cd $RDBASE
git checkout $RDKIT_BRANCH
git submodule update --init --recursive
mkdir build && cd build
cmake -D RDK_BUILD_INCHI_SUPPORT=ON -D PYTHON_EXECUTABLE=/usr/bin/python3 ..
make -j18 .. install
python3 -m pip install https://github.com/MolecularAI/aizynthfinder/archive/v2.4.0.tar.gz

filter select bug

I have tested your code, but have found problems selecting the filtering model.
in aizynthfinder/aizynthfinder/interfaces/aizynthcli.py line 186

image

try:
    finder.filter_policy.select(args.policy or finder.filter_policy.items[0])
except KeyError:
    pass

Pytables Dependency Issue on Windows 11

Installing via env-users.yml on Windows 11 (21H2) (after modifying yml to point to code version 3.3.1 instead of 3.0.0), code throws an error within jupyter notebook related to a missing Pytables.

Using an identical installation process on macOS Monterey (12.3) does not exhibit this issue. Haven't tested Linux.

Installing pytables via conda resolves this issue:
conda install -c conda-forge pytables

Error copied from jupyter notebook:
notebook_error.log

Install instructions lead to installing old version

Hey, this is just a minor heads up. I followed the install instructions in the README.md document under the "Troubleshooting" section, and the line:

python -m pip install https://github.com/MolecularAI/aizynthfinder/archive/v2.4.0.tar.gz

installs version 2.4.0. Once I found I had the old version I had no issues upgrading it, but I wanted to let you know about it because it is probably a very easy thing to fix and it might help out some people (like me) who simply copy and paste the install commands and don't read them thoroughly. Thank you in advance!

How to train a reaction involving two simultaneous reaction steps?

FB991182-E2F3-40de-9705-950577FFC488
Hi,
I extracted this reaction's retro template by rdchiral, as follows:
'[OH;D1;+0:2]-[c:1].[OH;D1;+0:4]-[c:3]>>[c:1]-[O;H0;D2;+0:2]-C-c1:c:c:c:c:c:1.[c:3]-[O;H0;D2;+0:4]-C-c1:c:c:c:c:c:1'

Obviously, the template has two products, It can not be used to train the reaction. Any idea to train this type of reaction? Thank U very much.
The reaction smiles is 'CC(C)(C)C1=CC(C2=C(CCCC3)C3=CC4=C2CCCC4)=C(OCC5=CC=CC=C5)C(C6=CC(C(C)(C)C)=CC=C6OC[C@@h]7CCCC[C@@h]7COC8=CC=C(C(C)(C)C)C=C8C9=CC(C(C)(C)C)=CC(C%10=C(CCCC%11)C%11=CC%12=C%10CCCC%12)=C9OCC%13=CC=CC=C%13)=C1>>OC1=C(C2=C(CCCC3)C3=CC4=C2CCCC4)C=C(C(C)(C)C)C=C1C5=CC(C(C)(C)C)=CC=C5OC[C@@h]6CCCC[C@@h]6COC7=CC=C(C(C)(C)C)C=C7C8=CC(C(C)(C)C)=CC(C9=C(CCCC%10)C%10=CC%11=C9CCCC%11)=C8O'

Molecule with difficulties

Hi,

My name is Pascal KREZEL and I am testing AiZynthFinder presently.
It is a very interesting tool. Thank you for having shared it.
To improve it, I show you the following strange result:
image

Best.

Pascal

Long-term binary artifact storage

Have you considered using a long-term solution like Zenodo or GitHub releases for storing artifacts like trained models? The former would even link with DOI, and both are as practical as the current Figshare server for retrieving the data.

TensorFlow library and AVX instructions error

Hi,

I could install Aizynthfinder package on my synology:
"conda env create -f https://raw.githubusercontent.com/MolecularAI/aizynthfinder/master/env-users.yml"

Installation proceeds well but once I try to import Aizynthfinder package through Python interface with the following command: "from aizynthfinder.aizynthfinder import AiZynthFinder", I receive the following error message related to Tensorflow package: "The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine.
Aborted (core dumped)"

How can I fix this problem ?

Thanks for your help.

Dam

Steps "None" are displayed (Jupyter)

After a fresh install (new machine; Ubuntu 18 LTS), I had some issues (a & b I mentioned in case they are related to Steps "None", though b shouldn't affect it)
Using Python 3.7.5 as base, conda environment.

a) aiohttp 3.6.3 requires yarl<1.6.0,>=1.0, but you have yarl 1.6.2 which is incompatible.
b) despite GPU & no errors in TF install, there is a dlerror missing missing libcudnn.so.8 . and some follow-up libraries. Python switches to CPU based TF. Not fun, but acceptable for now.

The app from within Jupyter seems to work, though I don't see any steps after the analysis is finished. Using your example smiles, starting materials are displayed, but no reactions schemes.
"None" is displayed.

From previous versions, I don't expect this to be correct behavior?

ImportError: DLL load failed while importing win32api: The specified program could not be found

When I execute the command 'aizynthapp --config config.yml', the jupyter shows 'kernel error' and the following error:

Traceback (most recent call last):
File "d:\software\anaconda\envs\test\lib\site-packages\tornado\web.py", line 1704, in _execute
result = await result
File "d:\software\anaconda\envs\test\lib\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "d:\software\anaconda\envs\test\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
model = yield maybe_future(
File "d:\software\anaconda\envs\test\lib\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "d:\software\anaconda\envs\test\lib\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "d:\software\anaconda\envs\test\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 98, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "d:\software\anaconda\envs\test\lib\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "d:\software\anaconda\envs\test\lib\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "d:\software\anaconda\envs\test\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 110, in start_kernel_for_session
kernel_id = yield maybe_future(
File "d:\software\anaconda\envs\test\lib\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "d:\software\anaconda\envs\test\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 176, in start_kernel
kernel_id = await maybe_future(self.pinned_superclass.start_kernel(self, **kwargs))
File "d:\software\anaconda\envs\test\lib\site-packages\jupyter_client\multikernelmanager.py", line 186, in start_kernel
km.start_kernel(**kwargs)
File "d:\software\anaconda\envs\test\lib\site-packages\jupyter_client\manager.py", line 337, in start_kernel
kernel_cmd, kw = self.pre_start_kernel(**kw)
File "d:\software\anaconda\envs\test\lib\site-packages\jupyter_client\manager.py", line 286, in pre_start_kernel
self.write_connection_file()
File "d:\software\anaconda\envs\test\lib\site-packages\jupyter_client\connect.py", line 466, in write_connection_file
self.connection_file, cfg = write_connection_file(self.connection_file,
File "d:\software\anaconda\envs\test\lib\site-packages\jupyter_client\connect.py", line 136, in write_connection_file
with secure_write(fname) as f:
File "d:\software\anaconda\envs\test\lib\contextlib.py", line 113, in enter
return next(self.gen)
File "d:\software\anaconda\envs\test\lib\site-packages\jupyter_core\paths.py", line 461, in secure_write
win32_restrict_file_to_user(fname)
File "d:\software\anaconda\envs\test\lib\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed while importing win32api: The specified program could not be found.

Hard dependency on anaconda

This project only depends on anaconda because of rdkit, which still doesn't support PyPi packages because of its native dependencies, but this could change relatively soon (at least partially). Once that happens, this project could migrate all its dependencies to poetry or any similarly modern package manager, leaving conda as an optional dependency.

This issue is intended as a reminder, and doesn't require any immediate action. Feel free to add it to a project board, leave it open, or simply close it and, optionally, document this in a separate file.

Python and rdkit versions

As of today (14-Aug-20), rdkit reports that it is not compatible with the latest Python, 3.8 (but see https://github.com/brsynth/rdkit if you're interested). Also, the default conda install (at least on my system) installs rdkit 2017.09.1, and training.py fails with an ImportWarning. This set-up worked fine:
conda create -n AiZynthFinder python=3.6 tensorflow-gpu=2.2.0 graphviz
conda install -n AiZynthFinder -c rdkit rdkit=2019.09.1 -y

Route starts to cycle when run search complicated target compound.

zishanchun-official_length12

Hi, I found that when the target compound is complicated, the route inclines to cycle, just like the compounds marked by the red cycle. how to solve it? how to force the mcts to break the large compound marked by the red cycle into smaller molecules. thank you.
the target compound is Paclitaxel.

Error when applying retro_template to product

When running either aizynthcli or the GUI, I sometimes get the following error:

Traceback (most recent call last):
File "xx/bin/aizynthcli", line 33, in
sys.exit(load_entry_point('aizynthfinder', 'console_scripts', 'aizynthcli')())
File "xx/aizynthfinder/aizynthfinder/interfaces/aizynthcli.py", line 119, in main
_process_multi_smiles(args.smiles, finder, args.output)
File "xx/aizynthfinder/aizynthfinder/interfaces/aizynthcli.py", line 86, in _process_multi_smiles
search_time = finder.tree_search()
File "xx/aizynthfinder/aizynthfinder/aizynthfinder.py", line 176, in tree_search
leaf = self.tree.select_leaf()
File "xx/aizynthfinder/aizynthfinder/mcts/mcts.py", line 100, in select_leaf
promising_child = current.promising_child()
File "xx/aizynthfinder/aizynthfinder/mcts/node.py", line 232, in promising_child
return self.promising_child()
File "xx/aizynthfinder/aizynthfinder/mcts/node.py", line 230, in promising_child
child = self._select_child(index)
File "xx/aizynthfinder/aizynthfinder/mcts/node.py", line 311, in _select_child
states = self._make_child_states(reaction)
File "xx/aizynthfinder/aizynthfinder/mcts/node.py", line 287, in _make_child_states
reactants_list = reaction.apply()
File "xx/aizynthfinder/aizynthfinder/chem.py", line 279, in apply
reactants = rdc.rdchiralRun(reaction, rct)
File "xx/lib/python3.6/site-packages/rdchiral/main.py", line 242, in rdchiralRun
merged_map_to_id[bj], b.GetBondType())
RuntimeError: Pre-condition Violation
attempt to add self-bond
Violation occurred on line 300 in file Code/GraphMol/RWMol.cpp
Failed Expression: atomIdx1 != atomIdx2
RDKIT: 2020.03.3
BOOST: 1_67

For some reason I don't understand, RDChiral is failing when trying to apply the retro_template to the product. My workaround is to catch this in mcts/node.py:

def _make_child_states(self, reaction):
    mols = [mol for mol in self.state.mols if mol is not reaction.mol]
    try:
        reactants_list = reaction.apply()
    except:
        reactants_list = None

I am training on Reaxys data and evaluating on the ChEMBL sample of 100 compounds. With this modification it solves 65 compounds.

Scanner Error

Hello,

I'm trying to use the Aizynthapp on the jupyter notebooks, using the documents provided in figshare. When I run the first cell I get the following error message:

ScannerError: while scanning for the next token
found character '\t' that cannot start any token
in "", line 5, column 7:
full_uspto_03_05_19_unique_temp ...

I'm running this in a Linux cluster using python 3.8. If that's of any help.

Thanks in advance for your help.

pandas warning

I suspect you know about this. I get a warning when using the cli

/Users/myname/miniconda3/envs/aizynth-env/lib/python3.8/site-packages/aizynthfinder/utils/files.py:48: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
data = data.append(new_data)

Issue with template application

Hi! After playing around with aizynthfinder, I have detected some issues regarding the application of the reaction templates, mainly among those defined as "selective" in your publication "Datasets and their influence on the development of computer assisted synthesis planning tools in the pharmaceutical domain"

Within the cases identified so far, two main classes are predominant:

  • Intramolecular reactions for which the application of the corresponding template may define a two-component reaction.
  • Reactions for which the forward application of the corresponding template is not able to regenerate the desired product.

Apparently, aizynthfinder does not check these specific cases in a forward manner to ensure product regeneration and keep consistency in the number of components.

For the sake of clarity, I'm attaching a jupyter notebook including a couple of examples:
WrongRXNtemplates.pdf

Thanks, David.

Incompatibility with python 3.8

Hello,
great tool, well done.
I was trying to set it up within a conda env python=3.8.5 (the install description states that it should work on python 3.8)
However rdkit is incompatible with python 3.8

  • rdkit -> python[version='2.6.|2.7.|3.5.|3.6.|>=2.7,<2.8.0a0|>=3
    0a0|>=3.5,<3.6.0a0|3.4.*']

Your python: python=3.8
You could fix this in the description or am I wrong?
Thank you!

Incorparate AiZynthFinder in to own python script

Hello,
how can I incorperate AiZynthFinder into my own script. I have a program that predicts different molecular properties based on the SMILES and I also want suggest the user a synthesis route based on that.

ValueError: Atomic identity should not change in a reaction!

Hi, I retrained aizynthfinder based on the USPTO dataset, named '1976_Sep2016_USPTOgrants_smiles' and '2001_Sep2016_USPTOapplications_smiles'. After executing "preprocess_expansion" command (template_occurance: 5), I got about 60k unique templates. And then I carried out "aizynth_training config.yml expansion" command(using default training parameters). After 45 epochs, the model ended up with early stopping, and the tail epochs were as follows:

epoch,accuracy,loss,top10_acc,top50_acc,top_k_categorical_accuracy,val_accuracy,val_loss,val_top10_acc,val_top50_acc,val_top_k_categorical_accuracy
41,0.37056171894073486,2.1262738704681396,0.9547296762466431,0.9979926347732544,0.8572583794593811,0.13169552385807037,3.383960247039795,0.8447669148445129,0.9704044461250305,0.6412613987922668
42,0.37039411067962646,2.1262192726135254,0.9547430276870728,0.9980724453926086,0.8570069670677185,0.13195891678333282,3.3870015144348145,0.8439049124717712,0.9697579145431519,0.6426501870155334
43,0.3698766529560089,2.1254725456237793,0.9548799991607666,0.9980325102806091,0.8570641875267029,0.1314081847667694,3.3882839679718018,0.8437373042106628,0.9703325629234314,0.6419557929039001
44,0.3700628876686096,2.1263396739959717,0.9547683000564575,0.998033881187439,0.8573368787765503,0.13179129362106323,3.3904759883880615,0.8440245985984802,0.9700692296028137,0.6423149704933167

I doubt the model was not trained well since too low accuracy, but I could not find better training parameters.
The trained keras_model performs not bad for most target smiles in the tree search except for a few target smiles. In the GUI, a target smile got the following error:

_ValueError Traceback (most recent call last)
D:\software\anaconda\lib\site-packages\aizynthfinder\interfaces\aizynthapp.py in _tree_search(self)
367 def _tree_search(self) -> None:
368 with self._output["tree_search"]:
--> 369 self.finder.tree_search(show_progress=True)
370 print("Tree search completed.")
371

D:\software\anaconda\lib\site-packages\aizynthfinder\aizynthfinder.py in tree_search(self, show_progress)
197 leaf.expand()
198 while not leaf.is_terminal():
--> 199 child = leaf.promising_child()
200 if child:
201 child.expand()

D:\software\anaconda\lib\site-packages\aizynthfinder\mcts\node.py in promising_child(self)
239 child = self._select_child(index)
240 if not child and max(self._children_values) > 0:
--> 241 return self.promising_child()
242
243 if not child:

D:\software\anaconda\lib\site-packages\aizynthfinder\mcts\node.py in promising_child(self)
237 index = np.random.choice(indices)
238
--> 239 child = self._select_child(index)
240 if not child and max(self._children_values) > 0:
241 return self.promising_child()

D:\software\anaconda\lib\site-packages\aizynthfinder\mcts\node.py in _select_child(self, child_idx)
372
373 reaction = self._children_actions[child_idx]
--> 374 if not reaction.reactants:
375 reaction.apply()
376

D:\software\anaconda\lib\site-packages\aizynthfinder\chem.py in reactants(self)
476 """
477 if not self._reactants:
--> 478 self._reactants = self.apply()
479 return self._reactants
480

D:\software\anaconda\lib\site-packages\aizynthfinder\chem.py in apply(self)
487 :return: the products of the reaction
488 """
--> 489 reaction = rdc.rdchiralReaction(self.smarts)
490 rct = rdc.rdchiralReactants(self.mol.smiles)
491 try:

D:\software\anaconda\lib\site-packages\rdchiral\initialization.py in init(self, reaction_smarts)
42 if any(self.atoms_rt_map[i].GetAtomicNum() != self.atoms_pt_map[i].GetAtomicNum()
43 for i in self.atoms_rt_map if i in self.atoms_pt_map):
---> 44 raise ValueError('Atomic identity should not change in a reaction!')
45
46 # Call template_atom_could_have_been_tetra to pre-assign value to atom

ValueError: Atomic identity should not change in a reaction!_

Some target smiles showed the following RDKit ERROR when run search in the GUI:

RDKit ERROR:
RDKit ERROR: ****
RDKit ERROR: Pre-condition Violation
RDKit ERROR: attempt to add self-bond
RDKit ERROR: Violation occurred on line 300 in file D:\bld\rdkit_1591869558094\work\Code\GraphMol\RWMol.cpp
RDKit ERROR: Failed Expression: atomIdx1 != atomIdx2
RDKit ERROR: ****
RDKit ERROR:
RDKit ERROR: [15:59:36]
RDKit ERROR:
RDKit ERROR: ****
RDKit ERROR: Pre-condition Violation
RDKit ERROR: attempt to add self-bond
RDKit ERROR: Violation occurred on line 300 in file D:\bld\rdkit_1591869558094\work\Code\GraphMol\RWMol.cpp
RDKit ERROR: Failed Expression: atomIdx1 != atomIdx2
RDKit ERROR: ****
RDKit ERROR:
RDKit ERROR: [15:59:36]
RDKit ERROR:
RDKit ERROR: ****
RDKit ERROR: Pre-condition Violation
RDKit ERROR: attempt to add self-bond
RDKit ERROR: Violation occurred on line 300 in file D:\bld\rdkit_1591869558094\work\Code\GraphMol\RWMol.cpp
RDKit ERROR: Failed Expression: atomIdx1 != atomIdx2
RDKit ERROR: ****
RDKit ERROR:

Any help would be appreciated!

issue with importing from markupsafe

It appears that the new release of markupsafe breaks importing AiZynthFinder - link to the same issue in markupsafe: pallets/markupsafe#284

apparently v2.0.1 should work fine

edit: I tried swapping out the default installation of markupsafe with v2.0.1 and the aizynthfinder import works fine! :)

Retraining Aizynthfinder

Hi! So I tired retraining aizynthfinder on reactions sources from Maestro. We created reaction smiles format, put it through rxnmapper(atom mapping program) and then through rdchiral for the retro templates. I put it through preprocess_rollout and training. But when I used, it showed errors and wasn't able to process many of the compounds I put through(only able to process 99 of 395 compounds). I have all the necessary columns for the training file, and followed the documentation for training. Any input on why this might be happening?

Suggestion for preprocess_rollout

I have a raw template library with ~15M rows. preprocess_rollout runs for ~1 day then fails in smiles_to_fingerprint. All my SMILES are valid, but a few cannot be sanitized. I could write a separate filter to prep the data, but I prefer to incorporate this into aizynthfinder in case I forget and lose another day:

aizynthfinder/training/utils.py:

14c14
< from aizynthfinder.chem import Molecule
---
> from aizynthfinder.chem import Molecule, MoleculeException
141a142,159
>
>
> def is_sanitizable(args):
>     """
>     Check whether a SMILES is sanitizable
>
>     :param args: the SMILES in the first element
>     :type args: tuple
>     :return: whether the SMILES is sanitizable
>     :rtype: bool
>     """
>     smiles = args[0]
>     try:
>         Molecule(smiles=smiles, sanitize=True)
>     except MoleculeException:
>         return False
>     else:
>         return True

aizynthfinder/training/preprocess_rollout.py:

--- 14,16 ----
      smiles_to_fingerprint,
+     is_sanitizable
  )
29a31,36
>
>     # remove rows with unsanitizable product SMILES
>     products = full_data["products"].to_numpy()
>     idx = np.apply_along_axis(is_sanitizable, 0, [products])
>     full_data = full_data[idx]
>

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.