Synthesis#

Synthesis engines, multi-step search, benchmarking, and ranking utilities.

Reactor#

class synkit.Synthesis.Reactor.batch_reactor.BatchReactor(data: List[str | Dict[str, Any]], host_key: str | None = None, *, react_engine: str = 'syn', pre_filter_engine: str | None = None, explicit_h: bool = True, implicit_temp: bool = False, strategy: str = 'bt', dedupe: bool = True, entry_n_jobs: int = 1, rule_n_jobs: int = 1, parallel_rules: bool = False, allow_nested: bool = False, cache_enabled: bool = True, cache_maxsize: int = 32768, logger: Logger | None = None, enable_logging: bool = True)[source]#

Bases: object

describe() str[source]#
fit(rules: Iterable[Any], *, invert: bool = False) List[Dict[str, Any]][source]#
help() str[source]#
class synkit.Synthesis.Reactor.benchmark.Benchmark(data: List[Dict[str, Any]], reaction_key: str = 'reactions', *, react_engine: str = 'syn', pre_filter_engine: str | None = None, explicit_h: bool = True, implicit_temp: bool = False, strategy: str = 'bt', dedupe: bool = True, entry_n_jobs: int = 1, rule_n_jobs: int = 1, parallel_rules: bool = False, allow_nested: bool = False, cache_enabled: bool = True, cache_maxsize: int = 32768, logger: Logger | None = None, enable_logging: bool = True)[source]#

Bases: BatchReactor

describe() str[source]#
fit(rules: Iterable[Any]) List[Dict[str, Any]][source]#
class synkit.Synthesis.Reactor.imba_engine.ImbaEngine(substrate: str | Graph | SynGraph, template: str | Graph | SynRule, add_wildcard: bool = True, clean_fragments: bool = False, max_frag: bool = False, invert: bool = False, canonicaliser: GraphCanonicaliser | None = None, strategy: Strategy | str = Strategy.ALL, partial: bool = False, embed_threshold: float = None, embed_pre_filter: bool = False, electron_diagnostics: bool = False)[source]#

Bases: object

static describe() None[source]#
property diagnostics: list[dict]#
fit() ImbaEngine[source]#
property smarts_list: List[str]#
to_list() List[str][source]#
class synkit.Synthesis.Reactor.mod_aam.MODAAM(substrate: str | List[str], rule_file: str | Path, *, invert: bool = False, strategy: str | Strategy = Strategy.BACKTRACK, verbosity: int = 0, print_results: bool = False, check_isomorphic: bool = True)[source]#

Bases: object

property dg: Any#
get_reaction_smiles() List[str][source]#
get_smarts() List[str][source]#
help() None[source]#
property product_count: int#
property reaction_smiles: List[str]#
run() List[str][source]#
synkit.Synthesis.Reactor.mod_aam.expand_aam(rsmi: str, rule: str) List[str][source]#
class synkit.Synthesis.Reactor.mod_reactor.MODReactor(substrate: str | List[str], rule_file: str | Path, *, invert: bool = False, strategy: str | Strategy = Strategy.BACKTRACK, verbosity: int = 0, print_results: bool = False)[source]#

Bases: object

property dg: None#
static generate_reaction_smiles(temp_results: List[List[str]], base_smiles: str, *, invert: bool = False, arrow: str = '>>', separator: str = '.') List[str][source]#
get_dg() None[source]#
get_reaction_smiles() List[str][source]#
help() None[source]#
property prediction_count: int#
property product_sets: List[List[str]]#
property product_smiles: List[str]#
property reaction_smiles: List[str]#
run() MODReactor[source]#
property temp_results: List[List[str]]#
class synkit.Synthesis.Reactor.partial_engine.PartialEngine(smi: str, template: str, electron_diagnostics: bool = False)[source]#

Bases: object

property diagnostics: list[dict]#
fit(invert: bool = False) list[str][source]#
class synkit.Synthesis.Reactor.post_syn.PostSyn(n_jobs: int = 1, verbose: int = 2, standardizer: Standardize | None = None, reaction_key: str = 'reactions', fw_key: str = 'fw', bw_key: str = 'bw')[source]#

Bases: object

clean_aam(list_aam: Iterable[str], remove_radical: bool = True) List[str][source]#
process(data: Iterable[Dict[str, Any]], *, progress: bool = False, prefilter: Callable[[Dict[str, Any]], bool] | None = None, filter_incomplete_rxn: bool = True) List[Dict[str, Any]][source]#
class synkit.Synthesis.Reactor.rbl_engine.RBLEngine(*, wildcard_element: ~typing.Any = ('*', '*'), element_key: str = 'element', node_attrs: ~typing.Sequence[str] | None = None, edge_attrs: ~typing.Sequence[str] | None = None, prune_wc: bool = True, prune_automorphisms: bool = True, mcs_side: str = 'l', early_stop: bool = True, fast_paths_only: bool = False, mode: str | None = None, max_mappings_per_pair: int = 1, implicit_temp: bool = True, explicit_h: bool = False, electron_diagnostics: bool = False, embed_threshold: int = 10000, reactor_cls: type = <class 'synkit.Synthesis.Reactor.syn_reactor.SynReactor'>, wildcard_adder_cls: type = <class 'synkit.Chem.Reaction.radical_wildcard.RadicalWildcardAdder'>, matcher_cls: type = <class 'synkit.Graph.Matcher.mcs_matcher.MCSMatcher'>, fuse_fn: ~typing.Callable[[~typing.Any, ~typing.Any, ~typing.Dict[~typing.Any, ~typing.Any]], ~typing.Any] = <function fuse_its_graphs>, remove_explicit_H_fn: ~typing.Callable[[str], str] = <function remove_explicit_H_from_rsmi>, rsmi_to_its_fn: ~typing.Callable[[...], ~typing.Any] = <function rsmi_to_its>, its_to_rsmi_fn: ~typing.Callable[[~typing.Any], str] = <function its_to_rsmi>, h_to_implicit_fn: ~typing.Callable[[~typing.Any], ~typing.Any] = <function h_to_implicit>, standardize_h_fn: ~typing.Callable[[~typing.Any], ~typing.Any] = <function standardize_hydrogen>, standardize_fn: ~typing.Callable[[str], str] | None = <bound method Standardize.fit of <synkit.Chem.Reaction.standardize.Standardize object>>, logger: ~logging.Logger | None = None)[source]#

Bases: object

property backward_its: List[Any]#
property diagnostics: Dict[str, List[Dict[str, Any]]]#
property forward_its: List[Any]#
property fused_its: List[Any]#
property fused_rsmis: List[str]#
help() str[source]#
property last_reaction: str | None#
prepare_template(template: str | Graph | Any) RBLEngine[source]#
process(rsmi: str, template: str | Graph | Any, *, replace_wc: bool = True, fast_paths_only: bool | None = None) RBLEngine[source]#
react(substrate: str | Any, pattern: Any | None = None, invert: bool = False) RBLEngine[source]#
replace_wildcard_with_H(G: Graph) Graph[source]#
property result: Dict[str, Any]#
property template_its: Any | None#
class synkit.Synthesis.Reactor.rule_filter.RuleFilter(host_graph: Graph, rules_list: List[Any], invert: bool = False, engine: str = 'turbo', node_label: str | List[str] = ['element', 'charge'], edge_label: str | List[str] = 'order', distance_threshold: int = 5000, sing_max_path: int = 3)[source]#

Bases: object

property engine: str#
property host: Graph#
property matches: List[bool]#
property new_rules: List[Any]#
property patterns: List[Graph]#
property rules: List[Any]#
class synkit.Synthesis.Reactor.single_predictor.SinglePredictor[source]#

Bases: object

class synkit.Synthesis.Reactor.strategy.Strategy(value)[source]#

Bases: str, Enum

ALL = 'all'#
BACKTRACK = 'bt'#
COMPONENT = 'comp'#
PARTIAL = 'partial'#
classmethod from_string(value: str | Strategy) Strategy[source]#
class synkit.Synthesis.Reactor.syn_reactor.SynReactor(substrate: str | Graph | SynGraph, template: str | Graph | SynRule, invert: bool = False, canonicaliser: GraphCanonicaliser | None = None, explicit_h: bool = True, implicit_temp: bool = False, strategy: Strategy | str = Strategy.ALL, partial: bool = False, template_format: Literal['typesGH', 'tuple'] = 'typesGH', electron_diagnostics: bool = False, embed_threshold: int | None = None, embed_pre_filter: bool = False, automorphism: bool = True)[source]#

Bases: object

automorphism: bool = True#
canonicaliser: GraphCanonicaliser | None = None#
property diagnostics: List[Dict[str, Any]]#
electron_diagnostics: bool = False#
embed_pre_filter: bool = False#
embed_threshold: int | None = None#
explicit_h: bool = True#
classmethod from_smiles(smiles: str, template: str | Graph | SynRule, *, invert: bool = False, canonicaliser: GraphCanonicaliser | None = None, explicit_h: bool = True, implicit_temp: bool = False, automorphism: bool = False, strategy: Strategy | str = Strategy.ALL, template_format: Literal['typesGH', 'tuple'] = 'typesGH', electron_diagnostics: bool = False) SynReactor[source]#
property graph: SynGraph#
help(print_results=False) None[source]#
implicit_temp: bool = False#
invert: bool = False#
property its#
property its_list: List[Graph]#
property mapping_count#
property mappings: List[Dict[Any, Any]]#
partial: bool = False#
property rule: SynRule#
property smarts#
property smarts_list: List[str]#
property smiles_list#
strategy: Strategy | str = 'all'#
substrate: str | Graph | SynGraph#
property substrate_smiles#
template: str | Graph | SynRule#
template_format: Literal['typesGH', 'tuple'] = 'typesGH'#

Multi-step search#

class synkit.Synthesis.MSR.multi_steps.MultiSteps[source]#

Bases: object

multi_step(original_rsmi: str, list_rule: List[str], order: List[int], cat: str | List[str]) List[str][source]#
class synkit.Synthesis.MSR.path_finder.PathFinder(reaction_rounds: List[Dict[str, List[str]]])[source]#

Bases: object

search_paths(input_smiles: str, target_smiles: str, method: str = 'bfs', max_solutions: int | None = None, cheapest: bool = True) List[List[str]][source]#

Metrics#

synkit.Synthesis.Metrics._plot.plot_f2_scores_line(data, figsize=(8, 6), show_f2=True, show_legend=True)[source]#
synkit.Synthesis.Metrics._plot.plot_recognition_coverage_curve(data, coverage_col='Coverage', recognition_col='Recognition', f2_score_col='F2_score', figsize=(8, 6), show_f2=True, show_legend=True)[source]#

Utilities#