amici.sbml_utils
SBML Utilities
This module provides helper functions for working with SBML.
Functions
|
Helper for adding an assignment rule to a SBML model. |
|
Helper for adding a compartment to a SBML model. |
|
|
|
Helper for adding a parameter to a SBML model. |
|
Helper for adding a rate rule to a SBML model. |
|
Helper for adding a species to a SBML model. |
|
Helper for creating an empty SBML model. |
|
Try to get the units for expression x. |
|
|
|
Prettifies an XML document (given as a string). |
|
Convert a SymPy expression to SBML math AST. |
|
Prints a SymPy expression to a MathML expression parsable by libSBML. |
|
Set the math attribute of a SBML node using a SymPy expression. |
Classes
|
Prints a SymPy expression to a MathML expression parsable by libSBML. |
Exceptions
- class amici.sbml_utils.MathMLSbmlPrinter(settings=None)[source]
Prints a SymPy expression to a MathML expression parsable by libSBML.
Differences from sympy.MathMLContentPrinter: 1. underscores in symbol names are not converted to subscripts 2. symbols with name ‘time’ are converted to the SBML time symbol
- __init__(settings=None)
- emptyPrinter(expr)
- mathml_tag(e)
Returns the MathML tag for an expression.
- property order
- classmethod set_global_settings(**settings)
Set system-wide printing settings.
- amici.sbml_utils.add_assignment_rule(model, variable_id, formula, rule_id=None)[source]
Helper for adding an assignment rule to a SBML model.
- Parameters:
model (
libsbml.Model
) – SBML model to which the assignment rule is to be added.variable_id (
str
|sympy.core.symbol.Symbol
) – SBML ID of the quantity for which the assignment rule is to be added.formula – Formula for the assignment rule (it will be sympified).
rule_id (
str
|None
) – SBML ID of the new assignment rule. Defaults to ‘assignment_’ + variableId.
- Return type:
libsbml.AssignmentRule
- Returns:
The assignment rule as a
libsbml.AssignmentRule
object.
- amici.sbml_utils.add_compartment(model, compartment_id, *, size=1.0)[source]
Helper for adding a compartment to a SBML model.
- Parameters:
model (
libsbml.Model
) – SBML model to which the compartment is to be added.compartment_id (
str
|sympy.core.symbol.Symbol
) – SBML ID of the new compartment.size (
float
) – Size of the new compartment. Defaults to 1.0.
- Return type:
libsbml.Species
- Returns:
The new compartment as a
libsbml.Compartment
object.
- amici.sbml_utils.add_inflow(model, species_id, rate, *, reaction_id=None, reversible=False)[source]
- Return type:
libsbml.Reaction
- amici.sbml_utils.add_parameter(model, parameter_id, *, name=False, value=None, units=None, constant=None)[source]
Helper for adding a parameter to a SBML model.
- Parameters:
- Return type:
libsbml.Parameter
- Returns:
The new parameter as a
libsbml.Parameter
object.
- amici.sbml_utils.add_rate_rule(model, variable_id, formula, rule_id=None)[source]
Helper for adding a rate rule to a SBML model.
- Parameters:
model (
libsbml.Model
) – SBML model to which the rate rule is to be added.variable_id (
str
|sympy.core.symbol.Symbol
) – SBML ID of the quantity for which the rate rule is to be added.formula – Formula for the rate rule (it will be sympified).
rule_id (
str
|None
) – SBML ID of the new rate rule. Defaults to ‘rate_’ + variableId.
- Return type:
libsbml.RateRule
- Returns:
The new rate rule as a
libsbml.RateRule
object.
- amici.sbml_utils.add_species(model, species_id, *, compartment_id=None, name=False, initial_amount=0.0, units=None)[source]
Helper for adding a species to a SBML model.
- Parameters:
model (
libsbml.Model
) – SBML model to which the species is to be added.species_id (
str
|sympy.core.symbol.Symbol
) – SBML ID of the new species.compartment_id (
str
|None
) – Compartment ID for the new species. If there is only one compartment it can be auto-selected.initial_amount (
float
) – Initial amount of the new species.
- Return type:
libsbml.Species
- Returns:
The new species as a
libsbml.Species
object.
- amici.sbml_utils.create_sbml_model(model_id, level=2, version=5)[source]
Helper for creating an empty SBML model.
- amici.sbml_utils.get_sbml_units(model, x)[source]
Try to get the units for expression x.
- Parameters:
model (
libsbml.Model
) – SBML model.x (
str
|sympy.core.symbol.Symbol
|sympy.core.basic.Basic
) – Expression to get the units of.
- Return type:
- Returns:
A string if the units could be determined, otherwise None.
- amici.sbml_utils.mathml2sympy(mathml, *, evaluate=False, locals=None, expression_type='mathml2sympy')[source]
- Return type:
- amici.sbml_utils.pretty_xml(ugly_xml)[source]
Prettifies an XML document (given as a string).
- Return type:
- amici.sbml_utils.sbml_math_ast(expr, **kwargs)[source]
Convert a SymPy expression to SBML math AST.
- Parameters:
expr – expression to be converted (will be sympified).
kwargs – extra options for MathML conversion.
- Return type:
libsbml.ASTNode
- amici.sbml_utils.sbml_mathml(expr, *, replace_time=False, pretty=False, **settings)[source]
Prints a SymPy expression to a MathML expression parsable by libSBML.
- amici.sbml_utils.set_sbml_math(obj, expr, **kwargs)[source]
Set the math attribute of a SBML node using a SymPy expression.
- Parameters:
obj (
libsbml.SBase
) – SBML node supporting setMath method.expr – expression to which the math attribute of obj should be se to (will be sympified).
kwargs – extra options for MathML conversion.
- Return type: