10.2. Rule Composition¶
10.2.1. Unary Operators¶
Special rules can be constructed from graphs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | include("0050_formoseGrammar.py")
glycolaldehyde.print()
# A graph G can be used to construct special rules:
# (\emptyset <- \emptyset -> G)
bindExp = rcBind(glycolaldehyde)
# (G <- \emptyset -> \emptyset)
unbindExp = rcUnbind(glycolaldehyde)
# (G <- G -> G)
idExp = rcId(glycolaldehyde)
# These are really rule composition expressions that have to be evaluated:
rc = rcEvaluator(inputRules)
# Each expression results in a lists of rules:
bindRules = rc.eval(bindExp)
unbindRules = rc.eval(unbindExp)
idRules = rc.eval(idExp)
postSection("Bind Rules")
for p in bindRules:
p.print()
postSection("Unbind Rules")
for p in unbindRules:
p.print()
postSection("Id Rules")
for p in idRules:
p.print()
|
10.2.2. Parallel Composition¶
A pair of rules can be merged to a new rule implementing the parallel transformation.
1 2 3 4 5 6 7 | include("0050_formoseGrammar.py")
rc = rcEvaluator(inputRules)
# The special global object 'rcParallel' is used to make a pseudo-operator:
exp = rcId(formaldehyde) *rcParallel* rcUnbind(glycolaldehyde)
rules = rc.eval(exp)
for p in rules:
p.print()
|
10.2.3. Supergraph Composition¶
A pair of rules can (maybe) be composed using a sueprgraph relation.
1 2 3 4 5 6 7 | include("0050_formoseGrammar.py")
rc = rcEvaluator(inputRules)
exp = rcId(formaldehyde) *rcParallel* rcId(glycolaldehyde)
exp = exp *rcSuper* ketoEnol_F
rules = rc.eval(exp)
for p in rules:
p.print()
|
10.2.4. Overall Formose Reaction¶
A complete pathway can be composed to obtain the overall rules.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | include("0050_formoseGrammar.py")
rc = rcEvaluator(inputRules)
exp = (
rcId(glycolaldehyde)
*rcSuper* ketoEnol_F
*rcParallel* rcId(formaldehyde)
*rcSuper(allowPartial=False)* aldolAdd_F
*rcSuper* ketoEnol_F
*rcParallel* rcId(formaldehyde)
*rcSuper(allowPartial=False)* aldolAdd_F
*rcSuper* ketoEnol_F
*rcSuper* ketoEnol_B
*rcSuper* aldolAdd_B
*rcSuper* ketoEnol_B
*rcSuper(allowPartial=False)*
(rcId(glycolaldehyde) *rcParallel* rcId(glycolaldehyde))
)
rules = rc.eval(exp)
for p in rules:
p.print()
|