Synthesis Module

The synkit.Synthesis package offers tools for both reaction prediction and chemical reaction network (CRN) exploration.

Reaction Prediction: Reactor

The synkit.Synthesis.Reactor submodule supports two backends:

Reactor parameters

Name

Type

Default

Description

invert

bool

False

Use False for forward prediction (substrate → products); True for backward prediction (target → precursors).

explicit_h

bool

False

When True, all hydrogens within the reaction center are rendered explicitly in the resulting SMARTS.

strategy

str

'bt'

Graph-matching strategy to enumerate transformations: - 'comp': component-aware subgraph search (fastest, preferred) - 'all': exhaustive arbitrary subgraph search - 'bt': backtracking fallback (tries comp first, then all if no match)

Example: Forward Prediction

Forward reaction prediction with explicit H and backtracking strategy
 1from synkit.Synthesis.Reactor.syn_reactor import SynReactor
 2
 3input_fw = 'CC=O.CC=O'
 4template = '[C:2]=[O:3].[C:4]([H:7])[H:8]>>[C:2]=[C:4].[O:3]([H:7])[H:8]'
 5
 6reactor = SynReactor(
 7    substrate=input_fw,
 8    template=template,
 9    invert=False,        # forward prediction
10    explicit_h=True,     # show H in reaction center
11    strategy='bt'        # try component search, then exhaustive
12)
13
14smarts_list = reactor.smarts_list
15print(smarts_list)
16# >> ['[CH3:1][CH:2]=[O:3].[CH:4]([CH:5]=[O:6])([H:7])[H:8]>>[CH3:1][CH:2]=[CH:4][CH:5]=[O:6].[O:3]([H:7])[H:8]', '[CH3:4][CH:5]=[O:6].[CH:1]([CH:2]=[O:3])([H:7])[H:8]>>[CH:1]([CH:2]=[O:3])=[CH:5][CH3:4].[O:6]([H:7])[H:8]']

Example: Backward Prediction

Backward reaction prediction targeting product to precursors
 1from synkit.Synthesis.Reactor.syn_reactor import SynReactor
 2
 3target = 'CC=CC=O.O'
 4template = '[C:2]=[O:3].[C:4]([H:7])[H:8]>>[C:2]=[C:4].[O:3]([H:7])[H:8]'
 5
 6reactor_bw = SynReactor(
 7    substrate=target,
 8    template=template,
 9    invert=True,         # backward prediction
10    explicit_h=False,    # hydrogens implicit
11    strategy='comp'      # component-aware search
12)
13
14precursors = reactor_bw.smarts_list
15print(precursors)
16# >> ['[CH3:1][CH:2]=[O:6].[CH3:3][CH:4]=[O:5]>>[CH3:1][CH:2]=[CH:3][CH:4]=[O:5].[OH2:6]', '[CH3:1][CH3:2].[CH:3]([CH:4]=[O:5])=[O:6]>>[CH3:1][CH:2]=[CH:3][CH:4]=[O:5].[OH2:6]']

Example: Implicit Hydrogen (NetworkX)

In some cases you may want to use an implicit-H template. Set implicit_temp=True and explicit_h=False:

Implicit-H template for backward prediction
 1from synkit.Synthesis.Reactor.syn_reactor import SynReactor
 2
 3target = 'CC=CC=O.O'
 4template = '[C:2]=[O:3].[CH2:4]>>[C:2]=[C:4].[OH2:3]'
 5
 6reactor_imp = SynReactor(
 7    substrate=target,
 8    template=template,
 9    invert=True,          # backward prediction
10    explicit_h=False,     # hydrogens implicit
11    strategy='comp',      # component-aware search
12    implicit_temp=True    # use implicit-H template
13)
14
15precursors = reactor_imp.smarts_list
16print(precursors)
17# >> ['[CH3:1][CH:2]=[O:6].[CH3:3][CH:4]=[O:5]>>[CH3:1][CH:2]=[CH:3][CH:4]=[O:5].[OH2:6]', '[CH3:1][CH3:2].[CH:3]([CH:4]=[O:5])=[O:6]>>[CH3:1][CH:2]=[CH:3][CH:4]=[O:5].[OH2:6]']

Example: Forward Prediction (MØD)

Forward prediction (no atom-map reservation)
 1from synkit.Synthesis.Reactor.mod_reactor import MODReactor
 2
 3input_fw = 'CC=O.CC=O'
 4template = '[C:2]=[O:3].[C:4]([H:7])[H:8]>>[C:2]=[C:4].[O:3]([H:7])[H:8]'
 5
 6reactor_mod = MODReactor(
 7    substrate=input_fw,
 8    rule_file=template,
 9    invert=False,         # forward direction
10    strategy='bt'         # component-aware, then exhaustive
11)
12
13reaction_list = reactor_mod.reaction_smiles
14print(reaction_list)
15# >> ['CC=O.CC=O>>CC=CC=O.O']

Example: Backward Prediction with AAM (MØD)

Backward prediction (with atom-map preservation)
 1from synkit.Synthesis.Reactor.mod_reactor import MODReactor
 2from synkit.Synthesis.Reactor.mod_aam      import MODAAM
 3from synkit.IO                            import smart_to_gml
 4
 5input_bw = 'CC=CC=O.O'
 6rule_gml = smart_to_gml(
 7    '[C:2]=[O:3].[C:4]([H:7])[H:8]>>[C:2]=[C:4].[O:3]([H:7])[H:8]',
 8    core=True
 9)
10
11reactor_bw = MODAAM(
12    substrate=input_bw,
13    rule_file=rule_gml,
14    invert=True,
15    strategy='bt'
16)
17
18smarts_list = reactor_bw.get_smarts()
19print(smarts_list)
20# >> [
21#   '[CH3:1][CH:2]=[O:3].[CH:4]([CH:5]=[O:6])([H:7])[H:8]>>[CH3:1][CH:2]=[CH:4][CH:5]=[O:6].[O:3]([H:7])[H:8]',
22#   '[CH3:1][CH:2]([H:3])[H:4].[CH:5]([CH:6]=[O:7])=[O:8]>>[CH3:1][CH:2]=[CH:5][CH:6]=[O:7].[H:3][O:8][H:4]'
23# ]

Chemical Reaction Networks: CRN

The synkit.Synthesis.CRN submodule provides classes for constructing, analyzing, and exploring chemical reaction networks derived from reaction rules.

See Also

  • synkit.IO — format conversion utilities

  • synkit.Graph — graph data structures and transformations