Skip to content

Commit

Permalink
Merge pull request #112 from MolecularAI/release-3.7.0
Browse files Browse the repository at this point in the history
Release 3.7.0
  • Loading branch information
Lakshidaa committed Jun 1, 2023
2 parents ead1aa2 + cd0215d commit d30600e
Show file tree
Hide file tree
Showing 71 changed files with 4,334 additions and 1,546 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ name: tests

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run
run: |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh |
bash -s -- --batch
conda env create -f env-dev.yml
conda run --name aizynth-dev poetry install -E all
conda run --name aizynth-dev inv full-tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
directory: ./coverage/
name: codecov-aizynth
fail_ci_if_error: false
verbose: true
- uses: actions/checkout@v3
- name: Run
run: |
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh |
bash -s -- --batch
conda env create -f env-dev.yml
conda run --name aizynth-dev poetry install -E all -E tf
conda run --name aizynth-dev inv full-tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
directory: ./coverage/
name: codecov-aizynth
fail_ci_if_error: false
verbose: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,4 @@ coverage/
# Files created by the tool
smiles.txt
config_local.yml
devtools/seldon-output-*/
34 changes: 17 additions & 17 deletions aizynthfinder/aizynthfinder.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
""" Module containing a class that is the main interface the retrosynthesis tool.
"""
from __future__ import annotations

import time
from collections import defaultdict
from typing import TYPE_CHECKING

from tqdm import tqdm

# This must be imported first to setup logging for rdkit, tensorflow etc
from aizynthfinder.utils.logging import logger
from aizynthfinder.utils.loading import load_dynamic_class
from aizynthfinder.context.config import Configuration
from aizynthfinder.search.mcts import MctsSearchTree
from aizynthfinder.reactiontree import ReactionTreeFromExpansion
from aizynthfinder.analysis import (
TreeAnalysis,
RouteCollection,
RouteSelectionArguments,
TreeAnalysis,
)
from aizynthfinder.chem import Molecule, TreeMolecule, FixedRetroReaction
from aizynthfinder.chem import FixedRetroReaction, Molecule, TreeMolecule
from aizynthfinder.context.config import Configuration
from aizynthfinder.reactiontree import ReactionTreeFromExpansion
from aizynthfinder.search.andor_trees import AndOrSearchTreeBase
from aizynthfinder.search.mcts import MctsSearchTree
from aizynthfinder.utils.exceptions import MoleculeException
from aizynthfinder.utils.loading import load_dynamic_class

# This must be imported first to setup logging for rdkit, tensorflow etc
from aizynthfinder.utils.logging import logger

if TYPE_CHECKING:
from aizynthfinder.chem import RetroReaction
from aizynthfinder.utils.type_utils import (
StrDict,
Optional,
Union,
Callable,
Dict,
List,
Optional,
StrDict,
Tuple,
Dict,
Union,
)
from aizynthfinder.chem import RetroReaction


class AiZynthFinder:
Expand Down Expand Up @@ -230,17 +232,15 @@ def tree_search(self, show_progress: bool = False) -> float:
self.search_stats["time"] = time_past
return time_past

def _setup_search_tree(self):
def _setup_search_tree(self) -> None:
self._logger.debug("Defining tree root: %s" % self.target_smiles)
if self.config.search_algorithm.lower() == "mcts":
self.tree = MctsSearchTree(
root_smiles=self.target_smiles, config=self.config
)
else:
cls = load_dynamic_class(self.config.search_algorithm)
self.tree: AndOrSearchTreeBase = cls(
root_smiles=self.target_smiles, config=self.config
)
self.tree = cls(root_smiles=self.target_smiles, config=self.config)


class AiZynthExpander:
Expand Down
2 changes: 1 addition & 1 deletion aizynthfinder/analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
""" Sub-package containing analysis routines
"""
from aizynthfinder.analysis.tree_analysis import TreeAnalysis
from aizynthfinder.analysis.tree_analysis import TreeAnalysis # isort: skip
from aizynthfinder.analysis.routes import RouteCollection
from aizynthfinder.analysis.utils import RouteSelectionArguments
18 changes: 8 additions & 10 deletions aizynthfinder/analysis/routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" Module containing classes to store and manipulate collections of synthetic routes.
"""
from __future__ import annotations

from typing import TYPE_CHECKING

import numpy as np
Expand All @@ -11,24 +12,21 @@
except ImportError:
pass

from aizynthfinder.analysis.utils import (
CombinedReactionTrees,
RouteSelectionArguments,
)
from aizynthfinder.reactiontree import SUPPORT_DISTANCES, ReactionTree
from aizynthfinder.search.mcts import MctsSearchTree, MctsNode
from aizynthfinder.analysis import TreeAnalysis
from aizynthfinder.analysis.utils import CombinedReactionTrees, RouteSelectionArguments
from aizynthfinder.reactiontree import SUPPORT_DISTANCES, ReactionTree
from aizynthfinder.search.mcts import MctsNode, MctsSearchTree

if TYPE_CHECKING:
from aizynthfinder.context.scoring import Scorer
from aizynthfinder.utils.type_utils import (
StrDict,
PilImage,
Optional,
Any,
Dict,
Optional,
PilImage,
Sequence,
StrDict,
)
from aizynthfinder.context.scoring import Scorer


class RouteCollection:
Expand Down
24 changes: 10 additions & 14 deletions aizynthfinder/analysis/tree_analysis.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
""" Module containing classes to perform analysis of the tree search results.
"""
from __future__ import annotations

from collections import defaultdict
from typing import TYPE_CHECKING

from aizynthfinder.chem import (
FixedRetroReaction,
hash_reactions,
)
from aizynthfinder.context.scoring import (
StateScorer,
)
from aizynthfinder.analysis.utils import RouteSelectionArguments
from aizynthfinder.chem import FixedRetroReaction, hash_reactions
from aizynthfinder.context.scoring import StateScorer
from aizynthfinder.reactiontree import ReactionTree
from aizynthfinder.search.mcts import MctsSearchTree, MctsNode
from aizynthfinder.search.andor_trees import AndOrSearchTreeBase
from aizynthfinder.search.mcts import MctsNode, MctsSearchTree

if TYPE_CHECKING:
from aizynthfinder.chem import RetroReaction
from aizynthfinder.context.scoring import Scorer
from aizynthfinder.utils.type_utils import (
StrDict,
Union,
Tuple,
Any,
Iterable,
Sequence,
List,
Sequence,
StrDict,
Tuple,
Union,
)
from aizynthfinder.context.scoring import Scorer
from aizynthfinder.chem import RetroReaction


class TreeAnalysis:
Expand Down
18 changes: 5 additions & 13 deletions aizynthfinder/analysis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,19 @@
To avoid clutter in that package, larger utility algorithms are placed herein.
"""
from __future__ import annotations
from dataclasses import dataclass

from collections import defaultdict
from dataclasses import dataclass
from typing import TYPE_CHECKING

import networkx as nx

from aizynthfinder.chem import (
Molecule,
UniqueMolecule,
FixedRetroReaction,
)
from aizynthfinder.utils.image import make_visjs_page
from aizynthfinder.chem import FixedRetroReaction, Molecule, UniqueMolecule
from aizynthfinder.reactiontree import ReactionTree
from aizynthfinder.utils.image import make_visjs_page

if TYPE_CHECKING:
from aizynthfinder.utils.type_utils import (
Sequence,
Tuple,
StrDict,
FrameColors,
)
from aizynthfinder.utils.type_utils import FrameColors, Sequence, StrDict, Tuple


@dataclass
Expand Down
10 changes: 5 additions & 5 deletions aizynthfinder/chem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
"""
from aizynthfinder.chem.mol import (
Molecule,
MoleculeException,
TreeMolecule,
UniqueMolecule,
MoleculeException,
none_molecule,
)
from aizynthfinder.chem.reaction import (
FixedRetroReaction,
Reaction,
RetroReaction,
TemplatedRetroReaction,
SmilesBasedRetroReaction,
FixedRetroReaction,
TemplatedRetroReaction,
hash_reactions,
)
from aizynthfinder.chem.serialization import (
MoleculeSerializer,
MoleculeDeserializer,
serialize_action,
MoleculeSerializer,
deserialize_action,
serialize_action,
)
10 changes: 5 additions & 5 deletions aizynthfinder/chem/mol.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" Module containing classes to deal with Molecules - mostly wrappers around rdkit routines.
"""
from __future__ import annotations

from typing import TYPE_CHECKING

import numpy as np
Expand All @@ -9,17 +10,16 @@

from aizynthfinder.utils.exceptions import MoleculeException


if TYPE_CHECKING:
from aizynthfinder.utils.type_utils import (
Callable,
Dict,
List,
Optional,
Union,
Tuple,
RdMol,
Sequence,
List,
Callable,
Tuple,
Union,
)


Expand Down
25 changes: 13 additions & 12 deletions aizynthfinder/chem/reaction.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
""" Module containing classes to deal with Reactions.
"""
from __future__ import annotations
import hashlib

import abc
import hashlib
from functools import partial
from typing import TYPE_CHECKING

import numpy as np
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem.rdchem import ChiralType, BondDir, BondStereo
from rdchiral import main as rdc
from rdchiral.bonds import get_atoms_across_double_bonds
from rdchiral.initialization import BondDirOpposite
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem.rdchem import BondDir, BondStereo, ChiralType

from aizynthfinder.chem.mol import Molecule, MoleculeException, TreeMolecule
from aizynthfinder.utils.logging import logger
from aizynthfinder.chem.mol import MoleculeException, Molecule, TreeMolecule

if TYPE_CHECKING:
from aizynthfinder.chem.mol import UniqueMolecule
from aizynthfinder.utils.type_utils import (
Optional,
Union,
Tuple,
Any,
Iterable,
List,
Optional,
RdReaction,
StrDict,
Iterable,
Any,
Set,
StrDict,
Tuple,
Union,
)
from aizynthfinder.chem.mol import UniqueMolecule


class _ReactionInterfaceMixin:
Expand Down
3 changes: 2 additions & 1 deletion aizynthfinder/chem/serialization.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
""" Module containing helper classes and routines for serialization.
"""
from __future__ import annotations

from typing import TYPE_CHECKING

import aizynthfinder.chem
from aizynthfinder.utils.loading import load_dynamic_class

if TYPE_CHECKING:
from aizynthfinder.utils.type_utils import Optional, Sequence, Dict, Any, StrDict
from aizynthfinder.chem import RetroReaction
from aizynthfinder.utils.type_utils import Any, Dict, Optional, Sequence, StrDict


class MoleculeSerializer:
Expand Down

0 comments on commit d30600e

Please sign in to comment.