10.2. Rule Composition

10.2.1. Unary Operators

Special rules can be constructed from graphs.

Explore in the playground.

 1include("0050_formoseGrammar.py")
 2glycolaldehyde.print()
 3# A graph G can be used to construct special rules:
 4# (\emptyset <- \emptyset -> G)
 5bindExp = rcBind(glycolaldehyde)
 6# (G <- \emptyset -> \emptyset)
 7unbindExp = rcUnbind(glycolaldehyde)
 8# (G <- G -> G)
 9idExp = rcId(glycolaldehyde)
10# These are really rule composition expressions that have to be evaluated:
11rc = rcEvaluator(inputRules)
12# Each expression results in a lists of rules:
13bindRules = rc.eval(bindExp)
14unbindRules = rc.eval(unbindExp)
15idRules = rc.eval(idExp)
16postSection("Bind Rules")
17for p in bindRules:
18   p.print()
19postSection("Unbind Rules")
20for p in unbindRules:
21   p.print()
22postSection("Id Rules")
23for p in idRules:
24   p.print()

10.2.2. Parallel Composition

A pair of rules can be merged to a new rule implementing the parallel transformation.

Explore in the playground.

1include("0050_formoseGrammar.py")
2rc = rcEvaluator(inputRules)
3# The special global object 'rcParallel' is used to make a pseudo-operator:
4exp = rcId(formaldehyde) *rcParallel*  rcUnbind(glycolaldehyde)
5rules = rc.eval(exp)
6for p in rules:
7   p.print()

10.2.3. Supergraph Composition

A pair of rules can (maybe) be composed using a sueprgraph relation.

Explore in the playground.

1include("0050_formoseGrammar.py")
2rc = rcEvaluator(inputRules)
3exp = rcId(formaldehyde) *rcParallel*  rcId(glycolaldehyde)
4exp = exp *rcSuper* ketoEnol_F
5rules = rc.eval(exp)
6for p in rules:
7   p.print()

10.2.4. Overall Formose Reaction

A complete pathway can be composed to obtain the overall rules.

Explore in the playground.

 1include("0050_formoseGrammar.py")
 2rc = rcEvaluator(inputRules)
 3exp = (
 4   rcId(glycolaldehyde)
 5   *rcSuper* ketoEnol_F
 6   *rcParallel* rcId(formaldehyde)
 7   *rcSuper(allowPartial=False)* aldolAdd_F
 8   *rcSuper* ketoEnol_F
 9   *rcParallel* rcId(formaldehyde)
10   *rcSuper(allowPartial=False)* aldolAdd_F
11   *rcSuper* ketoEnol_F
12   *rcSuper* ketoEnol_B
13   *rcSuper* aldolAdd_B
14   *rcSuper* ketoEnol_B
15   *rcSuper(allowPartial=False)*
16   (rcId(glycolaldehyde) *rcParallel* rcId(glycolaldehyde))
17)
18rules = rc.eval(exp)
19for p in rules:
20   p.print()