sbmlutils.converters.odefac

Convert SBML models to ODE systems for various programming languages.

This allows easy integration with existing workflows by rendering respective code templates.

Currently supported code generation: - python: scipy - R: desolve - R: dmod

The following SBML core constructs are currently NOT supported: - ConversionFactors - FunctionDefinitions - InitialAssignments - Events

Module Contents

Classes

SBML2ODE

SBML to ODE converter.

Attributes

logger

TEMPLATE_DIR

sbmlutils.converters.odefac.logger[source]
sbmlutils.converters.odefac.TEMPLATE_DIR[source]
class sbmlutils.converters.odefac.SBML2ODE(doc)[source]

SBML to ODE converter.

Writes out python or R ODE files which can be solved with standard integrators like scipy odeint or R desolve.

Parameters:

doc (libsbml.SBMLDocument) –

info()[source]

Print information on ODE system to console.

Return type:

None

classmethod from_file(sbml_file)[source]

Create converter from SBML file.

Parameters:

sbml_file (pathlib.Path) –

Return type:

SBML2ODE

_create_odes()[source]

Create information of ODE system from SBMLDocument.

Return type:

None

_add_reaction_formula(model, rid, species_ref, sign)[source]

Add part of reaction formula to ODEs for species.

Parameters:
  • model (libsbml.Model) –

  • rid (str) –

  • species_ref (libsbml.SpeciesReference) –

  • sign (str) –

Return type:

None

static dependency_graph(y, filtered_ids)[source]

Create dependency graph from given dictionary.

Parameters:
  • y (Dict[str, Union[libsbml.ASTNode, str]]) – { variable: astnode } dictionary

  • filtered_ids (Set[str]) – ids which are defined elsewhere and not part of dependency tree

Returns:

Return type:

Dict[str, Set]

_ordered_yids()[source]

Get the order of the vids from the assignment rules.

Parameters:

model

Return type:

List[str]

:param filtered_ids :return:

to_python(py_file)[source]

Write ODEs to python.

Parameters:

py_file (pathlib.Path) –

Return type:

None

to_R(r_file)[source]

Write ODEs to R.

Parameters:

r_file (pathlib.Path) –

Return type:

None

to_markdown(md_file)[source]

Write ODEs to markdown.

Parameters:

md_file (pathlib.Path) –

Return type:

None

_render_template(template_file='odefac_template.pytemp', index_offset=0, replace_symbols=True)[source]

Render given language template.

Returns:

rendered template string.

Parameters:
  • template_file (str) –

  • index_offset (int) –

  • replace_symbols (bool) –

Return type:

str

_indices(index_offset=0)[source]

Get indices of pids, yids and dxids.

Parameters:

index_offset (int) –

Return type:

Tuple[Dict[str, int], Dict[str, int], Dict[str, int]]