gillespy package

Submodules

gillespy.SBMLimport module

gillespy.gillespy module

Code based off StochSS internal interface to StochKit, originally by A. Hellander. Stand-alone GillesPy module work by J. Abel and B. Drawert.

Version 1.0 on github as of 8-7-2015.

class gillespy.gillespy.GillesPySolver[source]

abstract class for simulation methods

classmethod run(model, t=20, number_of_trajectories=10, increment=0.05, seed=None, stochkit_home=None, algorithm=None, job_id=None)[source]

Call out and run the solver. Collect the results.

exception gillespy.gillespy.InvalidStochMLError[source]

Bases: exceptions.Exception

class gillespy.gillespy.Model(name='', volume=1.0)[source]

Bases: object

Representation of a well mixed biochemical model. Contains reactions, parameters, species, etc.

add_parameter(params)[source]

Add Paramter(s) to listOfParamters. Input can be either a single paramter object or a list of Parameters.

add_reaction(reacs)[source]

Add reactions to model. Input can be single instance, a list of instances or a dict with name,instance pairs.

add_species(obj)[source]

Add a species to listOfSpecies. Accepts input either as a single Species object, or as a list of Species objects.

delete_all_parameters()[source]
delete_all_reactions()[source]
delete_all_species()[source]
delete_parameter(obj)[source]
delete_reaction(obj)[source]
delete_species(obj)[source]
get_all_parameters()[source]
get_all_reactions()[source]
get_all_species()[source]
get_parameter(pname)[source]
get_reaction(rname)[source]
get_species(sname)[source]
resolve_parameters()[source]

Attempt to resolve all parameter expressions to scalar floats. This methods must be called before exporting the model.

serialize()[source]

Serializes a Model object to valid StochML.

set_parameter(pname, expression)[source]

Set the expression of an existing paramter.

set_units(units)[source]
update_namespace()[source]

Create a dict with flattened parameter and species objects.

exception gillespy.gillespy.ModelError[source]

Bases: exceptions.Exception

class gillespy.gillespy.Parameter(name='', expression=None, value=None)[source]

A parameter can be given as an expression (function) or directly as a value (scalar). If given an expression, it should be understood as evaluable in the namespace of a parent Model.

evaluate(namespace={})[source]

Evaluate the expression and return the (scalar) value

set_expression(expression)[source]
exception gillespy.gillespy.ParameterError[source]

Bases: gillespy.gillespy.ModelError

class gillespy.gillespy.Reaction(name='', reactants={}, products={}, propensity_function=None, massaction=False, rate=None, annotation=None)[source]

Models a single reaction. A reaction has its own dictinaries of species (reactants and products) and parameters. The reaction’s propensity function needs to be evaluable (and result in a non-negative scalar value) in the namespace defined by the union of those dicts.

Annotate(annotation)[source]
addProduct(S, stoichiometry)[source]
addReactant(S, stoichiometry)[source]
create_mass_action()[source]

Create a mass action propensity function given self.reactants and a single parameter value.

setType(type)[source]
exception gillespy.gillespy.ReactionError[source]

Bases: gillespy.gillespy.ModelError

exception gillespy.gillespy.SimuliationError[source]

Bases: exceptions.Exception

class gillespy.gillespy.Species(name='', initial_value=0)[source]

Chemical species.

exception gillespy.gillespy.SpeciesError[source]

Bases: gillespy.gillespy.ModelError

class gillespy.gillespy.StochKitEnsemble(id=None, trajectories=None, parentmodel=None)[source]

A stochKit ensemble is a collection of StochKitTrajectories, all sharing a common set of metadata (generated from the same model instance).

add_trajectory(trajectory)[source]
dump(filename, type='mat')[source]

Serialize to a binary data file in a matrix format. Supported formats are HDF5 (requires h5py), .MAT (for Matlab V. <= 7.2, requires SciPy). Matlab V > 7.3 uses HDF5 as it’s base format for .mat files.

class gillespy.gillespy.StochKitODESolver[source]

Bases: gillespy.gillespy.GillesPySolver

Solver class to simulate Stochasticly with StockKit.

classmethod run(model, t=20, number_of_trajectories=10, increment=0.05, seed=None, stochkit_home=None, algorithm='stochkit_ode.py', job_id=None)[source]
class gillespy.gillespy.StochKitOutputCollection(collection=[])[source]

A collection of StochKit Ensembles, not necessarily generated from a common model instance (i.e. they do not necessarly have the same metadata). This datastructure can be useful to store e.g. data from parameter sweeps, or simply an ensemble of ensembles.

AH: Something like a PyTables object would be very useful here, if working in a Python environment.

add_ensemble(ensemble)[source]
class gillespy.gillespy.StochKitSolver[source]

Bases: gillespy.gillespy.GillesPySolver

Solver class to simulate Stochasticly with StockKit.

classmethod run(model, t=20, number_of_trajectories=10, increment=0.05, seed=None, stochkit_home=None, algorithm='ssa', job_id=None)[source]
class gillespy.gillespy.StochKitTrajectory(data=None, id=None)[source]

A StochKitTrajectory is a numpy ndarray. The first column is the time points in the timeseries, followed by species copy numbers.

class gillespy.gillespy.StochMLDocument[source]

Serializiation and deserialization of a Model to/from the native StochKit2 XML format.

classmethod from_file(filepath)[source]

Intializes the document from an exisiting native StochKit XML file read from disk.

classmethod from_model(model)[source]

Creates an StochKit XML document from an exisiting Mdoel object. This method assumes that all the parameters in the model are already resolved to scalar floats (see Model.resolveParamters).

Note, this method is intended to be used interanally by the models ‘serialization’ function, which performs additional operations and tests on the model prior to writing out the XML file. You should NOT do

document = StochMLDocument.fromModel(model) print document.toString()

you SHOULD do

print model.serialize()

classmethod from_string(string)[source]

Intializes the document from an exisiting native StochKit XML file read from disk.

parameter_to_element(P)[source]
reaction_to_element(R)[source]
species_to_element(S)[source]
to_model(name)[source]

Instantiates a Model object from a StochMLDocument.

to_string()[source]

Returns the document as a string.

exception gillespy.gillespy.StochMLImportError[source]

Bases: exceptions.Exception

Module contents