aizynthfinder.search.breadth_first package

Submodules

aizynthfinder.search.breadth_first.nodes module

Module containing a classes representation various tree nodes

class aizynthfinder.search.breadth_first.nodes.MoleculeNode(mol, config, parent=None)

Bases: aizynthfinder.search.andor_trees.TreeNodeMixin

An OR node representing a molecule

Variables
  • expandable – if True, this node is part of the frontier

  • mol – the molecule represented by the node

  • in_stock – if True the molecule is in stock and hence should not be expanded

  • parent – the parent of the node

Parameters
  • mol (TreeMolecule) – the molecule to be represented by the node

  • config (Configuration) – the configuration of the search

  • parent (Optional[ReactionNode]) – the parent of the node, optional

Return type

None

classmethod create_root(smiles, config)

Create a root node for a tree using a SMILES.

Parameters
  • smiles (str) – the SMILES representation of the root state

  • config (Configuration) – settings of the tree search algorithm

Returns

the created node

Return type

MoleculeNode

classmethod from_dict(dict_, config, molecules, parent=None)

Create a new node from a dictionary, i.e. deserialization

Parameters
  • dict – the serialized node

  • config (Configuration) – settings of the tree search algorithm

  • molecules (MoleculeDeserializer) – the deserialized molecules

  • parent (Optional[ReactionNode]) – the parent node

  • dict_ (StrDict) –

Returns

a deserialized node

Return type

MoleculeNode

property children: List[ReactionNode]

Gives the reaction children nodes

property prop: StrDict

Dictionary with publicly exposed properties

add_stub(reaction)

Add a stub / sub-tree to this node

Parameters

reaction (RetroReaction) – the reaction creating the stub

Returns

list of all newly added molecular nodes

Return type

Sequence[MoleculeNode]

ancestors()

Return the ancestors of this node

Returns

the ancestors

Return type

set

serialize(molecule_store)

Serialize the node object to a dictionary

Parameters

molecule_store (MoleculeSerializer) – the serialized molecules

Returns

the serialized node

Return type

StrDict

class aizynthfinder.search.breadth_first.nodes.ReactionNode(reaction, parent)

Bases: aizynthfinder.search.andor_trees.TreeNodeMixin

An AND node representing a reaction

Variables
  • parent – the parent of the node

  • reaction – the reaction represented by the node

Parameters
  • cost – the cost of the reaction

  • reaction (RetroReaction) – the reaction to be represented by the node

  • parent (MoleculeNode) – the parent of the node

Return type

None

classmethod create_stub(reaction, parent, config)

Create a ReactionNode and creates all the MoleculeNode objects that are the children of the node.

Parameters
Return type

ReactionNode

classmethod from_dict(dict_, config, molecules, parent)

Create a new node from a dictionary, i.e. deserialization

Parameters
Returns

a deserialized node

Return type

ReactionNode

property children: List[MoleculeNode]

Gives the molecule children nodes

property prop: StrDict

Dictionary with publicly exposed properties

serialize(molecule_store)

Serialize the node object to a dictionary

Parameters

molecule_store (MoleculeSerializer) – the serialized molecules

Returns

the serialized node

Return type

StrDict

aizynthfinder.search.breadth_first.search_tree module

Module containing a class that holds the tree search

class aizynthfinder.search.breadth_first.search_tree.SearchTree(config, root_smiles=None)

Bases: aizynthfinder.search.andor_trees.AndOrSearchTreeBase

Encapsulation of the a breadth-first exhaustive search algorithm

Variables
  • config – settings of the tree search algorithm

  • root – the root node

Parameters
  • config (Configuration) – settings of the tree search algorithm

  • root_smiles (Optional[str]) – the root will be set to a node representing this molecule, defaults to None

Return type

None

classmethod from_json(filename, config)

Create a new search tree by deserialization from a JSON file

Parameters
  • filename (str) – the path to the JSON node

  • config (Configuration) – the configuration of the search tree

Returns

a deserialized tree

Return type

SearchTree

property mol_nodes: Sequence[MoleculeNode]

Return the molecule nodes of the tree

one_iteration()

Perform one iteration expansion. Expands all expandable molecule nodes in the tree, which should be on the same depth of the tree.

Raises

StopIteration – if the search should be pre-maturely terminated

Returns

if a solution was found

Return type

bool

routes()

Extracts and returns routes from the AND/OR tree

Returns

the routes

Return type

List[ReactionTree]

serialize(filename)

Seralize the search tree to a JSON file

Parameters

filename (str) – the path to the JSON file

Return type

None

Module contents

Sub-package containing breadth first routines