bionetgen.simulator package

Submodules

bionetgen.simulator.bngsimulator module

class bionetgen.simulator.bngsimulator.BNGSimulator(model_file=None, model_str=None)[source]

Bases: object

The generic simulator interface to all BNG simulators.

This is (going to be) designed to allow for a generic API to all other types of simulators so that this API can be used in the rest of the library without specifically writing code for each simulator type.

Attributes

model_filestr

path to the model file this simulator is using

Properties

simulator: obj

the python object that runs the actual simulation. Any subclass implementing a BNGSimulator should set this property and make it so that setting the simulator object to the file path given to initialize the BNGSimulator class initializes the simulator object in turn.

Methods

simulate(args)

Uses the arguments provided to call the underlying simulator

property model_file

model file attribute that stores the path to the original model file and also sets up the simulator

property model_str

model file attribute that stores the path to the original model file and also sets up the simulator

simulate()[source]

bionetgen.simulator.csimulator module

class bionetgen.simulator.csimulator.CSimWrapper(lib_path, num_params=None, num_spec_init=None)[source]

Bases: object

Wrapper class for the compiled C simulator shared library.

The class loads the compiled C shared library and passes pointers to the initial species arrays and parameter arrays to the shared library, runs the simulation and returns the results as numpy named arrays.

set_parameters(arr)[source]

Set the parameter values array

set_species_init(arr)[source]

Set the initial species values array

simulate(t_start=0, t_end=100, n_steps=100)[source]

Run the simulate command of the shared C library.

This function will construct a timepoint array from the given arguments and then pass the timepoints, parameters and initial species to the simulate command. Take the result pointer and convert the pointer back to a result struct and then construct named numpy arrays to return observable and species values over time.

class bionetgen.simulator.csimulator.CSimulator(model_file, generate_network=False)[source]

Bases: BNGSimulator

Object that bridges the BNG model object and the CSimWrapper object.

The point of this object is to deal with the compilation of the shared library and pass the correct parameter and initial species values to the wrapper object.

compile_shared_lib()[source]
simulate(t_start=0, t_end=10, n_steps=10)[source]
property simulator

simulator attribute that stores the instantiated simulator object and also saves the SBML text in the sbml attribute

class bionetgen.simulator.csimulator.RESULT[source]

Bases: Structure

n_observables

Structure/Union member

n_species

Structure/Union member

n_tpts

Structure/Union member

obs_name_len

Structure/Union member

obs_names

Structure/Union member

observables

Structure/Union member

spcs_name_len

Structure/Union member

spcs_names

Structure/Union member

species

Structure/Union member

status

Structure/Union member

bionetgen.simulator.librrsimulator module

class bionetgen.simulator.librrsimulator.libRRSimulator(model_file=None, model_str=None)[source]

Bases: BNGSimulator

libRoadRunner simulator wrapper

Attributes

sbml: str

the SBML used by the underlying libRoadRunner simulator

Properties

simulator: obj

the python object that runs the actual simulation. Any subclass implementing a BNGSimulator should set this property and make it so that setting the simulator object to the file path given to initialize the BNGSimulator class initializes the simulator object in turn.

Methods

simulate(args)

Uses the arguments provided to call the underlying simulator

property sbml

sbml attribute which is just the SBML string with which the libRR instance is instantiated with

simulate(*args, **kwargs)[source]

generic simulate front-end that passes the args and kwargs to the underlying simulator object

property simulator

simulator attribute that stores the instantiated simulator object and also saves the SBML text in the sbml attribute

bionetgen.simulator.simulators module

bionetgen.simulator.simulators.sim_getter(model_file=None, model_str=None, sim_type='libRR')[source]

Convenience function to get a simulator object of a specific type. Allows you to pull a simulator object given a model file path.

Note: This likely needs to be refactored but for now it works.

Parameters

model_filestr, optional

The path to the model file, at the moment only BNGL is expected but this can change in the future.

model_strstr, optional

Instead of the path to the model you can also supply the model string instead.

sim_typestr, optional

The name of the type of simulator object to get. At the moment only libRoadRunner and CPY type simulators are allowed, allowed values are “libRR” and “cpy”.

Returns

BNGSimulator

A simulator object with an API that’s supposed to be agnostic to the underlying simulator it’s running.

Module contents