PySCeS Module documentation¶
PyscesUtils¶
The PyscesUtils module holds a collection of methods of general use such as timers and array export fucntionality that can be accessed as pysces.write.
- pysces.PyscesUtils.ConvertFileD2U(Filelist)[source]¶
Converts a [Filename] from rn to n inplace no effect if the line termination is correct
Filelist a file or list of files to convert
- pysces.PyscesUtils.ConvertFileU2D(Filelist)[source]¶
Converts a [Filename] from n to rn inplace no effect if the line termination is correct:
Filelist a file or list of files to convert
- class pysces.PyscesUtils.TimerBox[source]¶
A timer “container” class that can be used to hold user defined timers
- normal_timer(name)[source]¶
Creates a normal timer method with <name> in the TimerBox instance. Normal timers print the elapsed time since creation when called.
name the timer name
- reset_step(name)[source]¶
Reset the number of steps of timer <name> in the TimerBox to zero
name the step timer whose steps should be reset
- class pysces.PyscesUtils.WriteOutput[source]¶
This code is adapted from:
CBMPy: CBTools module
Constraint Based Modelling in Python (http://cbmpy.sourceforge.net) Copyright (C) 2009-2017 Brett G. Olivier, VU University Amsterdam, Amsterdam, The Netherlands
- exportArray2CSV(arr, fname)[source]¶
Export an array to fname.csv
arr the an array like object
fname the output filename
sep [default=’,’] the column separator
- exportArray2TXT(arr, fname)[source]¶
Export an array to fname.txt
arr the an array like object
fname the output filename
sep [default=’,’] the column separator
- exportLabelledArray(arr, names, fname, sep=',', sformat='%f')[source]¶
Write a 2D array type object to file
arr the an array like object
names the list of row names
fname the output filename
sep [default=’,’] the column separator
format [default=’%s’] the output number format
- exportLabelledArray2CSV(arr, names, fname)[source]¶
Export an array with row names to fname.csv
arr the an array like object
names the list of row names
fname the output filename
- exportLabelledArray2TXT(arr, names, fname)[source]¶
Export an array with row names to fname.txt
arr the an array like object
names the list of row names
fname the output filename
- exportLabelledArrayWithHeader(arr, names, header, fname, sep=',', format='%f')[source]¶
Export an array with row names and header
arr the an array like object
names the list of row names
header the list of column names
fname the output filename
sep [default=’,’] the column separator
format [default=’%s’] the output number format
appendlist [default=False] if True append the array to fname otherwise create a new file
- exportLabelledArrayWithHeader2CSV(arr, names, header, fname)[source]¶
Export an array with row names and header to fname.csv
arr the an array like object
names the list of row names
header the list of column names
fname the output filename
- exportLabelledArrayWithHeader2TXT(arr, names, header, fname)[source]¶
Export an array with row names and header to fname.txt
arr the an array like object
names the list of row names
header the list of column names
fname the output filename
- exportLabelledLinkedList(arr, fname, names=None, sep=',', format='%s', appendlist=False)[source]¶
Write a 2D linked list [[…],[…],[…],[…]] and optionally a list of row labels to file:
arr the linked list
fname the output filename
names the list of row names
sep [default=’,’] the column separator
format [default=’%s’] the output number format
appendlist [default=False] if True append the array to fname otherwise create a new file
PyscesPlot2¶
PyscesPlot2 is a new graphics susbsystem for PySCeS which will include a Unified Plotting Interface which can take advantage of different plotting backends via a common user interface.
- class pysces.PyscesPlot2.GnuPlotUPI(work_dir=None, gnuplot_dir=None)[source]¶
PySCeS/GnuPlot is reborn, leaner and meaner than ever before. This class enables plotting with GnuPlot via a subprocess link:
work_dir optional argument setting directory for dat file(s)
gnuplot_dir optional argument specifying the location of pgnuplot.exe (win32) or gnuplot
GnuPlot backend to the Unified Plotting Interface.
- CommonStyleDefs = {'lines': 'w l', 'points': 'w p'}¶
- DATF_FORMAT = '%.8e'¶
- PAUSE_TIME = 0.1¶
- Terminals = {'png': 'medium size 800,600', 'windows': '', 'x11': ''}¶
- export(name, directory=None, outtype='png')[source]¶
Export the current plot as a <format> file.
filename the filename
directory optional (default = current working directory)
outtype the file format (default=’png’).
Currently only PNG is guaranteed to be available in all interfaces.
- g_file_write_array(arr, dfmt=None)[source]¶
Write a normal (2D) dataset to temp file. Dumps the array to file using the format:
arr the array (r>0, c>1)
fmt default ‘%.8e’
- g_file_write_array3D(arr, yaxis=1, dfmt=None)[source]¶
Write a GnuPlot format 3D dataset. The yaxis argument specifies the column that should be used to split the dataset into GnuPlot slices.
arr the array (r>1, c>2)
fmt default ‘%.8e’
yaxis default 1
- plot(data, x, y, title='', format='w l')[source]¶
Plot a single line data[y] vs data[x] where:
data the data array
x x column index
y y column index
title is the line key
format is the GnuPlot format string (default=’w l’)
Format can also be the CommonStyle ‘lines’ or ‘points’.
- plotLines(data, x, y=[], titles=[], formats=['w l'])[source]¶
Plot a multiple lines data[y1, y2, ] vs data[x] where:
data the data array
x x column index
y is a list of line indexes, if empty all of y not including x is plotted
titles is a list of line keys if empty Line1, Line2, Line3 is used
formats is a list (per line) of GnuPlot format strings (default=’w l’).
If formats only contains a single item, this format is used for all lines and can also be the CommonStyle ‘lines’ or ‘points’.
- replotAndWait(seconds=0.5)[source]¶
Replot the current GnuPlot plot and wait default (seconds = 0.5) or until enter is pressed (seconds = -1)
- save(name, directory=None, dfmt=None)[source]¶
Save the last plot as a GnuPlot file name.plt which references name.dat.
name the name of the GnuPlot plt and and datafile
directory (optional) the directory to use (defaults to working directory)
dfmt is ignored and uses the value of self.DATF_FORMAT
- setAxisLabel(axis, label='')[source]¶
Set the axis label:
axis = x, y, z, xy, xz, yz, zyx
label = string (default=’’)
Called with only the axis argument clears the axis label.
- setDataFileNumberFormat(format='%.8e')[source]¶
Sets the format string for data written to file
format format string (default=’%.8e’)
- setGraphTitle(title='PySCeS Plot')[source]¶
Set the graph title, unset if title argument is None
title (string, default=’PySCeS Plot’) the graph title
- setKey(value=False)[source]¶
Enable or disable the current plot key, no arguments removes key.
value boolean (default = False)
- setOrigin(xpos=0, ypos=0)[source]¶
Set the origin (lower left corner) of the next plot. Uses GnuPlot screen coordinates. If no arguments are supplied reset origin to 0,0.
xpos of next plot (default = 0)
ypos of next plot (default = 0)
- setRange(axis, min=None, max=None)[source]¶
Set axis range where:
axis = x, y, z, xy, xz, yz, zyx
min = range(s) lower bound (default=None) autoscale
max = range(s) upper bound (default=None) autoscale
If only the axis argument is provided, GnuPlot will autoscale the ranges to the data.
- setSize(width=1.0, height=1.0)[source]¶
Set the size of the next plot relative to the GnuPlot canvas (e.g. screen) size which is defined to be 1. For example if
width = height = 0.5the plot is 1/4 the size of the viewable canvas. If no arguments are supplied reset size to 1,1.width of next plot (default = 1.0)
height of next plot (default = 1.0)
- setSizeAndOrigin(width=1, height=1, xpos=0, ypos=0)[source]¶
Set the size and origin of the next plot. If no arguments are supplied, reset the size to 1,1 and origin to 0.0
width of next plot (default = 1.0)
height of next plot (default = 1.0)
xpos of next plot (default = 0)
ypos of next plot (default = 0)
- splot(data, x, y, z, titles='', format='w l')[source]¶
Plot a surface data[z] vs data[y] vs data[x] where:
data the data array
x x column index
y y column index
z z column index
titles is the surface key
format is the GnuPlot format string (default=’w l’)
Format can also be the CommonStyle ‘lines’ or ‘points’.
- splotSurfaces(data, x, y, z=[], titles=[], formats=['w l'])[source]¶
Plot data[z1, z2, ] vs data[y] vs data[x] where:
data the data array
x x column index
y y column index
z list of z column indexes, if empty all of z not including x, y are plotted
titles is a list of surface keys, if empty Surf1, Surf2, Surf3 is used
formats is a list (per line) of GnuPlot format strings (default=’w l’).
If formats only contains a single item, this format is used for all surface and can also be the CommonStyle ‘lines’ or ‘points’.
- class pysces.PyscesPlot2.MatplotlibUPI(work_dir=None, backend=None)[source]¶
Refactored Matplotlib backend to the Unified Plotting Interface
work_dir (optional) working directory
- CommonStyleDefs = {'lines': '-', 'points': 'o'}¶
- MAX_OPEN_WINDOWS = 10¶
- export(name, directory=None, outtype='png')[source]¶
Export the current plot as a <format> file.
filename the filename
directory optional (default = current working directory)
outtype the file format (default=’png’).
Currently only PNG is guaranteed to be available in all interfaces.
- hold(hold=False)[source]¶
Enable plot holding where each new graph is plotted on top of the previous one.
hold boolean (default = False)
- plot(data, x, y, title='', format='-')[source]¶
Plot a single line data[y] vs data[x] where:
data the data array
x x column index
y y column index
title is the line key
format is the Matplotlib format string (default=’-‘)
Format can also be the CommonStyle ‘lines’ or ‘points’.
- plotLines(data, x, y=[], titles=[], formats=['-'])[source]¶
Plot a multiple lines data[y1, y2, ] vs data[x] where:
data the data array
x x column index
y is a list of line indexes
titles is a list of line keys
formats is a list (per line) of Matplotlib format strings.
If formats only contains a single item, this format is used for all lines and can also be the CommonStyle ‘lines’ or ‘points’.
- pyplot = None¶
- save(name, directory=None, dfmt='%.8e')[source]¶
Save the plot data to
filename the filename
directory optional (default = current working directory)
dfmt the data format string (default=’%.8e’)
- setAxisLabel(axis, label='')[source]¶
Set the axis label:
axis = x, y, z, xy, xz, yz, zyx
label = string (default=’’)
Called with only the axis argument clears the axis label.
- setGraphTitle(title='PySCeS Plot')[source]¶
Set the graph title, unset if title=None
title (string, default=’PySCeS Plot’) the graph title
- class pysces.PyscesPlot2.PlotBase[source]¶
Abstract class defining the Unified Plotting Interface methods. These methods should be overridden and the class extended by interface specific subclasses.
- CommonStyleDefs = {'lines': '', 'points': ''}¶
- axisInputStringToList(input)[source]¶
Extracts axis information from a string input, returns a boolean triple representing (x=True/False, y=True/False, z=True/False).
input the input string
- export(name, directory=None, outtype='png')[source]¶
Export the current plot as a <format> file.
filename the filename
directory optional (default = current working directory)
outtype the file format (default=’png’).
Currently only PNG is guaranteed to be available in all interfaces.
- plot(data, x, y, title='', format='')[source]¶
Plot a single line data[y] vs data[x] where:
data the data array
x x column index
y y column index
title is the line key
format is the XXX format string (default=’’)
Format can also be the CommonStyle ‘lines’ or ‘points’
- plotLines(data, x, y=[], titles=[], formats=[''])[source]¶
Plot a multiple lines data[y1, y2, ] vs data[x] where:
data the data array
x x column index
y is a list of line indexes, if empty all of y not including x is plotted
titles is a list of line keys, if empty Line1,Line2,Line3 is used
formats is a list (per line) of XXX format strings.
If formats only contains a single item, this format is used for all lines and can also be the CommonStyle ‘lines’ or ‘points’.
- save(name, directory=None, dfmt='%.8e')[source]¶
Save the plot data and (optionally) XXX format file
filename the filename
directory optional (default = current working directory)
dfmt the data format string (default=’%.8e’)
- setAxisLabel(axis, label='')[source]¶
Set the axis label:
axis = x, y, z, xy, xz, yz, zyx
label = string (default=’’)
Called with only the axis argument clears the axis label.
- setGraphTitle(title='PySCeS Plot')[source]¶
Set the graph title, unset if title=None
title (string, default=’PySCeS Plot’) the graph title
- setKey(value=False)[source]¶
Enable or disable the current plot key, no arguments removes key.
value boolean (default = False)
- setRange(axis, min=None, max=None)[source]¶
Set axis range where
axis = x, y, z, xy, xz, yz, zyx
min = range(s) lower bound (default=None) autoscale
max = range(s) upper bound (default=None) autoscale
- splot(data, x, y, z, titles='', format='')[source]¶
Plot a surface data[z] vs data[y] vs data[x] where:
data the data array
x x column index
y y column index
z z column index
title is the surface key
format is the XXX format string (default=’’)
Format can also be the CommonStyle ‘lines’ or ‘points’.
- splotSurfaces(data, x, y, z=[], titles=[], formats=[''])[source]¶
Plot data[z1, z2, ] vs data[y] vs data[x] where:
data the data array
x x column index
y y column index
z list of z column indexes, if empty all of z not including x, y are plotted
titles is a list of surface keys, if empty Surf1, Surf2, Surf3 is used
formats is a list (per line) of XXX format strings (default=’’).
If formats only contains a single item, this format is used for all surfaces and can also be the CommonStyle ‘lines’ or ‘points’.
- class pysces.PyscesPlot2.PyscesUPI[source]¶
This is the frontend to the PySCeS Unified Plotting Interface (pysces.plt.*) that allows one to specify which backend should be used to plot when a UPI method is called. More than one interface can be active at the same time and so far the Matplotlib and GnuPlot backends are available for use.
This is an experiment which must be refactored into a more general way of doing things. Basically, I want an instance of the abstract plotting class which will plot to one, any or all currently available backends. If anybody has an idea how I can generate this class automatically please let me know ;-)
- export(name, directory=None, outtype='png')[source]¶
Export the current plot as a <format> file.
filename the filename
directory optional (default = current working directory)
outtype the file format (default=’png’).
Currently only PNG is guaranteed to be available in all interfaces.
- g = None¶
- m = None¶
- p_activateInterface(interface)[source]¶
Activate an interface that has been set with p_setInterface() but deactivated with p_deactivateInterface
interface one of [‘matplotlib’,’gnuplot’]
- p_deactivateInterface(interface)[source]¶
Deactivate the interface. This does not delete the interface and it is possible to reactivate the deactivated interface with p_activateInterface.
interface one of [‘matplotlib’,’gnuplot’]
- p_setInterface(name, instance)[source]¶
Add an interface to the backend selector
name the interface name currently one of [‘matplotlib’,’gnuplot’]
instance an instance of a PlotBase derived (UPI) interface
- plot(data, x, y, title='', format='')[source]¶
Plot a single line data[y] vs data[x] where:
data the data array
x x column index
y y column index
title is the line key
format is the backend format string (default=’’)
- plotLines(data, x, y=[], titles=[], formats=[''])[source]¶
Plot a multiple lines data[y1, y2, ] vs data[x] where:
data the data array
x x column index
y is a list of line indexes, if empty all of y not including x is plotted
titles is a list of line keys, if empty Line1,Line2,Line3 is used
formats is a list (per line) of XXX format strings.
If formats only contains a single item, this format is used for all lines.
- save(name, directory=None, dfmt='%.8e')[source]¶
Save the plot data and (optionally) XXX format file
filename the filename
directory optional (default = current working directory)
dfmt the data format string (default=’%.8e’)
- setAxisLabel(axis, label='')[source]¶
Set the axis label:
axis = x, y, z, xy, xz, yz, zyx
label = string (default=None)
Called with only the axis argument clears the axis label.
- setGraphTitle(title='PySCeS Plot')[source]¶
Set the graph title, unset if title=None
title (string, default=’PySCeS Plot’) the graph title
- setKey(value=False)[source]¶
Enable or disable the current plot key, no arguments removes key.
value boolean (default = False)
- setRange(axis, min=None, max=None)[source]¶
Set axis range where
axis = x, y, z, xy, xz, yz, zyx
min = range(s) lower bound (default=None) autoscale
max = range(s) upper bound (default=None) autoscale
- splot(data, x, y, z, titles='', format='')[source]¶
Plot a surface data[z] vs data[y] vs data[x] where:
data the data array
x x column index
y y column index
z z column index
titles is a list of surface keys whose len matches data columns
format is the XXX format string (default=’’)
- splotSurfaces(data, x, y, z=[], titles=[], formats=[''])[source]¶
Plot data[z1, z2, ] vs data[y] vs data[x] where:
data the data array
x x column index
y y column index
z list of z column indexes, if empty all of z not including x, y are plotted
titles is a list of surface keys, if empty Surf1, Surf2, Surf3 is used
formats is a list (per line) of XXX format strings (default=’’).
If formats only contains a single item, this format is used for all surfaces.
PyscesInterfaces¶
Interfaces converting to and from PySCeS models - makes use of Brett’s Core2
- class pysces.PyscesInterfaces.Core2interfaces[source]¶
Defines interfaces for translating PySCeS model objects into and from other formats.
- convertSBML2PSC(sbmlfile, sbmldir=None, pscfile=None, pscdir=None)[source]¶
Convert an SBML file to a PySCeS MDL input file.
sbmlfile: the SBML file name
sbmldir: the directory of SBML files (if None current working directory is assumed)
pscfile: the output PSC file name (if None sbmlfile.psc is used)
pscdir: the PSC output directory (if None the pysces.model_dir is used)
- core = None¶
- core2psc = None¶
- core2sbml = None¶
- readMod2Core(mod, iValues=True)[source]¶
Convert a PySCeS model object to core2
iValues: if True then the models initial values are used (or the current values if False).
- readSBMLToCore(filename, directory=None)[source]¶
Reads the SBML file specified with filename and converts it into a core2 object pysces.interface.core
filename: the SBML file
directory: (optional) the SBML file directory None means try the current working directory
- sbml = None¶
- sbml2core = None¶
- sbml_level = 3¶
- sbml_version = 2¶
- writeCore2PSC(filename=None, directory=None, getstrbuf=False)[source]¶
Writes a Core2 object to a PSC file.
filename: writes <filename>.xml or <model_name>.xml if None
directory: (optional) an output directory
getstrbuf: if True a StringIO buffer is returned instead of writing to disk
- writeCore2SBML(filename=None, directory=None, getdocument=False)[source]¶
Writes Core2 object to an SBML file.
filename: writes <filename>.xml or <model_name>.xml if None
directory: (optional) an output directory
getdocument: if True an SBML document object is returned instead of writing to disk or
- writeMod2PSC(mod, filename=None, directory=None, iValues=True, getstrbuf=False)[source]¶
Writes a PySCeS model object to a PSC file.
filename: writes <filename>.psc or <model_name>.psc if None
directory: (optional) an output directory
iValues: if True then the models initial values are used (or the current values if False).
getstrbuf: if True a StringIO buffer is returned instead of writing to disk
- writeMod2SBML(mod, filename=None, directory=None, iValues=True, getdocument=False, getstrbuf=False, debug=False)[source]¶
Writes a PySCeS model object to an SBML file.
filename: writes <filename>.xml or <model_name>.xml if None
directory: (optional) an output directory
iValues: if True then the models initial values are used (or the current values if False).
getdocument: if True an SBML document object is returned instead of writing to disk or
getstrbuf: if True a StringIO buffer is returned instead of writing to disk
PyscesLink¶
Interfaces to external software and API’s, has replaced the PySCeS contrib classes.
- class pysces.PyscesLink.METATOOLlink(mod, __metatool_path__=None)[source]¶
New interface to METATOOL binaries
- doEModes()[source]¶
Calculate the elementary modes by way of an interface to MetaTool.
METATOOL is a C program developed from 1998 to 2000 by Thomas Pfeiffer (Berlin) in cooperation with Stefan Schuster and Ferdinand Moldenhauer (Berlin) and Juan Carlos Nuno (Madrid). http://www.biologie.hu-berlin.de/biophysics/Theory/tpfeiffer/metatool.html
Arguments: None
- class pysces.PyscesLink.SBWLayoutWebLink[source]¶
Enables access to DrawNetwork and SBMLLayout web services at www.sys-bio.org
- DEBUGLEVEL = 1¶
- DEBUGMODE = False¶
- DRAWNETWORKLOADED = False¶
- LAYOUTMODULELOADED = False¶
- sbml = None¶
- sbmllayout = None¶
- sbwhost = '128.208.17.26'¶
- setProxy(**kwargs)[source]¶
Set as many proxy settings as you need. You may supply a user name without a password in which case you will be prompted to enter one (once) when required (NO guarantees, implied or otherwise, on password security AT ALL). Arguments can be:
user = ‘daUser’, pwd = ‘daPassword’, host = ‘proxy.paranoid.net’, port = 3128
- svg = None¶