molfoundry.ruleDFS#

molfoundry.ruleDFS(dfs, name=None, labelType=LabelType.String, invert=False, add=True)#

Build a Rule from a RuleDFS line-notation string (L >> R).

Each side is a GraphDFS string; vertices are related across >> by their ids (a shared id with an unchanged label is a context vertex, otherwise a relabeling). Implicit hydrogens are not added on rule sides.

Parameters:
  • dfs (str) – The RuleDFS string, e.g. "[C+]1[C]2[H]3>>[C]1=[C]2.[H+]3".

  • name (str | None) – Human-readable name for the resulting rule, or None.

  • labelType (LabelType) – Pass LabelType.Term when _-prefixed / * labels are term variables.

  • invert (bool) – When True, invert the rule after loading.

  • add (bool) – When True (the default), also register the rule in inputRules.

Returns:

The parsed rule.

Return type:

Rule