sbmlsim.combine.mathml

Helper functions for evaluation of MathML expressions.

Using sympy to evaluate the expressions.

Module Contents

Functions

formula_to_astnode(formula)

Parse ASTNode from formula.

astnode_to_formula(astnode)

Write ASTNode as formula.

parse_mathml_str(mathml_str)

Parse MathML string.

parse_formula(formula)

Parse formula to ASTNode.

parse_astnode(astnode)

Parse ASTNode.

expr_from_formula(formula)

Parse sympy expression from given formula string.

evaluate(astnode, variables)

Evaluate the astnode with values.

_get_variables(astnode[, variables])

Add variable names to the variables.

replace_piecewise(formula)

Replace libsedml piecewise with sympy piecewise.

Attributes

logger

expr

sbmlsim.combine.mathml.logger[source]
sbmlsim.combine.mathml.formula_to_astnode(formula)[source]

Parse ASTNode from formula.

Parameters:

formula (str) –

Return type:

libsedml.ASTNode

sbmlsim.combine.mathml.astnode_to_formula(astnode)[source]

Write ASTNode as formula.

Parameters:

astnode (libsedml.ASTNode) –

Return type:

str

sbmlsim.combine.mathml.parse_mathml_str(mathml_str)[source]

Parse MathML string.

Parameters:

mathml_str (str) –

sbmlsim.combine.mathml.parse_formula(formula)[source]

Parse formula to ASTNode.

Parameters:

formula (str) –

Return type:

libsedml.ASTNode

sbmlsim.combine.mathml.parse_astnode(astnode)[source]

Parse ASTNode.

An AST node in libSBML is a recursive tree structure; each node has a type, a pointer to a value, and a list of children nodes. Each ASTNode node may have none, one, two, or more children depending on its type. There are node types to represent numbers (with subtypes to distinguish integer, real, and rational numbers), names (e.g., constants or variables), simple mathematical operators, logical or relational operators and functions.

see also: http://sbml.org/Software/libSBML/docs/python-api/libsedml-math.html

Parameters:
  • mathml

  • astnode (libsedml.ASTNode) –

Returns:

Return type:

Any

sbmlsim.combine.mathml.expr_from_formula(formula)[source]

Parse sympy expression from given formula string.

Parameters:

formula (str) –

sbmlsim.combine.mathml.evaluate(astnode, variables)[source]

Evaluate the astnode with values.

Parameters:
  • astnode (libsedml.ASTNode) –

  • variables (Dict) –

sbmlsim.combine.mathml._get_variables(astnode, variables=None)[source]

Add variable names to the variables.

Parameters:

astnode (libsedml.ASTNode) –

Return type:

Set[str]

sbmlsim.combine.mathml.replace_piecewise(formula)[source]

Replace libsedml piecewise with sympy piecewise.

sbmlsim.combine.mathml.expr[source]