Export a “flat” PySB model (pysb.export.pysb_flat)

A module containing a class that exports a PySB model to a single Python source file that, when imported, will recreate the same model. This is intended for saving a dynamically generated model so that it can be reused without re-running the dynamic generation process. Note that any macro calls and other program structure in the original model are “flattened” in the process.

For information on how to use the model exporters, see the documentation for pysb.export.

Structure of the Python code

The standalone Python code calls Model(), then defines Monomers, Parameters, Expressions (constant), Compartments, Observables, Expressions (dynamic), Rules and initial conditions in that order. This can be considered a sort of “repr()” for a full model.

If the output is saved as foo.py then one may load the model with the following line:

from foo import model
class pysb.export.pysb_flat.PysbFlatExporter(model, docstring=None)[source]

A class for generating PySB “flat” model source code from a model.

Inherits from pysb.export.Exporter, which implements basic functionality for all exporters.

export()[source]

Export PySB source code from a model.

Returns:
string

String containing the Python code.