Rules for Rules - siegfriedzoetzsche/grprak GitHub Wiki

What should our rules look like?

Hydrogens attached to Carbon atoms

are explicitly listed, so inlcude them in your context, e.g.

rule[
...
    context[
        node[id 0 label "C"]
        node[id 1 label "H"]
        node[id 2 label "H"]
        node[id 3 label "H"]
        edge[source 0 target 1 "-"]
        edge[source 0 target 2 "-"]
        edge[source 0 target 3 "-"]
    ]
...
]

for a methyl group (-CH3)

Use wildcards

In the followin example the wildcards “_R1”, “_R2”, “_R3”, “_R4”.

aldolreaction_acidic = ruleGMLString("""
rule[
	ruleID "aldolreaction_acidic" 
	left[
                ...
	]
	context[
		node[id 1 label "_R1"]
		node[id 2 label "C"]
		node[id 3 label "C"]
		node[id 4 label "_R2"]	
		node[id 5 label "O"]
		edge[source 1 target 2 label "-"]
		edge[source 2 target 3 label "-"]
		edge[source 3 target 4 label "-"]
		node[id 11 label "H"]
		node[id 12 label "H"]
		edge[source 2 target 11 label "-"]
		edge[source 2 target 12 label "-"]

		# unmodified part of Aldehyd / Keton 2
		node[id 6 label "_R3"]
		node[id 7 label "C"]
		node[id 8 label "C"]
		node[id 9 label "_R4"]	
		node[id 10 label "O"]
		edge[source 6 target 7 label "-"]
		edge[source 7 target 8 label "-"]
		edge[source 8 target 9 label "-"]
		edge[source 8 target 10 label "="]
		node[id 13 label "H"]
		node[id 14 label "H"]
		edge[source 7 target 13 label "-"]
	]
	right[
                ...
	]
]
""")
⚠️ **GitHub.com Fallback** ⚠️