If you wish to create a new model, the file name to be associated with that model is passed:
Valid operands are either literal numbers (which will be promoted to double precision internally if need be), or model values which must either be a metabolite name, a parameter name, or ``Time''. The use of reaction names in rate equations is not permitted. Like metabolites, parameters are not declared in advance. They are brought into existence by being referred to in a rate equation, if they do not appear elsewhere in a stoichiometry statement they are treated as parameters. Once the model is loaded, external metabolites become parameters, and their identifier is unchanged (i.e. the ``x_'' remains).
Operator Meaning Comment ** power x**y == xy * multiplication / division + addition - subtraction/negation unary negation acts as you would expect, e.g. x *-y is legal () parenthesis foo(bar) function bar is comma separated argument of possibly zero length. More about functions below
ScrumPy also provides a default kinetic for reactions: If in instead of a rate equation as described above, the reaction stoichiometry is followed by aFunctions in rate equationsScrumPy rate equations can contain invocations of any function available via the standard C header files math.h and stdlib.h. These should be treated with some caution however, as ScrumPy passes these to the C compiler without any checking. There are three possible outcomes if you make a mistake with a function invocation. They are in increasing order of seriousness:If all this looks a bit alarming, don't use functions in rate equations. They are anyway rarely, if ever, needed in realistic rate laws.
- The C compiler will throw it out. In this case you will get a slightly verbose error message, and the resulting model will be unusable. (see section 3.3.6)
- The Python interpreter will crash (taking Idle, and all its open editor windows etc. with it)
- ScrumPy will generate (unpredictably) incorrect results.
~
(tilde) the reaction will be assigned mass action kinetics, with rate and equilibrium constants of unity. This is mainly useful for structural modelling when kinetics are ignored.Clicking the ``Simulate'' item in the ScrumPy menu creates a Simulation tool as shown in figure 4.1. This is as simple to use as it looks: set the desired step size and number of steps and click on the ``OK'' button, and the model will be simulated accordingly. The Simulation tool can be removed by closing the window, or by clicking the cancel button. This simply destroys the window, and has no effect on the state of the model. It is possible to have as many simulation tools active at once as you wish, but there is probably not a lot of benefit to be gained from doing so (prizes for the best suggestion as to why this might be useful !).
The Saver tool, figure 4.4(A) allows arbitrary data associated with the model to be saved for posterity. Multiple values are selected from the list on the right hand side, and a save mode selected from the buttons on the left hand side. If ``dynamic'' mode is selected the saver will record data at every simulation time-point, if ``static'' is selected then the Saver updates at whenever a steady-state is calculated.
There are other variations on the theme of getting and setting multiple values, these are GetRescue(), SetRescue(), GetState(), SetState(), and GetStateSaver(). They will all be documented fully real soon.Elements in vectorsThe GetVec() and SetVec() were originally intended for situations in which the ordering within the vector is unimportant, however there may be cases in which the identities of individual elements in a vector is desired. To this end the GetVecNames() method is provided:
>>> print m.GetVecNames(ScrumPy.Conc)
The return from GetVecNames() is a list of strings corresponding to model variables, in the same order in which the values of those variables occur in the list returned from GetVec(), so
>>> MetNames = m.GetVecNames(ScrumPy.Conc)
>>> MetVals = m.GetVec(ScrumPy.Conc)
>>> MetVals[MetNames.index("B")]
Is equivalent to simply:
>>> m["B"]
More about numerical errorsIn a batch environment strings describing the errors are not a great deal of use, especially if you intend to take some kind of corrective action. To this end the method model.LastErr() returns an integer describing the most recent problem, as described below.
m.LastErr() m.ErrorMsg() Meaning 0 ``No Error'' No error 1 ``Negative concentration'' -ve concentration(s) encountered during simulation or steady state determination. 2 ``Requested tolerance not achieved'' Unable to determine steady state to tolerance requested in the model (default is 10-6). 3 ``Solver can't get steady state with these start conditions'' More serious than above, bad choice of initial metabolite values, problem with model definition, or possibly (eek !) a bug. 4 ``Simulation can't proceed from this position'' Problems in the time course simulator. Most likely reason is unitialised parameters or a very large or stiff model. 5 ``Out of memory'' If you see this I'll buy you a beer. 6 ``Couldn't open file'' Not currently used, if you see this it's a bug 7 ``No more data'' See 6 8 ``Model not defined'' No attempt has been made to load the model <0 or >8 !! CRASH !! You have found a bug
\n
'.
>>> ss = m.EnzSubsets() # get the subsets >>> len(ss) # how many ? 21 >>> print len(ss.DeadSSs()), len(ss.IrrevSSs()), len(ss.RevSSs()) #how many dead, ireversible and reversible ? 0 11 10 >>> revs = ss.RevSSs() # get the keys of reversible subsets >>> for r in revs: # print a nicely formatted list if len(ss[r]) >1: # of reversible subsets with more print r, " :\t", # than one reaction for e in ss[r]: print e[0], "\t", # print the name only print SubSet9 : PFP UGPase NDPK SubSet1 : Pexp AT
Method Behaviour PosFlux(n) modes for which reaction n carries a positive flux NoFlux(n) modes for which n carries no flux NegFlux(n) modes for which n carries a negative flux Consumes(m) modes which consume metabolite m Unused(m) modes which have no net effect on m Produces(m) modes which produce m
Action Row Col Note Get GetRow(idx) SetCol(idx) idx is string or integer Set SetRow(idx, seq) SetCol(idx,seq) sequence is of consistent length
Table 7.1: ScrumPy prerequisites. Most of these should come with you Linux distro, so check your CDs before following these URLs. Also note that these URLs are for the modules homepages. If you are running an RPM based Linux have a try http://www.rpmfind.org .
Module Provides Optional Download Numeric Numerical functions No http://sourceforge.net/ projects/numpy Ply Pasrer functions No (but distributed with ScrumPy) http://systems.cs.uchicago.edu/ply/ Gnuplot Interface to Gnuplot plotter Yes http://monsoon.harvard.edu/ mhagger/Gnuplot/Gnuplot.html Gnuplot The Gnuplot program Yes http://www.gnuplot.org stats statistical functions for DataSets Yes http://www.nmr.mgh.harvard.edu/ Neural_Systems_Group/gary/python/ statstest.zip Scientific Non-linear least squares in DataSets Yes http://starship.python.net/ crew/hinsen/scientific.html Pmw Monitor plotter Yes http://pmw.sourceforge.net/ Blt Graph function for Pmw yes ftp://ftp.tcltk.com/pub/blt/ BLT2.4.tar.gz
This document was translated from LATEX by HEVEA.