Formula Parser

Parses formula strings (lavaan-style DSL) into ArchNode objects for constructing phenogenetic architectures. See the Formula DSL Reference guide for the full DSL reference.

Formula parser for xftsim architecture DSL.

Parses formula strings into a list of ArchNode objects.

Grammar: - LHS ~ function(args) e.g. height.G ~ genetic(eff) - LHS ~ function(args) | GROUPING e.g. height.E ~ noise(0.3) | FID - LHS ~ arithmetic_expression e.g. height ~ height.G + height.E - (a, b) ~ mvGenetic(eff) tuple LHS for multi-output - (a, b) ~ cnoise(cov=[[1,0.2],[0.2,1]]) multivariate correlated noise - Functions: genetic, mvGenetic, noise, cnoise, parent, mother, father

xftsim.parser.parse_formula(formula, effects=None)[source]

Parse a formula string into a list of ArchNode objects.

Parameters:
  • formula (str) – Multi-line formula string. Each line is one statement: LHS ~ RHS. Lines starting with # are comments. Empty lines are skipped.

  • effects (dict, optional) – Name → EffectSpec mapping for resolving effect references.

Return type:

list[ArchNode]

Returns:

list[ArchNode] – Parsed nodes in declaration order.

Raises:

ValueError – On parse errors (unknown function, missing effect, etc.).

Parameters: