Skip to content

Commit

Permalink
Publishing version 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SGenheden committed Nov 24, 2020
1 parent 6c936a7 commit 1dec2df
Show file tree
Hide file tree
Showing 60 changed files with 2,957 additions and 2,820 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# CHANGELOG

## Version 2.0.0 - 2020-11-24 (2020-09-29)

### Breaking changes

- The `Reaction` class is renamed to `RetroReaction`
- The `Policy` class is renamed to `ExpansionPolicy`
- `config`, `stock`, `policy` and `scoring` modules moved to `aizynthfinder.context` package
- Tool "preprocess_rollout" is now called "preprocess_expansion"
- Some of the public methods of `Stock`, `Policy` and `ScorerCollection` classes are renamed
- Setting target molecule now destroys the search tree

### Features

- Add a filter policy to MCTS to remove unfeasible reactions
- Add tools to train filter policy
- Add logic to prevent cycle forming in MCTS by rejecting creation of parent molecule when expanding
- Introduce new `context` subpackage that contains the `config`, `stock`, `policy` and `scoring` modules
- The `Stock`, `ExpansionPolicy`, `FilterPolicy` and `ScorerCollection` classes now has a common interface for selection and loading
- Introduce possibility to remove unsantizable reactions from template library when training
- Catch exceptions from RDChiral more gracefully


## Version 1.2.0 - 2020-11-24 (2020-09-04)

### Features
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Before you begin, ensure you have met the following requirements:

The tool has been developed on a Linux platform, but the software has been tested on Windows 10 and macOS Catalina.

* You have installed anaconda or miniconda with python 3.6 or 3.7
* You have installed anaconda or miniconda with python 3.6, 3.7 or 3.8


## Installation
Expand All @@ -30,7 +30,7 @@ if you have GPU and CUDA libraries enabled on your machine, you can install the
* Secondly, install the ``aizynthfinder`` package

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

if you want to install the latest version
Expand Down Expand Up @@ -61,8 +61,9 @@ To use the tool you need

1. A stock file
2. A trained rollout policy network (including the Keras model and the list of unique templates)
3. A trained filer policy network (optional)

Such files can be downloaded from [figshare](https://figshare.com/articles/AiZynthFinder_a_fast_robust_and_flexible_open-source_software_for_retrosynthetic_planning/12334577) or they can be downloaded automatically using
Such files can be downloaded from [figshare](https://figshare.com/articles/AiZynthFinder_a_fast_robust_and_flexible_open-source_software_for_retrosynthetic_planning/12334577) and [here](https://figshare.com/articles/dataset/A_quick_policy_to_filter_reactions_based_on_feasibility_in_AI-guided_retrosynthetic_planning/13280507) or they can be downloaded automatically using

```
download_public_data my_folder
Expand Down Expand Up @@ -111,7 +112,7 @@ Please use ``black`` package for formatting, and follow ``pep8`` style guide.
* [@EBjerrum](https://www.github.com/EBjerrum)
* [@A-Thakkar](https://www.github.com/A-Thakkar)

The contributors have limited time for support questions, but pleae do not hesitate to submit an issue (see above).
The contributors have limited time for support questions, but please do not hesitate to submit an issue (see above).

## License

Expand All @@ -120,4 +121,4 @@ The software is licensed under the MIT license (see LICENSE file), and is free a
## References

1. Thakkar A, Kogej T, Reymond J-L, et al (2019) Datasets and their influence on the development of computer assisted synthesis planning tools in the pharmaceutical domain. Chem Sci. https://doi.org/10.1039/C9SC04944D
2. Genheden S, Thakkar A, Chadimova V, et al (2020) AiZynthFinder: a fast, robust and flexible open-source software for retrosynthetic planning. ChemRxiv. Preprint. https://doi.org/10.26434/chemrxiv.12465371.v1
2. Genheden S, Thakkar A, Chadimova V, et al (2020) AiZynthFinder: a fast, robust and flexible open-source software for retrosynthetic planning. J. Cheminf. https://jcheminf.biomedcentral.com/articles/10.1186/s13321-020-00472-1
33 changes: 22 additions & 11 deletions aizynthfinder/aizynthfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# This must be imported first to setup logging for rdkit, tensorflow etc
from aizynthfinder.utils.logging import logger
from aizynthfinder.mcts.config import Configuration
from aizynthfinder.context.config import Configuration
from aizynthfinder.mcts.mcts import SearchTree
from aizynthfinder.analysis import TreeAnalysis, RouteCollection
from aizynthfinder.chem import Molecule
Expand All @@ -16,8 +16,8 @@ class AiZynthFinder:
"""
Public API to the aizynthfinder tool
If intantiated with the path to a yaml file or dictionary of settings
the stocks and policy networks are loaded directly.
If intantiated with the path to a yaml file or dictionary of settings
the stocks and policy networks are loaded directly.
Otherwise, the user is responsible for loading them prior to
executing the tree search.
Expand Down Expand Up @@ -52,7 +52,8 @@ def __init__(self, configfile=None, configdict=None):
else:
self.config = Configuration()

self.policy = self.config.policy
self.expansion_policy = self.config.expansion_policy
self.filter_policy = self.config.filter_policy
self.stock = self.config.stock
self.scorers = self.config.scorers
self.tree = None
Expand Down Expand Up @@ -87,6 +88,7 @@ def target_mol(self):

@target_mol.setter
def target_mol(self, mol):
self.tree = None
self._target_mol = mol

def build_routes(self, min_nodes=5, scorer="state score"):
Expand Down Expand Up @@ -135,8 +137,12 @@ def run_from_json(self, params):
:return: dictionary with all settings and top scored routes
:rtype: dict
"""
self.stock.select_stocks(params["stocks"])
self.policy.select_policies(params.get("policy", params.get("policies", "")))
self.stock.select(params["stocks"])
self.expansion_policy.select(params.get("policy", params.get("policies", "")))
if "filter" in params:
self.filter_policy.select(params["filter"])
else:
self.filter_policy.deselect()
self.config.C = params["C"]
self.config.max_transforms = params["max_transforms"]
self.config.cutoff_cumulative = params["cutoff_cumulative"]
Expand All @@ -146,6 +152,7 @@ def run_from_json(self, params):
self.config.time_limit = params["time_limit"]
self.config.iteration_limit = params["iteration_limit"]
self.config.exclude_target_from_stock = params["exclude_target_from_stock"]
self.config.filter_cutoff = params["filter_cutoff"]

self.prepare_tree()
self.tree_search()
Expand Down Expand Up @@ -213,15 +220,15 @@ def _get_settings(self):
"""Get the current settings as a dictionary
"""
# To be backward-compatible
if len(self.policy.selected_policies) == 1:
policy_value = self.policy.selected_policies[0]
if len(self.expansion_policy.selection) == 1:
policy_value = self.expansion_policy.selection[0]
policy_key = "policy"
else:
policy_value = self.policy.selected_policies
policy_value = self.expansion_policy.selection
policy_key = "policies"

return {
"stocks": self.stock.selected_stocks,
dict_ = {
"stocks": self.stock.selection,
policy_key: policy_value,
"C": self.config.C,
"max_transforms": self.config.max_transforms,
Expand All @@ -232,4 +239,8 @@ def _get_settings(self):
"time_limit": self.config.time_limit,
"iteration_limit": self.config.iteration_limit,
"exclude_target_from_stock": self.config.exclude_target_from_stock,
"filter_cutoff": self.config.filter_cutoff,
}
if self.filter_policy.selection:
dict_["filter"] = self.filter_policy.selection
return dict_
2 changes: 1 addition & 1 deletion aizynthfinder/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, search_tree, scorer=None):
self.search_tree = search_tree
if scorer is None:
# Do import here to avoid circular imports
from aizynthfinder.scoring import StateScorer
from aizynthfinder.context.scoring import StateScorer

self.scorer = StateScorer()
else:
Expand Down

0 comments on commit 1dec2df

Please sign in to comment.