StochPy Module documentation
Stochastic Simulation Module
The main module of StochPy
TODO: ininstance for s_id en r_id types in rates2plot and species2plot
http://www.python-course.eu/python3_formatted_output.php
Written by T.R. Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: Augustus 15, 2014
-
class stochpy.modules.StochSim.SSA(Method='Direct', File='ImmigrationDeath.psc', dir=None, Mode='steps', End=1000, Trajectories=1, IsTrackPropensities=False, IsInteractive=True)
SSA(Method=’Direct’, File=None, dir=None, Mode=’steps’, End=1000, Trajectories=1, IsTrackPropensities=False)
- Input options:
- Method [default = ‘Direct’], Available methods: ‘Direct’, ‘FirstReactionMethod’,’TauLeaping’,’Next Reaction Method’
- File [default = ImmigrationDeath.psc]
- dir [default = /home/user/stochpy/pscmodels/ImmigrationDeath.psc]
- Mode [default = ‘steps’] simulation for a total number of ‘steps’ or until a certain end ‘time’ (string)
- End [default = 1000] end of the simulation (number of steps or end time) (float)
- Trajectories [default = 1] (integer)
- TrackPropensities [default = False] (boolean)
Usage (with High-level functions):
>>> smod = stochpy.SSA()
>>> help(smod)
>>> smod.Model(File = ‘filename.psc’, dir = ‘/.../’)
>>> smod.Method(‘Direct’)
>>> smod.Reload()
>>> smod.Trajectories(3)
>>> smod.Timesteps(10000)
>>> smod.DoStochSim()
>>> smod.DoStochSim(end=1000,mode=’steps’,trajectories=5,method=’Direct’,IsTrackPropensities=True)
>>> smod.PlotSpeciesTimeSeries()
>>> smod.PlotPropensitiesTimeSeries()
>>> smod.PlotAverageSpeciesTimeSeries()
>>> smod.PlotWaitingtimesDistributions()
>>> smod.PlotSpeciesDistributions(bin_size = 3)
>>> smod.PrintSpeciesMeans()
>>> smod.PrintSpeciesDeviations()
>>> smod.PrintPropensitiesMeans()
>>> smod.ShowOverview()
>>> smod.ShowSpecies()
>>> smod.DoTestsuite()
-
ChangeInitialSpeciesAmount(species, value)
ChangeInitialSpeciesAmount(species,value)
Change initial species Amount
- Input:
- species (string)
- value (float)
-
ChangeParameter(parameter, value)
ChangeParameter(parameter,value)
Change parameter value
- Input:
- parameter (string)
- value (float)
-
DeleteTempfiles()
Deletes all .dat files
-
DoCainStochSim(endtime=100, frames=10000, trajectories=False, solver="HomogeneousDirect2DSearch", IsTrackPropensities=False)
Use Cain implementations for fixed-interval output stochastic simulations (www.cacr.caltech.edu/~sean/cain/DeveloperFile)
Make sure that the input file contains net stoichiometric coefficients
- Input:
- endtime [default = 100](float)
- frames [default = 10000] (integer)
- trajectories [default = False] (integer)
- solver [default = HomogeneousDirect2DSearch] (string)
- IsTrackPropensities [default = False] (boolean)
-
DoCompleteStochSim(error = 0.001, size=100000, IsTrackPropensities=False)
Do a stochastic simulation until the first four moments converge (in development, beta-status)
- Input:
- error maximal allowed error [default = 0.001]
- size (integer) number of steps before checking the first four moments [default = 100000]
- IsTrackPropensities [default = False]
- species_selection [default = None] List of names of species to store. This saves memory space and prevents Memory Errors.
-
DoDelayedStochSim(end=False, mode=False, method=False, trajectories=False, IsTrackPropensities=False, species_selection=None, IsOnlyLastTimepoint=False)
DoDelayedStochSim(end=100, mode=’steps’, method=’DelayedDirect’, trajectories=1, IsTrackPropensities=False, species_selection = None)
Run a stochastic simulation with delayed reactions until end is reached. This can be either time steps or end time (which could be a HUGE number of steps).
- Input:
- end [default=1000] simulation end (steps or time)
- mode [default=’steps’] simulation mode, can be one of:
- steps (string) total number of steps to simulate
- time (string) simulate until time is reached
- method [default=’Delayeddirect’] stochastic algorithm (DelayedDirect, DelayedNRM)
- trajectories [default = 1] number of trajectories
- IsTrackPropensities [default = False]
- species_selection [default = None] List of names of species to store. This saves memory space and prevents Memory Errors (occurring at ~15 species).
- IsOnlyLastTimepoint [default = False]
-
DoSingleMoleculeStochSim(end=False, mode=False, method=False, trajectories=False, species_selection=None, IsOnlyLastTimepoint=False)
DoSingleMoleculeStochSim(end=100, mode=’steps’, method=’SingleMoleculeMethod’, trajectories=1, IsTrackPropensities=False)
Run a single molecule stochastic simulation until end is reached. This can be either time steps or end time (which could be a HUGE number of steps).
- Input (similar to .DoStochSim()):
- end [default=1000] simulation end (steps or time)
- mode [default=’steps’] simulation mode, can be one of:
- steps (string) total number of steps to simulate
- time (string) simulate until time is reached
- method [default=’SingleMoleculeMethod’] stochastic algorithm, can be one of:
- SingleMoleculeMethod or SMM
- FastSingleMoleculeMethod or fSMM
- trajectories [default = 1] number of trajectories
- species_selection [default = None] List of names of species to store. This saves memory space and prevents Memory Errors.
- IsOnlyLastTimepoint [default = False]
-
DoStochKitStochSim(endtime=100, frames=10000, trajectories=False, IsTrackPropensities=False, customized_reactions=None, solver=None, keep_stats = False, keep_histograms = False)
Do Stochastic simulations with StochKit in StochPy
Make sure that the input file contains net stoichiometric coefficients
- Input:
- endtime [default = 100] (float)
- frames [default = 10000] (integer)
- trajectories [default = False] (integer)
- IsTrackPropensities [default = False] (boolean)
- customized_reactions [default=None] (list of strings)
- solver [default = None] (string)
- keep_states [default = False] (boolean)
- keep_histograms [default = False) (boolean)
-
DoStochSim(end=10, mode='steps', method='Direct', trajectories=1, epsilon=0.03, IsTrackPropensities=False)
Run a stochastic simulation for until end is reached. This can be either time steps or end time (which could be a HUGE number of steps).
- Input:
- end [default=1000] simulation end (steps or time)
- mode [default=’steps’] simulation mode, can be one of:
- steps (string) total number of steps to simulate
- time (string) simulate until time is reached
- method [default=’Direct’] stochastic algorithm (Direct, FRM, NRM, TauLeaping)
- trajectories [default = 1] number of trajectories
- epsilon [default = 0.03] parameter for Tau-Leaping
- IsTrackPropensities [default = False]
- species_selection [default = None] List of names of species to store. This saves memory space and prevents Memory Errors (occurring at ~15 species).
- IsOnlyLastTimepoint [default = False]
-
DoTestsuite(epsilon_ = 0.01, sim_trajectories=1000)
Do “sim_trajectories” simulations until t=50 and print the interpolated result for t = 0,1,2,...,50
- Input:
- epsilon_ [default = 0.01]: useful for tau-Leaping simulations (float)
- sim_trajectories [default = 1000]
-
DumpTrajectoryData(n)
- Input:
-
-
Endtime(t)
Set the end time of the exact realization of the Markov jump process
- Input:
-
-
Export2File(analysis='timeseries', datatype='species', IsAverage = False, directory=None)
Write data to a text document
- Input:
- analysis [default = ‘timeseries’] (string) options: timeseries, distribution, mean, std, autocorrelation, autocovariance
- datatype [default = ‘species’] (string) options: species, propensities, waitingtimes
- IsAverage [default = False] (boolean)
- directory [default = None] (string)
-
FillDataStochsim(IsImport=False)
Put all simulation data in the data object data_stochsim
- Input:
- IsImport (boolean) [False]
-
GetAveragePropensitiesDistributions()
Get average propensities distributions
-
GetAverageSpeciesDistributions()
Get average species distributions
-
GetPropensitiesAutocorrelations(rates2calc=True, gridpoints=True)
- Input:
- rates2calc [default = True] as a list [‘R1’,’R2’]
- gridpoints (integer)
-
GetPropensitiesAutocovariances(rates2calc=True, gridpoints=True)
- Input:
- rates2calc [default = True] as a list [‘R1’,’R2’]
- gridpoints (integer)
-
GetRegularGrid(npoints=50)
The Gillespie method generates data at irregular time points. However, it is possible to output data on a fixed regular time grid where the user can specify the resolution of the grid (npoints).
- Input:
- npoints [default = 50] (integer)
-
GetSpeciesAutocorrelations(species2calc=True, gridpoints=True)
- Input:
- species2calc [default = True] as a list [‘S1’,’S2’]
- gridpoints (integer)
-
GetSpeciesAutocovariances(species2calc=True, gridpoints=True)
- Input:
- species2calc [default = True] as a list [‘S1’,’S2’]
- gridpoints (integer)
-
GetTrajectoryData(n=1)
GetTrajectryData(n=1)
Switch to another trajectory, by default, the last trajectory is accessible
- Input:
- n [default = 1] (integer)
-
GetWaitingtimes()
Get for each reaction the waiting times
-
Import2StochPy(filename, filedir, delimiter='t')
Can import time series data with the following format:
Time S1 S2 S3 Fired Reactions
0 1 0 1 nan
1.5 0 0 2 1
etc.
or
Time S1 S2 S3
0 1 0 1
1.5 0 0 2
etc.
In the future, this function will probably support more data types. We currently accept the default output of the Gillespie algorithm from which other data types can be derived.
- Input:
- filename (string)
- filedir (string)
- delimiter (string)
-
Method(method)
- Input:
-
- Select one of the following methods:
- Direct
- FirstReactionMethod (FRM)
- NextReactionMethod (NRM)
- TauLeaping
- DelayedDirect
- DelayedNextReactionMethod (DelayedNRM)
- SingleMoleculeMethod (SMM)
- FastSingleMoleculeMethod (fSMM)
Note: input must be a string –> ‘Direct’ (not case sensitive)
-
Mode(sim_mode='steps')
Run a stochastic simulation for until end is reached. This can be either time steps or end time (which could be a HUGE number of steps).
- Input:
- sim_mode [default = ‘steps’] (string) ‘time’ or ‘steps’
-
Model(File, dir=None)
Select model for simulation
- Input:
- File (string)
- dir [default = None] (string)
-
PlotAveragePropensitiesAutocorrelations(nlags=-1, rates2plot=True, linestyle='None', linewidth=1, marker='o', colors=None, title='StochPy Propensities Autocorrelation Plot (# of trajectories = )', xlabel='Lag ($\tau$)', ylabel='Auto-correlation', IsLegend=True, legend_location='upper right', nstd=1)
PlotAveragePropensitiesAutocorrelation(nlags=-1,rates2plot = True,linestyle = ‘None’,linewidth = 1, marker = ‘o’,colors = None,title = ‘StochPy Propensities Autocorrelation Plot (# of trajectories = )’,xlabel=r’Lag ($ au$)’,ylabel=’Auto-correlation’,IsLegend=True,legend_location=’upper right’,nstd=1)
Plot the average propensities autocorrelation result for different lags. For each lag, the mean and standard deviation are plotted
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- rates2plot [default = True] as a list [‘R1’,’R2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- marker [default = ‘,’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = StochPy Average Time (# of trajectories = ... ) ] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotAveragePropensitiesAutocovariances(nlags=-1, rates2plot=True, linestyle='None', linewidth=1, marker='o', colors=None, title='StochPy Propensities Autocorrelation Plot (# of trajectories = )', xlabel='Lag ($\tau$)', ylabel='Auto-correlation', IsLegend=True, legend_location='upper right', nstd=1)
PlotAveragePropensitiesAutocorrelation(nlags=-1,rates2plot = True,linestyle = ‘None’,linewidth = 1, marker = ‘o’,colors = None,title = ‘StochPy Propensities Autocorrelation Plot (# of trajectories = )’,xlabel=r’Lag ($ au$)’,ylabel=’Auto-correlation’,IsLegend=True,legend_location=’upper right’,nstd=1)
Plot the average propensities autocorrelation result for different lags. For each lag, the mean and standard deviation are plotted
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- rates2plot [default = True] as a list [‘R1’,’R2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘,’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = StochPy Average Time (# of trajectories = ... ) ] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotAveragePropensitiesDistributions(rates2plot = True, linestyle = 'None', marker = 'o', colors = None, title = 'StochPy Average Species Time Series Plot (# of trajectories = )', xlabel='Propensity', ylabel='Probability', IsLegend=True, legend_location='upper right', nstd=1)
Plot the average time simulation result. For each time point, the mean and standard deviation are plotted
- Input:
- rates2plot [default = True] as a list [‘R1’,’R2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Time (# of trajectories = ... )’ ] (string)
- xlabel [default = ‘Propensity’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- nstd [default=1] (float
-
PlotAveragePropensitiesDistributionsConfidenceIntervals(rates2plot = True, colors = None, title = 'StochPy Average Propensities Distributions Plot (# of trajectories = )', xlabel='Propensity', ylabel='Probability', IsLegend=True, legend_location='Upper right', nstd=1)
Plot the average time simulation result. For each time point, the mean and standard deviation are plotted
- Input:
- rates2plot [default = True] as a list [‘R1’,’R2’]
- colors [default = None] (list)
- title [default = ‘StochPy Average Time (# of trajectories = ... )’ ] (string)
- xlabel [default = ‘Propensity’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- nstd [default=1] (float)
-
PlotAveragePropensitiesTimeSeries(rates2plot = True, linestyle = 'None', marker = 'o', colors = None, title = 'StochPy Average Propensities Time Series Plot (# of trajectories = )', xlabel='Time', ylabel='Propensity', IsLegend=True, legend_location='upper right', nstd=1)
Plot the average propensities For each time point, the mean and standard deviation are plotted
- Input:
- rates2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Propensities Plot (# of trajectories = ...)’ ] (string)
- xlabel [default = ‘Time’] (string)
- ylabel [default = ‘Propensity’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- nstd [default=1] (float
-
PlotAverageSpeciesAutocorrelations(species2plot = True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Species Autocorrelation Plot (# of trajectories = )')
Plot the average time simulation result. For each time point, the mean and standard deviation are plotted
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Species Autocorrelation Plot (# of trajectories = ... )’ ] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotAverageSpeciesAutocovariances(species2plot = True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Species Autocorrelation Plot (# of trajectories = )')
Plot the average time simulation result. For each time point, the mean and standard deviation are plotted
Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Species Autocorrelation Plot (# of trajectories = ... )’ ] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotAverageSpeciesDistributions(species2plot = True, linestyle = 'None', marker = 'o', colors = None, title = 'StochPy Average Species Distributions Plot (# of trajectories = )', xlabel='Species Amount', ylabel='Probability', IsLegend=True, legend_location='upper right', nstd=1)
Plot the average species distributions For each species Amount, the mean and standard deviation are plotted
- Input:
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Time (# of trajectories = ... )’ ] (string)
- xlabel [default = ‘Species Amount’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- nstd [default=1] (float)
-
PlotAverageSpeciesDistributionsConfidenceIntervals(species2plot=True, colors = None, title = 'StochPy Average Species Distributions Plot (# of trajectories = )', xlabel='Species Amount', ylabel='Probability', IsLegend=True, legend_location='upper right', nstd=1)
Plot the average species distributions For each species Amount, the mean and standard deviation are plotted
- Input:
- species2plot [default = True] as a list [‘S1’,’S2’]
- colors [default = None] (list)
- title [default = ‘StochPy Average Time (# of trajectories = ... )’ ] (string)
- xlabel [default = ‘Species Amount’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- nstd [default=1] (float
-
PlotAverageSpeciesTimeSeries(species2plot = True, linestyle = 'None', marker = 'o', colors = None, title = 'StochPy Average Species Time Series Plot (# of trajectories = )', xlabel='Time', ylabel='Copy Number', IsLegend=True, legend_location='upper right', nstd=1)
Plot the average time simulation result. For each time point, the mean and standard deviation are plotted
- Input:
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Time (# of trajectories = ... )’ ] (string)
- xlabel [default = ‘Time’] (string)
- ylabel [default = ‘Copy Number’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- nstd [default=1] (float
-
PlotPropensitiesAutocorrelations(rates2plot=True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Propensities Autocorrelation Plot', xlabel=r'Lag ($ au$)', ylabel='Auto-correlation')
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- rates2plot [default = True] as a list [‘R1’,’R2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘,’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = StochPy Propensities Autocorrelation Plot] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotPropensitiesAutocovariances(rates2plot=True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Propensities Autocorrelation Plot', xlabel=r'Lag ($ au$)', ylabel='Auto-correlation')
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- rates2plot [default = True] as a list [‘R1’,’R2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘,’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = StochPy Propensities Autocorrelation Plot] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Auto-correlation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotPropensitiesDistributions(self, rates2plot = True, linestyle = 'dotted', linewidth = 1, colors=None, title = 'StochPy Propensities Probability Mass Function', xlabel='Propensity', ylabel='Probability', IsLegend=True, legend_location='upper right', bin_size=1)
Plots the PDF for each generated trajectory
Default: PlotPropensitiesDistributions() plots PDF for each species
- Input:
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] (string)
- linewidth [default = 1] (float)
- colors (list)
- title [default = ‘StochPy Propensities Probability Mass Function’] (string)
- xlabel [default = ‘Propensity’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- bin_size [default=1] (integer)
-
PlotPropensitiesTimeSeries(n_events2plot = 10000, rates2plot = True, linestyle = 'solid', marker = '', colors = None, title = 'StochPy Propensities Time Series Plot', xlabel='Time', ylabel='Propensity', IsLegend=True, legend_location='upper right')
Plot time simulation output for each generated trajectory
Default: PlotPropensitiesTimeSeries() plots propensities for each species
- Input:
- n_events2plot [default = 10000] (integer)
- rates2plot [default = True]: species as a list [‘S1’,’S2’]
- marker [default = ‘’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- linestyle [default = ‘solid’]: dashed, dotted, and solid (string)
- linewidth [default = 1] (float)
- colors [default = None] (list)
- title [default = ‘StochPy Propensities Time Series Plot’] (string)
- xlabel [default = ‘Time’] (string)
- ylabel [default = ‘Propensity’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotSpeciesAutocorrelations(species2plot=True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Species Autocorrelation Plot', xlabel='Lag', ylabel='Auto-correlation')
Plot species autocorrelations
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Species Autocorrelation Plot’] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotSpeciesAutocovariances(species2plot=True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Species Autocorrelation Plot', xlabel='Lag', ylabel='Auto-correlation')
Plot species auto-covariances
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Species Autocorrelation Plot’] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotSpeciesDistributions(species2plot = True, linestyle = 'dotted', linewidth = 1, colors=None, title = 'StochPy Species Probability Mass Function', xlabel='Number of Molecules', ylabel='Probability', IsLegend=True, bin_size=1)
Plots the PDF for each generated trajectory
Default: PlotSpeciesDistributions() plots PDF for each species
- Input:
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] (string)
- linewidth [default = 1] (float)
- colors (list)
- title [default = ‘StochPy Species Probability Mass Function’] (string)
- xlabel [default = ‘Number of Molecules’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- bin_size [default=None] (integer)
-
PlotSpeciesTimeSeries(n_events2plot = 10000, species2plot = True, linestyle = 'solid', linewidth = 1, marker = '', colors = None, title = 'StochPy Species Time Series Plot', xlabel='Time', ylabel='Copy Number', IsLegend=True, legend_location='upper right')
Plot time simulation output for each generated trajectory
Default: PlotSpeciesTimeSeries() plots time simulation for each species
- Input:
- n_events2plot [default = 10000] (integer)
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘solid’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Species Time Series Plot’] (string)
- xlabel [default = ‘Time’] (string)
- ylabel [default = ‘Copy Number’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotWaitingtimesDistributions(rates2plot = True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Waiting times Plot', xlabel='inter-event time t', ylabel='Probability Density')
Plot event waiting time distributions
default: PlotWaitingtimesDistributions() plots waiting times for all rates
- Input:
- rates2plot [default = True] as a list of strings [“R1”,”R2”]
- linestyle [default = ‘None’] dashed, dotted, dash_dot, and solid (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Event Waiting times Plot’] (string)
- xlabel [default = ‘inter-event time t’] (string)
- ylabel [default = ‘Probability Density’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PrintAveragePropensitiesTimeSeries()
Analyze the average output over all generated trajectories
-
PrintAverageSpeciesTimeSeries()
Analyze the average output over all generated trajectories
-
PrintPropensitiesDistributions()
Print obtained distributions for each generated trajectory
-
PrintPropensitiesMeans()
Print the means of each propensity for the selected trajectory
-
PrintPropensitiesStandardDeviations()
Print the standard deviations of each propensity for the selected trajectory
-
PrintPropensitiesTimeSeries()
Print a time series of the propensities each generated trajectory
-
PrintSpeciesDistributions()
Print obtained distributions for each generated trajectory
-
PrintSpeciesMeans()
Print the means of each species for the selected trajectory
-
PrintSpeciesStandardDeviations()
Print the standard deviations of each species for the selected trajectory
-
PrintSpeciesTimeSeries()
Print time simulation output for each generated trajectory
-
PrintWaitingtimesDistributions()
Print obtained waiting times
-
PrintWaitingtimesMeans()
Print the waiting time means for the selected trajectory
-
PrintWaitingtimesStandardDeviations()
Print the waiting time standard deviations for the selected trajectory
-
Reload()
Reload the entire model again. Useful if the model file has changed
-
SetDelayParameters(delay_distributions, nonconsuming_reactions=None)
Input delayed model parameters. This function subsequently parses the delay input and assigns it to the SSA method.
Example:
SetDelayParameters(delay_distributions = {‘R1’:(‘fixed’,3), ‘R2’:(‘gamma’,5,1)}, nonconsuming_reactions = [‘R2’])
- Reaction ‘R1’ will get a delay of 3 time units and reaction ‘R2’ a random delay from a gamma distr with shape=5 and scale=1.
- Reaction ‘R1’ will be a consuming reaction, and ‘R2’ a nonconsuming reaction.
- Inputs:
- delay_distributions (dictionary)
- Dictionary of reaction name (or index) as key and distribution as value.
- nonconsuming_reactions (list) [default = None]
- Reaction names or indices of the given delayed reactions that are nonconsuming (subset of reactions given in delay_distributions.
All other delayed reactions given in delay_distributions are considered consuming.
Consuming and nonconsuming reactions are defined according to Xiaodong Cai (2007), “Exact stochastic simulation of coupled chemical reactions with delays”, J.Phys. Chem. 126:124108.
Value of delay_distributions can be any distribution of numpy.random, e.g.:
- (‘gamma’, p1,p2) = np.random.gamma(p1,p2) #Where p1 is the shape parameter and p2 the scale parameter.
- (‘exponential’, p1) = np.random.exponential(p1) #Where p1 is the scale parameter (NOT the rate).
- (‘uniform’, lower, upper) = np.random.uniform(0,lower,upper)
-
SetPutativeReactionTimes(distributions)
Sets the single molecule putative reaction times distribution. For use with DoSingleMoleculeStochSim().
- Inputs:
- distributions (dictionary)
- Dictionary of reaction name (or index) as key and distribution as value.
Value of distributions can be any distribution of numpy.random, e.g.:
- (‘gamma’, p1,p2) = np.random.gamma(p1,p2) #Where p1 is the shape parameter and p2 the scale parameter.
- (‘exponential’, p1) = np.random.exponential(p1) #Where p1 is the scale parameter (NOT the rate).
- (‘uniform’, lower, upper) = np.random.uniform(0,lower,upper)
-
ShowOverview()
Print an overview of the current settings
-
ShowSpecies()
Print the species of the model
-
Timesteps(s)
Set the number of time steps to be generated for each trajectory
- Input:
-
-
Trajectories(n)
Set the number of trajectories to be generated
- Input:
-
-
class stochpy.modules.StochSim.SSASettings(X_matrix, timesteps, starttime, endtime, speciesselection, istrackpropensities, isonlylasttimepoint)
- Input:
- X_matrix (array)
- timesteps (integer)
- starttime (float)
- endtime (float)
- istrackpropensities (boolean)
StochPy Cell Division Module
Example of a sequential simulator. This simulator tracks one cell for N generations.
Most of the functionalities of the SSA module such as plotting and writing to a file are also available in this module.
Written by T.R. Maarleveld and M. Moinat, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: Augustus 20, 2014
-
class stochpy.modules.StochPyCellDivision.CellDivision(Method='Direct', File='CellDivision.psc', dir=None, sim_mode='generations', end=3, IsInteractive=True)
- Input options:
- File [default = CellDivision.psc]
- dir [default = /home/user/stochpy/pscmodels/ImmigrationDeath.psc]
Usage (with High-level functions):
>>> cmod = stochpy.CellDivision()
>>> help(cmod)
>>> cmod.DoCellDivisionStochSim()
>>> cmod.DoCellDivisionStochSim(self,end = 5, mode= ‘generations’,IsTrackPropensities=False)
>>> cmod.Model(File = ‘filename.psc’, dir = ‘/.../’)
>>> cmod.Reload()
>>> smod.PlotSpeciesTimeSeries()
>>> smod.PlotPropensitiesTimeSeries()
>>> smod.PlotAveragedSpeciesTimeSeries()
>>> smod.PlotWaitingtimeDistributions()
>>> smod.PlotSpeciesDistributions(bin_size = 3)
>>> smod.PrintSpeciesMeans()
>>> smod.PrintSpeciesDeviations()
>>> smod.PrintPropensityMeans()
>>> cmod.ShowOverview()
>>> cmod.ShowSpecies()
-
AnalyzeExtantCells(n_bins=50, n_samples=100000)
Obtains the species statistics for a population of extant cells.
- Input:
- n_bins (int) [default = 50] Number of bins for the binning of interdivision time and age.
- n_samples (int) [default = 100,000] Number of equally time spaced samples to take from the simulation.
Result:
# self.probabilities_extant_output will contain for every trajectory for every species an array with for every copy number the ‘probability’ in an extant cell population.
-
CalculateSpecificGrowthRate(n_trapezoidal=20, IsDebug=True)
Calculates the specific growth rate from the mother volume distribution (phi) and partitioning distribution (K).
The specific growth rate is retrieved by numerically solving equation 20 of Painter and Marr [1] for k. For a fast calcuation, the trapezoidal rule is used for integration and the Secant method for solving the equation.
[1] Painter P.R. and Marr A.G. (1968), “Mathematics of microbial populations”, Annu. Rev. Microbiol. 22:519-548.
- Input:
- n_trapezoidal (integer) [default = 20] Number of subintervals used for integration with the composite trapezoidal rule.
- IsDebug (boolean) [default = True] With IsDebug True, the script checks calculated specific growth rate. This takes some time. For a ‘silent’ calculation, set IsDebug False.
-
ChangeInitialSpeciesAmount(species, value)
ChangeInitialSpeciesAmount(species,value)
Change initial species Amount
- Input:
- species (string)
- value (float)
-
ChangeParameter(parameter, value)
ChangeParameter(parameter,value)
Change parameter value
- Input:
- parameter (string)
- value (float)
-
DoCellDivisionStochSim(mode=False, end=False, method=False, trajectories=False, IsTrackPropensities=False, species_selection=None, IsOnlyLastTimepoint=False)
Do stochastic simulations with cell growth and cell divisions.
- Input:
- mode (str)
- ‘generations’ [default]
- ‘time’
- ‘steps’
- end (int) [default = None]
- Number of generations (default = 3) or steps to take (default = 1000).
method (str) [default = False]
trajectories (int) [default = 1]
IsTrackPropensities (boolean)
- species_selection
- Selection of species of which the time series data is stored.
IsOnlyLastTimepoint [default = False]
-
DumpTrajectoryData(n)
- Input:
-
-
Endtime(t)
Set the end time of the exact realization of the Markov jump process
- Input:
-
-
Export2File(analysis='timeseries', datatype='species', IsAverage = False, directory=None)
Write data to a text document
- Input:
- analysis [default = ‘timeseries’] (string) options: timeseries, distribution, mean, std, autocorrelation, autocovariance
- datatype [default = ‘species’] (string) options: species, propensities, waitingtimes
- IsAverage [default = False] (boolean)
- directory [default = None] (string)
-
Generations(g)
Endtime(t)
Set the end time of the exact realization of the Markov jump process
- Input:
-
-
GetRegularGrid(npoints=50)
The Gillespie method generates data at irregular time points. However, it is possible to output data on a fixed regular time grid where the user can specify the resolution of the grid (npoints).
- Input:
- npoints [default = 50] (integer)
-
GetTrajectoryData(n=1)
Switch to another trajectory, by default, the last trajectory is accesible
- Input:
-
-
GetWaitingtimes()
Get for each reaction the waiting times
-
Method(method)
Set stochastic simulation algorithm to be used.
- Input:
-
-
Mode(sim_mode='generations')
Set mode for a stochastic simulation.
- Input:
- sim_mode [default = ‘generations’] (string) ‘time’,’steps’, ‘generations’
-
Model(File, dir=None, IsSetDefault=True)
Give the model, which is used to do stochastic simulations on
- Input:
- File filename.psc (string)
- dir [default = None] the directory where File lives (string)
- IsSetDefault [default = True]
-
PlotAveragePropensitiesAutocorrelations(nlags=-1, rates2plot=True, linestyle='None', linewidth=1, marker='o', colors=None, title='StochPy Propensities Autocorrelation Plot (# of trajectories = )', xlabel='Lag ($\tau$)', ylabel='Auto-correlation', IsLegend=True, legend_location='upper right', nstd=1)
PlotAveragePropensitiesAutocorrelation(nlags=-1,rates2plot = True,linestyle = ‘None’,linewidth = 1, marker = ‘o’,colors = None,title = ‘StochPy Propensities Autocorrelation Plot (# of trajectories = )’,xlabel=r’Lag ($ au$)’,ylabel=’Auto-correlation’,IsLegend=True,legend_location=’upper right’,nstd=1)
Plot the average propensities autocorrelation result for different lags. For each lag, the mean and standard deviation are plotted
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- rates2plot [default = True] as a list [‘R1’,’R2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- marker [default = ‘,’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = StochPy Average Time (# of trajectories = ... ) ] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotAveragePropensitiesAutocovariances(nlags=-1, rates2plot=True, linestyle='None', linewidth=1, marker='o', colors=None, title='StochPy Propensities Autocorrelation Plot (# of trajectories = )', xlabel='Lag ($\tau$)', ylabel='Auto-correlation', IsLegend=True, legend_location='upper right', nstd=1)
PlotAveragePropensitiesAutocorrelation(nlags=-1,rates2plot = True,linestyle = ‘None’,linewidth = 1, marker = ‘o’,colors = None,title = ‘StochPy Propensities Autocorrelation Plot (# of trajectories = )’,xlabel=r’Lag ($ au$)’,ylabel=’Auto-correlation’,IsLegend=True,legend_location=’upper right’,nstd=1)
Plot the average propensities autocorrelation result for different lags. For each lag, the mean and standard deviation are plotted
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- rates2plot [default = True] as a list [‘R1’,’R2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘,’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = StochPy Average Time (# of trajectories = ... ) ] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotAveragePropensitiesDistributions(rates2plot = True, linestyle = 'None', marker = 'o', colors = None, title = 'StochPy Average Species Time Series Plot (# of trajectories = )', xlabel='Propensity', ylabel='Probability', IsLegend=True, nstd=1)
Plot the average time simulation result. For each time point, the mean and standard deviation are plotted
- Input:
- rates2plot [default = True] as a list [‘R1’,’R2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Time (# of trajectories = ... )’ ] (string)
- xlabel [default = ‘Propensity’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string)
- nstd [default=1] (float
-
PlotAveragePropensitiesDistributionsConfidenceIntervals(rates2plot = True, colors = None, title = 'StochPy Average Propensities Distributions Plot (# of trajectories = )', xlabel='Propensity', ylabel='Probability', IsLegend=True, nstd=1)
Plot the average time simulation result. For each time point, the mean and standard deviation are plotted
- Input:
- rates2plot [default = True] as a list [‘R1’,’R2’]
- colors [default = None] (list)
- title [default = ‘StochPy Average Time (# of trajectories = ... )’ ] (string)
- xlabel [default = ‘Propensity’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string)
- nstd [default=1] (float)
-
PlotAveragePropensitiesTimeSeries(rates2plot = True, linestyle = 'None', marker = 'o', colors = None, title = 'StochPy Average Propensities Time Series Plot (# of trajectories = )', xlabel='Time', ylabel='Propensity', IsLegend=True, nstd=1)
Plot the average propensities For each time point, the mean and standard deviation are plotted
- Input:
- rates2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Propensities Plot (# of trajectories = ...)’ ] (string)
- xlabel [default = ‘Time’] (string)
- ylabel [default = ‘Propensity’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string)
- nstd [default=1] (float
-
PlotAverageSpeciesAutocorrelations(species2plot = True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Species Autocorrelation Plot (# of trajectories = )')
Plot the average time simulation result. For each time point, the mean and standard deviation are plotted
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Species Autocorrelation Plot (# of trajectories = ... )’ ] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotAverageSpeciesAutocovariances(species2plot = True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Species Autocorrelation Plot (# of trajectories = )')
Plot the average time simulation result. For each time point, the mean and standard deviation are plotted
Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Species Autocorrelation Plot (# of trajectories = ... )’ ] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotAverageSpeciesDistributions(species2plot = True, linestyle = 'None', marker = 'o', colors = None, title = 'StochPy Average Species Distributions Plot (# of trajectories = )', xlabel='Species Amount', ylabel='Probability', IsLegend=True, nstd=1)
Plot the average species distributions For each species Amount, the mean and standard deviation are plotted
- Input:
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Time (# of trajectories = ... )’ ] (string)
- xlabel [default = ‘Species Amount’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string)
- nstd [default=1] (float)
-
PlotAverageSpeciesDistributionsConfidenceIntervals(species2plot=True, colors = None, title = 'StochPy Average Species Distributions Plot (# of trajectories = )', xlabel='Species Amount', ylabel='Probability', IsLegend=True, nstd=1)
Plot the average species distributions For each species Amount, the mean and standard deviation are plotted
- Input:
- species2plot [default = True] as a list [‘S1’,’S2’]
- colors [default = None] (list)
- title [default = ‘StochPy Average Time (# of trajectories = ... )’ ] (string)
- xlabel [default = ‘Species Amount’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string)
- nstd [default=1] (float
-
PlotAverageSpeciesTimeSeries(species2plot = True, linestyle = 'None', marker = 'o', colors = None, title = 'StochPy Average Species Time Series Plot (# of trajectories = )', xlabel='Time', ylabel='Copy Number', IsLegend=True, nstd=1)
Plot the average time simulation result. For each time point, the mean and standard deviation are plotted
- Input:
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Average Time (# of trajectories = ... )’ ] (string)
- xlabel [default = ‘Time’] (string)
- ylabel [default = ‘Copy Number’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string)
- nstd [default=1] (float)
-
PlotExtantSpeciesDistribution(species2plot=True, histtype='steps-mid', linestyle='dotted', linewidth=1, colors=None, title='StochPy Extant cell Species Probability Mass Function', xlabel='Molecule number', ylabel='Probability Mass', IsLegend=True, legend_location='upper right')
Plots the analyzed/extrapolated extant cell species number Probability Mass Function.
- Input:
- species2plot [default = True) (list)
- histtype [default = ‘steps-mid’] (string)
- linestyle [default = ‘dotted’] (string)
- linewidth [default = 1] (float)
- colors [default = None] (list)
- title [default = ‘StochPy Daughter cell Volume Probability Mass Function’] (string)
- xlabel [default = ‘Volume’] (string)
- ylabel [default = ‘Probability Mass’] (string)
-
PlotInterdivisionTimeDistribution(bin_size=0.01, histtype = 'step', linestyle = 'dotted', filled = False, linewidth = 1, colors=None, title = 'StochPy IDT Probability Density Function', xlabel='Interdivision Time', ylabel='Probability Density', IsLegend=True, legend_location='upper right')
Plots Interdivision Time distribution (between cell divisions) for a certain trajectories or for ‘all’ trajectories together
- Input:
- bin_size [default = 0.01] (float)
- histtype [default = ‘step’] (string)
- linestyle [default = ‘dotted’] (string)
- filled [default = False] (boolean)
- linewidth [default = 1] (float)
- colors [default = None] (list)
- title [default = ‘StochPy IDT Probability Density Function’] (string)
- xlabel [default = ‘Interdivision Time’] (string)
- ylabel [default = ‘Probability Density’] (string)
- IsLegend [default = True] (boolean)
-
PlotPropensitiesAutocorrelations(rates2plot=True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Propensities Autocorrelation Plot', xlabel=r'Lag ($ au$)', ylabel='Auto-correlation')
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- rates2plot [default = True] as a list [‘R1’,’R2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘,’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = StochPy Propensities Autocorrelation Plot] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotPropensitiesAutocovariances(rates2plot=True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Propensities Autocorrelation Plot', xlabel=r'Lag ($ au$)', ylabel='Auto-correlation')
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- rates2plot [default = True] as a list [‘R1’,’R2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘,’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = StochPy Propensities Autocorrelation Plot] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Auto-correlation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotPropensitiesDistributions(self, rates2plot = True, linestyle = 'dotted', linewidth = 1, colors=None, title = 'StochPy Propensities Probability Mass Function', xlabel='Propensity', ylabel='Probability', IsLegend=True, bin_size=1)
Plots the PDF for each generated trajectory
Default: PlotPropensitiesDistributions() plots PDF for each species
- Input:
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] (string)
- linewidth [default = 1] (float)
- colors (list)
- title [default = ‘StochPy Propensities Probability Mass Function’] (string)
- xlabel [default = ‘Propensity’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- bin_size [default=1] (integer)
-
PlotPropensitiesTimeSeries(n_events2plot = 10000, rates2plot = True, linestyle = 'solid', marker = '', colors = None, title = 'StochPy Propensities Time Series Plot', xlabel='Time', ylabel='Propensity', IsLegend=True, legend_location='upper right')
Plot time simulation output for each generated trajectory
Default: PlotPropensitiesTimeSeries() plots propensities for each species
- Input:
- n_events2plot [default = 10000] (integer)
- rates2plot [default = True]: species as a list [‘S1’,’S2’]
- marker [default = ‘’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- linestyle [default = ‘solid’]: dashed, dotted, and solid (string)
- linewidth [default = 1] (float)
- colors [default = None] (list)
- title [default = ‘StochPy Propensities Time Series Plot’] (string)
- xlabel [default = ‘Time’] (string)
- ylabel [default = ‘Propensity’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string)
-
PlotSpeciesAutocorrelations(species2plot=True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Species Autocorrelation Plot', xlabel='Lag', ylabel='Auto-correlation')
Plot species autocorrelations
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Species Autocorrelation Plot’] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotSpeciesAutocovariances(species2plot=True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Species Autocorrelation Plot', xlabel='Lag', ylabel='Auto-correlation')
Plot species auto-covariances
- Input:
- nlags [default = -1] (integer) 1,2,3 ... -1 where 3 means calculate the autocorrelation for the first 3 lags and -1 for all lags
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Species Autocorrelation Plot’] (string)
- xlabel [default = r’Lag ($ au$)’] (string)
- ylabel [default = ‘Autocorrelation’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotSpeciesDaughterDistribution(bin_size=1, species2plot = True, histtype = 'step', linestyle = 'dotted', filled = False, linewidth = 1, colors=None, title = 'StochPy Daughter cell Species Probability Mass Function', xlabel='Molecule number', ylabel='Probability Mass', IsLegend=True, legend_location='upper right')
StochPy Daughter cell Species Probability Mass Function
- Input:
- bin_size [default = 0.1] (float)
- species2plot [default = True) (list)
- histtype [default = ‘step’] (string)
- linestyle [default = ‘dotted’] (string)
- filled [default = False] (boolean)
- linewidth [default = 1] (float)
- colors [default = None] (list)
- title [default = ‘StochPy Daughter cell Volume Probability Mass Function’] (string)
- xlabel [default = ‘Volume’] (string)
- ylabel [default = ‘Probability Mass’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotSpeciesDistributions(species2plot = True, linestyle = 'dotted', linewidth = 1, colors=None, title = 'StochPy Species Probability Mass Function', xlabel='Number of Molecules', ylabel='Probability', IsLegend=True, bin_size=1)
Plots the PDF for each generated trajectory
Default: PlotSpeciesDistributions() plots PDF for each species
- Input:
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘dotted’] (string)
- linewidth [default = 1] (float)
- colors (list)
- title [default = ‘StochPy Species Probability Mass Function’] (string)
- xlabel [default = ‘Number of Molecules’] (string)
- ylabel [default = ‘Probability’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- bin_size [default=1] (integer)
-
PlotSpeciesMotherDistribution(bin_size=1, species2plot = True, histtype = 'step', linestyle = 'dotted', filled = False, linewidth = 1, colors=None, title = 'StochPy Mother cell Species Probability Mass Function', xlabel='Molecule number', ylabel='Probability Mass', IsLegend=True, legend_location='upper right')
StochPy Mother cell Species Probability Mass Function
- Input:
- bin_size [default = 0.1] (float)
- species2plot [default = True) (list)
- histtype [default = ‘step’] (string)
- linestyle [default = ‘dotted’] (string)
- filled [default = False] (boolean)
- linewidth [default = 1] (float)
- colors [default = None] (list)
- title [default = ‘StochPy Mother cell Volume Probability Mass Function’] (string)
- xlabel [default = ‘Volume’] (string)
- ylabel [default = ‘Probability Mass’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
PlotSpeciesTimeSeries(plottype = 'amounts', n_events2plot = 10000, species2plot = True, linestyle = 'solid', linewidth = 1, marker = '', colors = None, title = 'StochPy Species Time Series Plot', xlabel='Time', ylabel='Copy Number', IsLegend=True, legend_location='upper right')
Plot time simulation output for each generated trajectory.
Default: PlotSpeciesTimeSeries() plots time simulation for each species amounts. Note that also species concentrations can be plotted.
- Input:
- plottype [default = ‘amounts’] alternative is ‘concentrations’
- n_events2plot [default = 10000] (integer)
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘solid’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Species Time Series Plot’] (string)
- xlabel [default = ‘Time’] (string)
- ylabel [default = ‘Copy Number’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string)
-
PlotSpeciesVolumeTimeSeries(plottype ='amounts', n_events2plot = 10000, species2plot = True, linestyle = 'solid', linewidth = 1, marker = '', colors = None, IsCalculated=True)
Plot time simulation output for each generated trajectory
Default: PlotSpeciesTimeSeries() plots time simulation for each species
- Input:
- plottype [default = ‘amounts’] alternative is ‘concentrations’
- n_events2plot [default = 10000] (integer)
- species2plot [default = True] as a list [‘S1’,’S2’]
- linestyle [default = ‘solid’] dashed, solid, and dash_dot (string)
- linewidth [default = 1] (float)
- marker [default = ‘’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Species Time Series and Volume Plot’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string)
-
PlotVolumeDaughterDistribution(bin_size=0.1, histtype = 'step', linestyle = 'dotted', filled = False, linewidth = 1, colors=None, title = 'StochPy Daughter cell Volume Probability Density Function', xlabel='Volume', ylabel='Probability Density')
Plot the volume distribution of daughter cells
- Input:
- bin_size [default = 0.1] (float)
- histtype [default = ‘step’] (string)
- linestyle [default = ‘dotted’] (string)
- filled [default = False] (boolean)
- linewidth [default = 1] (float)
- colors [default = None] (list)
- title [default = ‘StochPy Daughter cell Volume Probability Density Function’] (string)
- xlabel [default = ‘Volume’] (string)
- ylabel [default = ‘Probability Density’] (string)
-
PlotVolumeMotherDistribution(bin_size=0.1, histtype = 'step', linestyle = 'dotted', filled = False, linewidth = 1, colors=None, title = 'StochPy Mother cell Volume Probability Density Function', xlabel='Volume', ylabel='Probability Density')
Plot the volume distribution of mother cells
- Input:
- bin_size [default = 0.1] (float)
- histtype [default = ‘step’] (string)
- linestyle [default = ‘dotted’] (string)
- filled [default = False] (boolean)
- linewidth [default = 1] (float)
- colors [default = None] (list)
- title [default = ‘StochPy Mother cell Volume Probability Density Function’] (string)
- xlabel [default = ‘Volume’] (string)
- ylabel [default = ‘Probability Density’] (string)
-
PlotVolumeTimeSeries(n_events2plot = 10000, linestyle = 'solid', linewidth = 1, marker = '', colors = None, title = 'StochPy Volume Time Series Plot', xlabel = 'Time', ylabel = 'Volume')
StochPy Volume Time Series Plot
- Input:
- n_events2plot [default = 10000] (integer)
- linestyle [default = ‘solid’] (string)
- linewidth [default = 1] (float)
- marker [default = ‘’] (string)
- colors [default = None] (list)
- title [default = ‘StochPy Volume Time Series Plot’] (string)
- xlabel [default = ‘Volume’] (string)
- ylabel [default = ‘Probability Mass’] (string)
-
PlotWaitingtimesDistributions(rates2plot = True, linestyle = 'None', linewidth = 1, marker = 'o', colors = None, title = 'StochPy Waiting times Plot', xlabel='inter-event time t', ylabel='Probability Density')
Plot event waiting time distributions
default: PlotWaitingtimesDistributions() plots waiting times for all rates
- Input:
- rates2plot [default = True] as a list of strings [“R1”,”R2”]
- linestyle [default = ‘None’] dashed, dotted, dash_dot, and solid (string)
- linewidth [default = 1] (float)
- marker [default = ‘o’] (‘v’,’o’,’s’,’,’,’*’,’.’)
- colors [default = None] (list)
- title [default = ‘StochPy Event Waiting times Plot’] (string)
- xlabel [default = ‘inter-event time t’] (string)
- ylabel [default = ‘Probability Density’] (string)
- IsLegend [default = True] (boolean)
- legend_location [default = ‘upper right’] (string)
-
PrintPropensitiesMeans()
Print the means of each species for the selected trajectory
-
PrintPropensitiesStandardDeviations()
Print the standard deviations of each species for the selected trajectory
-
PrintSpeciesMeans()
Print the means of each species for the selected trajectory
-
PrintSpeciesStandardDeviations()
Print the standard deviations of each species for the selected trajectory
-
Reload()
Reload the entire model again. Useful if the model file has changed
-
SetDefaultParameters()
Set default parameters: growth rate, growth type, initial volume, and volume distributions
-
SetDelayParameters(delay_distributions, nonconsuming_reactions=None)
Input delayed model parameters. This function subsequently parses the delay input and assigns it to the SSA method.
Example:
SetDelayParameters(delay_distributions = {‘R1’:(‘fixed’,3), ‘R2’:(‘gamma’,5,1)}, nonconsuming_reactions = [‘R2’])
- Reaction ‘R1’ will get a delay of 3 seconds and reaction ‘R2’ a random delay from a gamma distr with shape=5 and scale=1.
- Reaction ‘R1’ will be a consuming reaction, and ‘R2’ a nonconsuming reaction.
- Inputs:
- delay_distributions (dictionary)
- Dictionary of reaction name (or index) as key and distribution as value.
- nonconsuming_reactions (list) [default = None]
- Reaction names or indices of the given delayed reactions that are nonconsuming (subset of reactions given in delay_distributions.
All other delayed reactions given in delay_distributions are considered consuming.
Consuming and nonconsuming reactions are defined according to Xiaodong Cai (2007), “Exact stochastic simulation of coupled chemical reactions with delays”, J.Phys. Chem. 126:124108.
Value of delay_distributions can be any distribution of numpy.random, e.g.:
- (‘gamma’, p1,p2) = np.random.gamma(p1,p2) #Where p1 is the shape parameter and p2 the scale parameter.
- (‘exponential’, p1) = np.random.exponential(p1) #Where p1 is the scale parameter (NOT the rate).
- (‘uniform’, lower, upper) = np.random.uniform(0,lower,upper)
-
SetExactDividingSpecies(species)
Set species (as list of names) that are volume dependent, but divide equally (after replication).
- Input:
-
-
SetGrowthFunction(growth_rate, growth_type='exponential')
- Input:
- growth_rate (float)
- growth_type (string) [default = ‘exponential’, alternative = ‘linear’]
-
SetInitialVolume(initial_volume)
Set initial volume
- Input:
-
-
SetNonDividingSpecies(species)
Set species (as list of names) that are volume dependent, but do not divide.
- Input:
-
-
SetPutativeReactionTimes(distributions)
Sets the single molecule putative reaction times distribution.
- Inputs:
- distributions (dictionary)
- Dictionary of reaction name (or index) as key and distribution as value.
Value of distributions can be any distribution of numpy.random, e.g.:
- (‘gamma’, p1,p2) = np.random.gamma(p1,p2) #Where p1 is the shape parameter and p2 the scale parameter.
- (‘exponential’, p1) = np.random.exponential(p1) #Where p1 is the scale parameter (NOT the rate).
- (‘uniform’, lower, upper) = np.random.uniform(0,lower,upper)
-
SetVolumeDependencies(IsVolumeDependent, VolumeDependencies=, []SpeciesExtracellular=[])
Set volume dependency of reactions.
- Input:
-
-
SetVolumeDistributions(phi, K, phi_beta_mean=False)
- Input:
phi (list) Specifies the distribution of the cell volume at which the mother cell divides.
- K (list) The number from this distribution is multiplied with the mother cell volume to get volume of daughter 1.
Vdaughter = Vmother * K
Note: This distribution needs to have a symmetrical distribution with a mean of 0.5, otherwise one will create a bias for one daughter
phi_beta_mean (float) only if phi is a beta distribution, then it is added to the random number from phi_distr
- The phi and K distributions can be any distribution of numpy.random, e.g.:
- (‘gamma’, p1,p2) = np.random.gamma(p1,p2) #Where p1 is the shape parameter and p2 the scale parameter.
- (‘exponential’, p1) = np.random.exponential(p1) #Where p1 is the scale parameter (NOT the rate).
- (‘uniform’, lower, upper) = np.random.uniform(0,lower,upper)
Fixed values for phi and K are also possible, e.g.:
- phi = (‘fixed’, 2) and K = (‘fixed’,0.5) creates a lineage with cells that grow from a volume of 1 to 2.
-
ShowOverview()
Print an overview of the current settings
-
ShowSpecies()
Print the species of the model
-
Timesteps(s)
Set the number of time steps to be generated for each trajectory
- Input:
-
-
Trajectories(n)
Set the number of trajectories to be generated
- Input:
-
-
class stochpy.modules.StochPyCellDivision.IntegrationStochasticCellDivisionObj
This class is specifically designed to store the results of a stochastic time simulation
It has methods for setting e.g. the Time, Labels, Species, and Volume data and
getting e.g. Time, Species,and Volume (including time) arrays. However, of more use:
- getDataAtTime(time) the data generated at time point “time”.
- getDataInTimeInterval(time, bounds=None) more intelligent version of the above
returns an array of all data points where: time-bounds <= time <= time+bounds
-
HAS_AGES = False
-
HAS_DT = False
-
HAS_GENERATION_TIMESTEPS = False
-
HAS_IDT = False
-
HAS_SPECIES_DAUGHTER = False
-
HAS_SPECIES_MOTHER = False
-
HAS_TIME = False
-
HAS_VOLUME_DAUGHTER = False
-
HAS_VOLUME_MOTHER = False
-
HAS_XDATA = False
-
IS_VALID = True
-
TYPE_INFO = 'Stochastic'
-
ages = None
-
division_times = None
-
generation_timesteps = None
-
getDataAtTime(time)
Return all data generated at “time”
- Input:
- time the required exact time point
-
getDataInTimeInterval(time, bounds=None)
Returns an array of all data in interval: time-bounds <= time <= time+bounds
where bound defaults to step size
- Input:
- time the interval midpoint
- bounds [default=None] interval half span defaults to step size
-
getDaughterDataAtDivisionTime(time)
Return all daughter data generated at “time”
- Input:
- time the required exact time point
-
getMotherDataAtDivisionTime(time)
Return all mother data generated at “time”
- Input:
- time the required exact time point
-
getSpeciesDaughter(lbls=False)
Return an array of time+species
Input:
- lbls [default=False] return only the time+species array or optionally both the data array and a list of column label
-
getSpeciesMother(lbls=False)
Return an array of time+species
Input:
- lbls [default=False] return only the time+species array or optionally both the data array and a list of column label
-
getTime(lbls=False)
Return the time vector
- Input:
- lbls [default=False] return only the time array or optionally both the time array and time label
-
getVolumeDaughter()
Return an array of time+volume
-
getVolumeMother()
Return an array of time+volume
-
interdivision_times = None
-
setAges(ages)
set the ... ages array
- Input:
-
-
setGenerationTimesteps(timesteps)
set the generation timesteps array
- Input:
-
-
setInterdivisionTimes(idt, n_generations)
set the (inter)division times array
- Input:
-
-
setLabels(species)
Set the species
- Input:
- species a list of species labels
-
setSimulationInfo(timesteps, endtime, simulation_trajectory)
set Simulation Information
- Input:
- timesteps (integer)
- endtime (float)
- simulation_trajectory (integer)
-
setSpeciesDaughter(species, lbls=None)
Set the species array
- Input:
- species an array of species vs time data
- lbls [default=None] a list of species labels
-
setSpeciesDaughterDist(distributions, means, stds, moments)
setSpeciesDist stuff for the determination of distributions
- Input:
- distributions (list)
- means (dictionary)
- stds (dictionary)
- moments (dictionary)
-
setSpeciesMother(species, lbls=None)
Set the species array
- Input:
- species an array of species vs time data
- lbls [default=None] a list of species labels
-
setSpeciesMotherDist(distributions, means, stds, moments)
setSpeciesDist stuff for the determination of distributions
- Input:
- distributions (list)
- means (dictionary)
- stds (dictionary)
- moments (dictionary)
-
setTime(time, lbl=None)
Set the time vector
- Input:
- time a 1d array of time points
- lbl [default=None] is “Time” set as required
-
setVolumeDaughter(volume_selected, volume_notselected)
set the volume daughter array
- Input:
-
-
setVolumeDaughterDist(distributions, means, stds, moments)
setSpeciesDist stuff for the determination of distributions
- Input:
- distributions (list)
- means (dictionary)
- stds (dictionary)
- moments (dictionary)
-
setVolumeMother(volume)
set the volume mother array
- Input:
-
-
setVolumeMotherDist(distributions, means, stds, moments)
setSpeciesDist stuff for the determination of distributions
- Input:
- distributions (list)
- means (dictionary)
- stds (dictionary)
- moments (dictionary)
-
setXData(xdata, lbls=None)
Sets an array of extra simulation data
Input:
- xdata an array of xdata vs time
- lbls [default=None] a list of xdata labels
-
species_daughter = None
-
species_labels = None
-
species_mother = None
-
time = None
-
time_label = 'Time'
-
volume_daughter = None
-
volume_mother = None
-
xdata_labels = None
Direct Method
This program performs the direct Stochastic Simulation Algorithm from Gillespie (1977) [1].This algorithm is used to generate exact realizations of the Markov jump process. Of course, the algorithm is stochastic, so these realizations are different for each run.
Only molecule populations are specified. Positions and velocities, such as in Molecular Dynamics (MD) are ignored. This makes the algorithm much faster, because non-reactive molecular collisions can be ignored.
Still, this exact SSA is quite slow, because it insists on simulating every individual reaction event, which takes a lot of time if the reactant population is large. Furthermore, even larger problems arise if the model contains distinct processes operating on different time-scales [2].
[1] Gillespie D.T (1977), “Exact stochastic simulation of coupled chemical reactions”, J.Phys. Chem. 81:2340-2361
[2] Wilkinson D.J (2009), “Stochastic Modelling for quantitative description of heterogeneous biological systems”, Nat Rev Genet; 0(2):122-133
-
class stochpy.implementations.DirectMethod.DirectMethod(File, dir)
Direct Stochastic Simulation Algorithm from Gillespie (1977) [1].
This algorithm is used to generate exact realizations of the Markov jump process. Of course, the algorithm is stochastic, so these realizations are different for each run.
[1] Gillespie D.T (1977), “Exact stochastic simulation of coupled chemical reactions”, J.Phys. Chem. 81:2340-2361
- Input:
- File filename.psc
- dir /home/user/Stochpy/pscmodels/filename.psc
-
Execute(settings, IsStatusBar=False)
Generates T trajectories of the Markov jump process.
- Input:
-
-
RunExactTimestep(settings)
Calculates a time step of the Direct Method
First Reaction Method
This module performs the first reaction method Stochastic Simulation Algorithm from Gillespie (1977).
This algorithm is used to generate exact realizations of the Markov jump process. Of course, the algorithm is stochastic, so these realizations are different for each run.
Only molecule populations are specified. Positions and velocities, such as in Molecular Dynamics (MD) are ignored. This makes the algorithm much faster, because non-reactive molecular collisions can be ignored.different
Still, this exact SSA is quite slow, because it insists on simulating every individual reaction event, which takes a lot of time if the reactant population is large.
Furthermore, even larger problems arise if the model contains distinct processes operating on different time-scales.
Written by T.R. Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: Augustus 20, 2014
-
class stochpy.implementations.FirstReactionMethod.FirstReactionMethod(File, dir)
First Reaction Method from Gillespie (1977)
This algorithm is used to generate exact realizations of the Markov jump process. Of course, the algorithm is stochastic, so these realizations are different for each run.
- Input:
- File filename.psc
- dir /home/user/Stochpy/pscmodels/filename.psc
-
Execute(settings, IsStatusBar=False)
Generates T trajectories of the Markov jump process.
- Input:
-
-
RunExactTimestep(settings)
Perform a direct SSA time step and pre-generate M random numbers
Next Reaction Method
This module performs the Next Reaction Method from Gibson and Bruck [1]. Therefore, it is also called the Gibson and Bruck algorithm.
[1] M.A. Gibson and J. “Bruck Efficient Exact Stochastic Simulation of Chemical Systems with Many Species and Many
Channels”, J. Phys. Chem., 2000, 104, 1876-1889
Written by T.R. Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Speed improvements by M. Moinat.
Last Change: Augustus 20, 2014
-
class stochpy.implementations.NextReactionMethod.NextReactionMethod(File, dir)
Next Reaction Method from Gibson and Bruck 2000 [1].
[1] M.A. Gibson and J. “Bruck Efficient Exact Stochastic Simulation of Chemical Systems with Many Species and Many Channels”, J. Phys. Chem., 2000,104,1876-1889
- Input:
- File filename.psc
- dir /home/user/Stochpy/pscmodels/filename.psc
-
Execute(settings, IsStatusBar=False)
Generates T trajectories of the Markov jump process.
- Input:
-
-
InitialMonteCarloStep()
Monte Carlo step to determine all taus and to create a pqdict indexed priority queue
-
Propensities()
Determines the propensities to fire for each reaction at the current time point. At t=0, all the rate equations are compiled.
-
RunExactTimestep()
Perform a direct SSA time step and pre-generate M random numbers
-
UpdateHeap()
Renews the changed propensities in the priority queue heap.
Optimized Tau-Leaping
This program performs Optimized Explicit Tau-leaping algorithm, which is an approximate version of the exact Stochastic Simulation Algorithm (SSA). Here, an efficient step size selection procedure for the tau-leaping method [1] is used.
[1] Cao. Y, Gillespie D., Petzold L. (2006), “Efficient step size selection for the tau-leaping method”, J.Chem. Phys. 28:124-135
Written by T.R. Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: Augustus 20, 2014
-
stochpy.implementations.TauLeaping.DetermineOrderHOR(rate_vector, reactants)
Determines once the order of each reaction and the highest order of reaction (HOR) for each species.
- Input:
- Rate_vector: (list)
- Reactants: (nested list)
- Output:
-
-
stochpy.implementations.TauLeaping.GetSample(probs)
This function extracts a sample from a list of probabilities.
The ‘extraction chance’ is identical to the probability of the sample.
- Input:
-
- Output:
-
-
stochpy.implementations.TauLeaping.MinPositiveValue(List)
This function determines the minimum positive value
- Input:
-
- Output:
-
-
class stochpy.implementations.TauLeaping.OTL(File, dir)
- Input:
- File filename.psc
- dir /home/user/Stochpy/pscmodels/filename.psc
-
DetermineMethod()
Determines for each time step what to perform: exact of approximate SSA
-
Execute(settings, IsStatusBar=False, epsilon=0.03)
- Generates T trajectories of the Markov jump process.
- settings (python class)
- epsilon [default = 0.03] (float)
-
Execute_K_Reactions()
Perform the determined K reactions
-
GetA0c()
Calculate the total propensities for all critical reactions
-
GetCriticalReactions()
Determines the critical reactions (as a boolean vector)
-
GetG(orders, hors, hor_info)
Determine the G-vector based on options provided in [1], page 6
- Input:
- orders (list)
- hors (list) highest order of reaction for each species
- hor_info
-
GetK()
Determines the K-vector, which describes the number of firing reactions for each reaction.
-
GetMuVar()
Calculate the estimates of mu and var for each species (i)
-
GetTauPrime()
Calculate tau’
-
GetTauPrimePrime()
Calculate Tau’‘
-
RunExactTimestep(settings)
Perform a direct method SSA time step
Delayed Direct Method
This module performs the Delayed Direct Stochastic Simulation Algorithm adapted from Cai (2007) [1]. This algorithm is used to generate exact realizations of the Markov jump process with delays. Of course, the algorithm is stochastic, so these realizations are different for each run.
Only molecule populations are specified. Positions and velocities, such as in Molecular Dynamics (MD) are ignored. This makes the algorithm much faster, because non-reactive molecular collisions can be ignored.
Still, this exact SSA is quite slow, because it insists on simulating every individual reaction event, which takes a lot of time if the reactant population is large. Furthermore, even larger problems arise if the model contains distinct processes operating on different time-scales [2].
[1] Xiaodong Cai (2007), “Exact stochastic simulation of coupled chemical reactions with delays”, J.Phys. Chem. 126:124108
-
class stochpy.implementations.DelayedDirectMethod.DelayedDirectMethod(File, dir)
Delayed Direct Stochastic Simulation Algorithm from Cai (2007) [1].
This algorithm is used to generate exact realizations of the Markov jump process with delays. Of course, the algorithm is stochastic, so these realizations are different for each run.
[1] Xiaodong Cai (2007), “Exact stochastic simulation of coupled chemical reactions with delays”, J.Phys. Chem. 126:124108
- Input:
- File filename.psc
- dir /home/user/Stochpy/pscmodels/filename.psc
-
CheckReactantExhaustion()
Checks wheter a reactant is exhausted. Important if still reactions pending in Tstruct, but no reactant present.
-
CompleteReaction()
Completes a delayed reaction and updates propensities accordingly.
-
Execute(settings, IsStatusBar=False)
Generates T trajectories of the Markov jump process.
- Input:
-
-
GenerateTau()
Generates the waiting time, according to the improved equation 11 of Cai
-
InitiateReaction()
Chooses reaction that will occur at sim_t and updates species accordingly
-
RunExactTimestep()
Calculates a time step of the Direct Method
-
add_delay()
Add delay
Modified Next Reaction Method with delays
This module performs the Next Reaction Method with delay from Anderson [1], Algorithm 7.
Note that the definition of Cai is used for types of delayed reactions: consuming and non-consuming.
[1] David F. Anderson “A modified next reaction mehtod for simulating chemical systems with
time dependent propensities and delays”, J. Phys. Chem., 2007, 127, 214107
Author: M. Moinat, T.R. Maarleveld
Adapted from ‘NextReactionMethod’ by T.R. Maarleveld, Amsterdam, The Netherlands
Last Change: Augustus 20, 2014
-
class stochpy.implementations.DelayedNRM.DelayedNRM(File, dir)
Modified Next Reaction Method from Anderson 2007 [1].
- [1] David F. Anderson “A modified next reaction mehtod for simulating chemical systems with
- time dependent propensities and delays”, J. Phys. Chem., 2007, 127, 214107
- Input:
- File filename.psc
- dir /home/user/Stochpy/pscmodels/filename.psc
-
BuildInits()
Build initials that are necessary to generate a trajectory
-
BuildTaus()
(Re)Calculates and orders taus
-
CheckReactantExhaustion()
Checks wheter a reactant is exhausted after completion and deletes the pending delayed reactions of this reactant.
-
CompleteReaction()
Completes a delayed reaction, depending on consuming or not or not
-
Execute(settings, IsStatusBar=False)
Generates steps of the Markov jump process.
- Input:
-
-
GetTauReaction()
Gets minimum tau, corresponding reaction index and whether it initiates or completes
-
HandleEvents()
Event handling
-
InitiateReaction()
Initiates a reaction based on being delayed (consuming or nonconsuming) or not
-
Propensities()
Determines the propensities to fire for each reaction at the current time point. At t=0, all the rate equations are compiled.
-
RunExactTimestep(settings)
Perform a direct SSA time step
-
UpdateTP()
Update T and P
-
add_delay()
Adds delay time from distribution, specified in DoDelayedStochSim (StochSim.py)
Analysis
This module provides functions for Stochastic Simulation Algorithms Analysis (SSA). Implemented SSAs import this module to perform their analysis. Plotting of time series species, propensities), distributions (species, propensities, distributions), autocorrelations, and autocovariances (species, propensities) is possible.
Written by TR Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: Augustus 06, 2014
-
stochpy.modules.Analysis.AutoCov(s, **kwargs)
Returns the autocovariance of signal s at all lags.
Adheres to the definition
sxx[k] = E{S[n]S[n+k]} = cov{S[n],S[n+k]}
where E{} is the expectation operator, and S is a zero mean process
-
stochpy.modules.Analysis.Autocorrelation(s, **kwargs)
Returns the autocorrelation of signal s at all lags.
Adheres to the definition
rxx[k] = E{S[n]S[n+k]}/E{S*S} = cov{S[n],S[n+k]}/sigma**2
where E{} is the expectation operator, and S is a zero mean process
-
stochpy.modules.Analysis.Binning(x, y, bin_size)
Binning of the PDF. Works only properly if there is a fixed distance
bin_size is the number of indices for binning (23/01/2013)
- Input:
- x list of x-values
- y list of probabilities for each x[i]
- bin_size (integer)
-
stochpy.modules.Analysis.Count(L_data, L_edges)
- Input:
- L_data (list)
- L_edges (list)
-
stochpy.modules.Analysis.CrossCov(x, y, axis=-1, all_lags=False, debias=True)
Returns the crosscovariance sequence between two ndarrays.
This is performed by calling fftconvolve on x, y[::-1]
x: ndarray
y: ndarray
axis: time axis
all_lags: {True/False}
whether to return all nonzero lags, or to clip the length of s_xy
to be the length of x and y. If False, then the zero lag covariance
is at index 0. Otherwise, it is found at (len(x) + len(y) - 1)/2
- debias: {True/False}
- Always removes an estimate of the mean along the axis, unless
told not to.
cross covariance is defined as
sxy[k] := E{X[t]*Y[t+k]}, where X,Y are zero mean random processes
-
class stochpy.modules.Analysis.DoPlotting(species_labels, rate_labels, plotnum=1)
This class initiates the plotting options.
- Input:
- species_labels (list) [S1,S2, ..., Sn]
- rate_labels (list) [R1, R2, ..., Rm]
-
Autocorrelations(lags, data, species2plot, trajectory_index, linestyle, marker, colors, title, xlabel, ylabel, IsLegend, legend_location)
- Input:
- lags
- data (array)
- datatype2plot (list)
- L_labels (list)
- trajectory_index (integer)
- linestyle (string)
- linewidth (float)
- marker string)
- colors (list)
- title (string)
- xlabel (string)
- ylabel (string)
- IsLegend (boolean)
-
AverageDistributions(L_means, L_stds, nstd, datatype2plot, L_labels, linestyle, linewidth, marker_, colors, title, xlabel, ylabel, IsLegend, legend_location)
Plots the average and standard deviation
- Input:
- L_means (nested list)
- L_stds (nested list)
- nstd (float)
- L_labels (list)
- linestyle (string)
- linewidth (float)
- marker_ (string)
- colors (list)
- title (string)
- xlabel (string)
- ylabel (string)
- IsLegend (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
AverageDistributionsCI(L_means, L_stds, nstd, datatype2plot, L_labels, colors, title, xlabel, ylabel, IsLegend, legend_location)
-
AverageTimeSeries(L_means, L_stds, L_time, nstd, datatype2plot, L_labels, linestyle, linewidth, marker_, colors, title, xlabel, ylabel, IsLegend, legend_location)
AverageSpeciesTimeSeries(L_means,L_stds,L_time,nstd,datatype2plot,L_labels,linestyle,linewidth,marker_,colors,title,xlabel,ylabel,IsLegend,legend_location)
Plots the average and standard deviation of datatype on a regular grid
- Input:
- L_means (nested list)
- L_stds (nested list)
- L_time (list)
- nstd (float)
- datatype2plot (list)
- L_labels (list)
- L_time (list)
- linestyle (string)
- linewidth (float)
- marker_ (string)
- colors (list)
- title (string)
- xlabel (string)
- ylabel (string)
- IsLegend (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
Distributions(distributions, datatype2plot, trajectory_index, linestyle, colors, title, xlabel, ylabel, IsLegend, legend_location, legend_location, bin_size)
Plots the distributions of species and/or propensities
- Input:
- distributions (nested list)
- datatype2plot (list)
- L_labels (list)
- trajectory_index (integer)
- linestyle (string)
- linewidth (float)
- colors (list)
- title (string)
- xlabel (string)
- ylabel (string)
- IsLegend (boolean)
- legend_location [default = ‘upper right’] (string/integer)
- bin_size (string)
-
ResetPlotnum()
Reset figure numbers if trajectories > 1
-
TimeSeries(data, n_points2plot, datatype2plot, trajectory_index, linestyle, marker, colors, title)
Tracks the propensities and/or species over time
- Input:
- data (array)
- n_points2plot (integer)
- datatype2plot (list)
- L_labels (list)
- trajectory_index (integer)
- linestyle (string)
- linewidth (float)
- title (string)
- xlabel (string)
- ylabel (string)
- IsLegend (boolean)
-
WaitingtimesDistributions(D_waiting_times, rates2plot, trajectory_index, linestyle, linewidth, marker, colors, title, xlabel, ylabel, IsLegend, legend_location)
Plots the waiting times for each reaction in the model. Makes use of ObtainWaitingtimes to derive the waiting times out of the SSA output.
- Input:
- D_waiting_times (dict)
- rates2plot (list)
- trajectory_index (integer)
- linestyle (string)
- linewith (float)
- marker (string)
- colors (list)
- title (string)
- xlabel (string)
- ylabel (string)
- IsLegend (boolean)
- legend_location [default = ‘upper right’] (string/integer)
-
stochpy.modules.Analysis.FFTconvolve(in1, in2, mode='full', axis=None)
Convolve two N-dimensional arrays using FFT. See convolve.
-
stochpy.modules.Analysis.GetAverageResults(L_regular_grid)
Gets the averaged output of multiple trajectories
- Input:
- L_regular_grid (nested list)
-
stochpy.modules.Analysis.GetDataDistributions(L_sim_output, L_names)
Get distributions, means, standard deviations, and the (raw) moments
Input:
- L_sim_output (list)
- L_names (list)
Output:
- L_probability_mass
- D_means
- D_stds
- D_moments
-
stochpy.modules.Analysis.LogBin(data, factor)
Function that creates log bins
- Input:
- L_data (list)
- factor (float) determines the width of the bins
- Output:
- L_x (list)
- L_y (list)
- nbins (integer)
-
stochpy.modules.Analysis.ObtainWaitingtimes(data_stochsim, L_reactions)
This function extracts the waiting times for each reaction of the model from the used SSA output.
- Input:
- data_stochsim (python data object) that stores all simulation data
- L_reactions (list)
- output:
-
Note: It is impossible to use this function in combination with the Tau-leaping method, because the Tau-Leaping results are not exact!
-
stochpy.modules.Analysis.RemoveBias(x, axis)
Subtracts an estimate of the mean from signal x at axis
-
stochpy.modules.Analysis.getDataForTimeSimPlot(data, n_points2plot = 100000)
- Input:
- Arr_data (numpy array)
- n_points2plot [default = 10000] (integer)
PySCeS MDL Parser
The PySCeS parser is used to import a model written in the MDL of PySCeS. Further, all required input do to stochastic simulations is build.
Written by T.R. Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: Augustus 06, 2014
-
class stochpy.modules.PyscesMiniModel.Event(name, mod)
Event’s have triggers and fire EventAssignments when required.
Ported from Core2.
-
assignments = None
-
code_string = None
-
delay = 0.0
-
formula = None
-
mod = None
-
piecewises = None
-
reset()
-
setAssignment(var, formula)
-
setTrigger(formula, delay=0.0)
-
state = False
-
state0 = False
-
symbols = None
-
trigger = None
-
xcode = None
-
class stochpy.modules.PyscesMiniModel.EventAssignment(name, mod)
Event assignments are actions that are triggered by an event.
Ported from Core2 to build an event handling framework fro PySCeS
-
code_string = None
-
evaluateAssignment()
-
formula = None
-
mod = None
-
piecewises = None
-
setFormula(formula)
-
setVariable(var)
-
symbols = None
-
variable = None
-
xcode = None
-
class stochpy.modules.PyscesMiniModel.Function(name, mod)
Function class ported from Core2 to enable the use of functions in PySCeS
-
addFormula(formula)
-
argsl = None
-
code_string = None
-
formula = None
-
functions = None
-
mod = None
-
piecewises = None
-
setArg(var, value=None)
-
symbols = None
-
value = None
-
xcode = None
-
class stochpy.modules.PyscesMiniModel.IntegrationStochasticDataObj
This class is specifically designed to store the results of a stochastic time simulation
It has methods for setting the Time, Labels, Species and Propensity data and
getting Time, Species and Rate (including time) arrays. However, of more use:
- getOutput(*args) feed this method species/rate labels and it will return
an array of [time, sp1, r1, ....]
- getDataAtTime(time) the data generated at time point “time”.
- getDataInTimeInterval(time, bounds=None) more intelligent version of the above
returns an array of all data points where: time-bounds <= time <= time+bounds
-
HAS_PROPENSITIES = False
-
HAS_SPECIES = False
-
HAS_SPECIES_CONCENTRATIONS = False
-
HAS_TIME = False
-
HAS_VOLUME = False
-
HAS_WAITINGTIMES = False
-
HAS_XDATA = False
-
IS_VALID = True
-
TYPE_INFO = 'Stochastic'
-
getAllSimData(lbls=False)
Return an array of time + all available simulation data
- Input:
- lbls [default=False] return only the data array or (data array, list of labels)
-
getDataAtTime(time)
Return all data generated at “time”
- Input:
- time the required exact time point
-
getDataInTimeInterval(time, bounds=None)
Returns an array of all data in interval: time-bounds <= time <= time+bounds
where bound defaults to step size
- Input:
- time the interval midpoint
- bounds [default=None] interval half span defaults to step size
-
getPropensities(lbls=False)
Return time+propensity array
- Input:
- lbls [default=False] return only the time+propensity array or optionally both the data array and a list of column label
-
getSimData(*args, **kwargs)
Feed this method species/xdata labels and it will return an array of [time, sp1, ....]
- Input:
- ‘speces_l’, ‘xdatal’ ...
- lbls [default=False] return only the data array or (data array, list of labels)
-
getSpecies(lbls=False)
Return an array of time+species
Input:
- lbls [default=False] return only the time+species array or optionally both the data array and a list of column label
-
getSpeciesConcentrations(lbls=False)
Return an array of time+species concentrations
Input:
- lbls [default=False] return only the time+species array or optionally both the data array and a list of column label
-
getTime(lbls=False)
Return the time vector
- Input:
- lbls [default=False] return only the time array or optionally both the time array and time label
-
getVolume()
Return an array of time+volume
-
getWaitingtimes(lbls=False, traj=[])
Return waiting times, time+waiting_time array
- Input:
- lbls [default=False] return only the time+waiting_time array or optionally both the data array and a list of column label
- traj [default=[0]] return the firs or trajectories defined in this list
-
getXData(lbls=False)
Return time+xdata array
Input:
- lbls [default=False] return only the time+xdata array or optionally both the data array and a list of column label
-
propensities = None
-
propensities_distributions = None
-
propensities_labels = None
-
setFiredReactions(fired_reactions)
Set the reactions that fired
- Input:
-
-
setLabels(species)
Set the species
- Input:
- species a list of species labels
-
setPropensities(propensities, lbls=None)
Sets an array of propensities.
- Input:
-
-
setPropensitiesDist(distributions, means, stds, moments)
setPropensitiesDist stuff for the determination of distributions
- Input:
- distributions (list)
- means (dictionary)
- stds (dictionary)
- moments (dictionary)
-
setPropensitiesLabels(labels)
- Input:
-
-
setSimulationInfo(timesteps, endtime, simulation_trajectory)
set Simulation Information
- Input:
- timesteps (integer)
- endtime (float)
- simulation_trajectory (integer)
-
setSpecies(species, lbls=None)
Set the species array
- Input:
- species an array of species vs time data
- lbls [default=None] a list of species labels
-
setSpeciesConcentrations(extracellular=[])
Set the species concentrations array
-
setSpeciesDist(distributions, means, stds, moments)
setSpeciesDist stuff for the determination of distributions
- Input:
- distributions (list)
- means (dictionary)
- stds (dictionary)
- moments (dictionary)
-
setTime(time, lbl=None)
Set the time vector
- Input:
- time a 1d array of time points
- lbl [default=None] is “Time” set as required
-
setVolume(volume)
Set the volume array
- Input:
- species an array of volume vs time data
-
setWaitingtimes(waiting_times, lbls=None)
Set the waiting_times this data structure is not an array but a nested list of: waiting time log bins per reaction per trajectory.
waiting_times = [traj_1, ..., traj_n]
traj_1 = [wt_J1, ..., wt_Jn] # in order of SSA_REACTIONS
wt_J1 = (xval, yval, nbin)
xval =[x_1, ..., x_n]
yval =[y_1, ..., y_n]
nbin = n
- Input:
- waiting_times a list of waiting times
- lbls [default=None] a list of matching reaction names
-
setWaitingtimesMeans(waiting_times, rate_names)
set waiting times means
- Input:
- waiting_times (dictionary)
-
setWaitingtimesStandardDeviations(waiting_times, rate_names)
set waiting times standard deviations
- Input:
- waiting_times (dictionary)
-
setXData(xdata, lbls=None)
Sets an array of extra simulation data
Input:
- xdata an array of xdata vs time
- lbls [default=None] a list of xdata labels
-
species = None
-
species_distributions = None
-
species_labels = None
-
time = None
-
time_label = 'Time'
-
waiting_times = None
-
waiting_times_labels = None
-
xdata = None
-
xdata_labels = None
-
class stochpy.modules.PyscesMiniModel.NewCoreBase
Core2 base class, needed here as we use Core2 derived classes in PySCeS
-
get(attr)
Return an attribute whose name is str(attr)
-
getName()
-
name = None
-
setName(name)
-
class stochpy.modules.PyscesMiniModel.NumberBase
Derived Core2 number class.
-
getValue()
-
setValue(v)
-
value = None
-
value_initial = None
-
class stochpy.modules.PyscesMiniModel.PySCeS_Connector(ModelFile, ModelDir, IsNRM=False, IsDelayed=False, IsMolecularNRM=False)
-
BuildDependencyGraph()
Function which builds a dependency graph
-
BuildN()
Generates the stoichiometric matrix N from the parsed model description. Returns a stoichiometric matrix (N) as a NumPy array
-
BuildN_react_prod()
Generates the reactant, product and net stoichiometric matrix N from the parsed model description.
Also: generates list of reactant and product indices for each reaction.
Returns three stoichiometric matrices (N) as NumPy arrays
-
BuildPropensityCodes(propensities=None)
Makes a list of compiled propensity codes for each reaction. If a reaction fires, its code is executed.
- Input:
- propensities: optional argument for providing the propensities that should be pre-compiled. If none, self.propensities is used.
-
BuildReactions()
Extract information out of each reaction, such as what are the reagents/reactants and which parameter is used for that particular reaction.
-
BuildSpeciesAffects()
Builds dependencies specifying for each species in which reactions they are reactants and/or modifiers (i.e. occuring in rate equation).
Used for the Molecular NRM.
-
BuildX()
Builds the initial concentrations of all species (X).
-
DetermineAffects()
Determine the affects for each reaction
-
class stochpy.modules.PyscesMiniModel.PyscesInputFileParser(File, dir, output_dir=None)
This class contains the PySCeS model loading
-
InitialiseEvents()
Initialise Events
-
InitialiseInputFile()
Parse the input file associated with the PySCeS model instance and assign the basic model attributes
-
ModelDir = None
-
ModelFile = None
-
ModelOutput = None
-
N = None
-
class stochpy.modules.PyscesMiniModel.RegularGridDataObj
This class is specifically designed to store the results of a stochastic time simulation on fixed time intervals
It has methods for setting the Time, Labels, Species and Propensity data and
getting Time, Species and Rate (including time) arrays. However, of more use:
- getOutput(*args) feed this method species/rate labels and it will return
an array of [time, sp1, r1, ....]
- getDataAtTime(time) the data generated at time point “time”.
- getDataInTimeInterval(time, bounds=None) more intelligent version of the above
returns an array of all data points where: time-bounds <= time <= time+bounds
-
HAS_AVERAGE_PROPENSITIES_DISTRIBUTIONS = False
-
HAS_AVERAGE_SPECIES_DISTRIBUTIONS = False
-
HAS_PROPENSITIES = False
-
HAS_PROPENSITIES_AUTOCORRELATIONS = False
-
HAS_PROPENSITIES_AUTOCOVARIANCES = False
-
HAS_SPECIES = False
-
HAS_SPECIES_AUTOCORRELATIONS = False
-
HAS_SPECIES_AUTOCOVARIANCES = False
-
HAS_SPECIES_CONCENTRATIONS = False
-
HAS_TIME = False
-
HAS_VOLUME = False
-
getSpecies(lbls=False)
Return an array of time+species
Input:
- lbls [default=False] return only the time+species array or optionally both the data array and a list of column label
-
getSpeciesConcentrations(lbls=False)
Return an array of time+species concentrations
Input:
- lbls [default=False] return only the time+species array or optionally both the data array and a list of column label
-
getTime(lbls=False)
Return the time vector
- Input:
- lbls [default=False] return only the time array or optionally both the time array and time label
-
getVolume()
Return an array of time+volume
-
propensities = None
-
propensities_means = None
-
propensities_standard_deviations = None
-
setPropensities(propensities)
Sets an array of propensities.
- Input:
-
-
setPropensitiesAutocorrelations(auto_correlations, lbls=None)
Set the autocorrelations ***
- Input:
- auto_correlation a list of auto correlations
- lbls [default=None] a list of matching reaction names
-
setPropensitiesAutocovariances(auto_covariances, lbls=None)
Set the autocovariances ***
- Input:
- auto_correlation a list of auto covariances
- lbls [default=None] a list of matching reaction names
-
setPropensitiesDistributionAverage(mean, std)
Set means and stds of species data
- Input:
-
-
setSpecies(species, lbls=None)
Set the species array
- Input:
- species an array of species vs time data
- lbls [default=None] a list of species labels
-
setSpeciesAutocorrelations(auto_correlations, lbls=None)
Set the autocorrelations ***
- Input:
- auto_correlation a list of auto correlations
- lbls [default=None] a list of matching reaction names
-
setSpeciesAutocovariances(auto_covariances, lbls=None)
Set the autocorrelations ***
- Input:
- auto_correlation a list of auto correlations
- lbls [default=None] a list of matching reaction names
-
setSpeciesConcentrations(extracellular=[])
Set the species concentrations array
-
setSpeciesDistributionAverage(mean, std)
Set means and stds of species data
- Input:
-
-
setTime(time, lbl=None)
Set the time vector
- Input:
- time a 1d array of time points
- lbl [default=None] is “Time” set as required
-
setVolume(volume)
Set the volume array
- Input:
- species an array of volume vs time data
-
species = None
-
species_autocorrelations = None
-
species_autocorrelations_means = None
-
species_autocorrelations_standard_deviations = None
-
species_means = None
-
species_standard_deviations = None
-
time = None
Copyright (C) 2004-2014 B.G. Olivier
Brett G. Olivier (bgoli@users.sourceforge.net)
Triple-J Group for Molecular Cell Physiology
Stellenbosch University, South Africa.
Permission to use, modify, and distribute this software is given under the
terms of the PySceS (BSD style) license. See LICENSE.txt that came with
this distribution for specifics.
pys
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
Brett G. Olivier
Adapted by T.R. Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: Augustus 20, 2014
Demo of StochPy Functionalities
Written by T.R. Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: Augustus 06, 2014
-
class stochpy.modules.StochPyDemo.Demo(DoSimulations=True)
-
Demo1()
Use the Immigration-Death model for doing basic simulations with the Direct method, some plotting and exportation of results
-
Demo10()
Demo of StochPy for doing (preprogrammed) Sequential simulations
-
Demo11()
StochPy Demo which illustrates delayed SSAs
-
Demo2()
Use the Immigration-Death model for a stochastic simulation with multiple trajectories
-
Demo3()
Use the Immigration-Death model to demonstrate probability density functions
-
Demo4()
Use Birth-Death model to illustrate averaging multiple simulations
-
Demo5()
Use Decaying-Dimerizing model to illustrate performance differences between different stochastic simulation algorithms
-
Demo6()
Demo of StochPy’s next reaction method handling events
-
Demo7()
Demo of StochPy’s first reaction method handling events
-
Demo8()
Demo of StochPy’s direct method for supporting events
-
Demo9()
Demo of StochPy’s direct method for handling volume and HasOnlySubstanceUnits
-
DoDemoSimulations()
StochPy Utils
Module that contains functions that are created by the users of stochpy. New functions will be added in the next releases of stochpy.
Written by T.R. Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: Augustus 20, 2014
-
stochpy.modules.StochPyUtils.GetAnalyticalPDF(kon, koff, kdeg, ksyn)
Get the analytical probability density function. The analytical solution is taken from Sharezaei and Swain 2008 - Analytical distributions for stochastic gene expression
-
stochpy.modules.StochPyUtils.GetAnalyticalWaitingtimes(kon, koff, ksyn)
Get analytical waiting times
-
class stochpy.modules.StochPyUtils.Utils
-
doExample1()
Immigration Death example (available at http://stochpy.sourceforge.net/examples.html)
-
doExample2()
SBML events and Interpolation example (available at http://stochpy.sourceforge.net/examples.html)
-
doExample3()
Burstmodel example (available at http://stochpy.sourceforge.net/examples.html)
-
doExample4()
Second Burstmodel example (available at http://stochpy.sourceforge.net/examples.html)
-
doExample5()
Protein turnover example with and without cell division (available at http://stochpy.sourceforge.net/examples.html)
-
stochpy.modules.StochPyUtils.doSequentialSim(smod, n_generations, cell_division_times)
Model protein synthesis subject to cell division
Written by T.R. Maarleveld, Amsterdam, The Netherlands
E-mail: tmd200@users.sourceforge.net
Last Change: Augustus 06, 2014
-
class stochpy.modules.SBML2PSC.SBML2PSC(sbmlfile, sbmldir=None, pscfile=None, pscdir=None)
Module that converts SBML models into PSC models if libxml and libsbml are installed
Usage:
>>> converter = stochpy.SBML2PSC()
>>> converter.SBML2PSC(‘Burstmodel.xml’,’/home/user/Stochpy/pscmodels/’)