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