ICSB 2005 Systems Biology Workbench - Tutorial
8 pages
English

ICSB 2005 Systems Biology Workbench - Tutorial

-

Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
8 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

ICSB 2005 - SBW Tutorial ICSB 2005 Systems Biology Workbench – Tutorial This tutorial shows how an application is written that takes use of SBW modules. After detailing the software requirements the tutorial will begin with an example of writing a simple application accessing a simulator using the C# language. The second example will use python to simulate a model. Requirements The C# part of this tutorial will be performed using: • Microsoft Visual Studio 2003 (Professional Edition) • SBW 2.4.x http://public.kgi.edu/~fbergman/files/sbw/SetupSBW_2.4.x.exe • SBW Visual Studio Add-in: an/files/sbw/vsSBWSetup.msi • ZedGraph – graphing library http://www.sf.net/projects/zedgraph The second part of tutorial uses: • Python 2.4.x http://www.python.org • Numerical Python http://www.sf.net/projects/numpy • SBW 2.4.x http://public.kgi.edu/~fbergman/files/sbw/SetupSBW_2.4.x.exe One note on the SBW installer: The python bindings will only be installed if an installation of Python together with the according Numerical Python version is installed. Using C# to access a module 1. The first thing to do is to create a new project: File\New\New Project\Visual C# Projects\Windows Application 2. Once the new project has been created. The first thing to do is to set up the references we will use. In order to do so click on: Project\Add Reference… In the upcoming dialog click on Browse and navigate to the SBW installation directory ...

Informations

Publié par
Nombre de lectures 43
Langue English

Extrait

ICSB 2005  SBW Tutorial
ICSB 2005 Systems Biology Workbench – Tutorial This tutorial shows how an application is written that takes use of SBW modules. After detailing the software requirements the tutorial will begin with an example of writing a simple application accessing a simulator using the C# language. The second example will use python to simulate a model.
Requirements The C# part of this tutorial will be performed using: Microsoft Visual Studio 2003 (Professional Edition) SBW 2.4.x http://public.kgi.edu/~fbergman/files/sbw/SetupSBW_2.4.x.exeSBW Visual Studio Addin: http://public.kgi.edu/~fbergman/files/sbw/vsSBWSetup.msiZedGraph – graphing library http://www.sf.net/projects/zedgraphThe second part of tutorial uses: Python 2.4.x http://www.python.orgNumerical Python http://www.sf.net/projects/numpySBW 2.4.x http://public.kgi.edu/~fbergman/files/sbw/SetupSBW_2.4.x.exeOne note on the SBW installer: The python bindings will only be installed if an installation of Python together with the according Numerical Python version is installed.
Using C# to access a module 1.The first thing to do is to create a new project: File\New\New Project\Visual C# Projects\Windows Application 2.Once the new project has been created. The first thing to do is to set up the references we will use. In order to do so click on: Project\Add Reference… In the upcoming dialog click on Browse and navigate to the SBW installation directory. (Usually: C:\Program Files\KGI\SBW\bin) and from this directory choose the two files: SBWCSharp.dll and Zedgraph.dll. These two files will enable the application to interface with SBW and to access the Zedgraph API.
Page 1 of 8
ICSB 2005  SBW Tutorial
3.The next step is to set up the Form for our application. The form consists of one panel containing three textboxes and three buttons docked to the right. And one panel containing the zedgraph control docked to fill the rest of the form. Finally drag an OpenFileDialog on the form. This form could look like this:
4.The next step is to wire the textboxes and buttons to the desired events. For that just double click on the textboxes and buttons. After each double click, Visual Studio will create the default event and take you to the source code. 5.Once all events are set up the layout part of our application is done. The next step is to interface with the simulator. For this purpose an addin was written for Visual Studio that simplifies the process. This addin is invoked by selecting: Tools\SBW Integration The following dialog appears:
Page 2 of 8
ICSB 2005  SBW Tutorial
6.From this dialog select the SBW Module ‘Jarnac’ and the service ‘sim’. After a click on ‘Create’ a wrapper for this module will be created and added to your solution. 7.Next go to the beginning of the C# source code of the Form and add the following lines to the default name spaces: usingSystem.IO; usingZedGraph; usingJarnac; The System.IO namespace will be needed in order to read the model that should be simulated. The ZedGraph namespace will be used when we add the simulated points to the graph. Finally the Jarnac namespace will be used when we access the simulator. 8.Now we are ready to use the simulator in the application. For that change to the design view and double click on the Load button. Visual Studio takes you to the code for that button. Here you want to enter: if(openFileDialog1.ShowDialog() == DialogResult.OK) { // read the sbml  StreamReader oReader =new StreamReader(openFileDialog1.FileName); stringsSBML = oReader.ReadToEnd();  oReader.Close(); // and pass it to the simulator sim.loadSBML(sSBML); } The code for the reset button is: sim.reset(); And finally the Simulate button: updateGraph(sim.simulate()) 9.This already simulates the model with the default parameters of the simulator. Of course these default values are not suitable for any model. Thus the textboxes … here a user can specify what time range to simulate and how many points to obtain. Add the following lines to the constructor of the Form:
Page 3 of 8
ICSB 2005  SBW Tutorial
txtNumPoints.Text = "100"; txtTimeEnd.Text = "1.0"; txtTimeStart.Text = "0.0"; And then add the following code to the TextChanged events of the Textboxes. For the number of points: intnTemp = Convert.ToInt32(  txtNumPoints.Text,10); if(nTemp > 0)  sim.setNumPoints(nTemp); And for time start: doubledTemp = Convert.ToDouble( txtTimeStart.Text); sim.setTimeStart(dTemp); And finally for time end: doubledTemp = Convert.ToDouble( txtTimeEnd.Text); if(dTemp > 0)  sim.setTimeEnd(dTemp); Now it is possible to simulate any sbml file within the given range and for the number of points. The only thing missing is how to display the new results. 10.In order to update the graph with the new values the simplest method is shown below. It is assumed that time is in the first column of the returned matrix. Then one curve is created for each additional column. Also a random color and symbol will be chosen each time.
Page 4 of 8
 ICSB 2005  SBW Tutorial privatevoidupdateGraph(double[][] values) { // delete old values  zedGraphControl1.GraphPane.CurveList.Clear(); for(intx = 1; x < values[0].Length; x++)  {  ZedGraph.PointPairList oList =new ZedGraph.PointPairList(); for(inty = 0; y < values.Length; y++)  {  oList.Add(values[y][0], values[y][x]);  } zedGraphControl1.GraphPane.CurveList.Add( newLineItem(x.ToString(),oList,  ColorSymbolRotator.StaticNextColor,  ColorSymbolRotator.StaticNextSymbol));  }  zedGraphControl1.AxisChange();  zedGraphControl1.Refresh(); } This concludes this short tutorial. We have seen how a SBM simulation module can be accessed using a graphical interface. The final result is:
Page 5 of 8
 ICSB 2005  SBW Tutorial Using python to access a module In order to start python with the SBW modules loaded just go to:  Start\All Programs\Systems Biology Workbench\Python\PythonSBW 2.x as was mentioned before during the installation of SBW the installer will detect installed Python versions and install the SBW bindings as appropriate. Upon a click on PythonSBW you will see a new console window open. You will see output like this: (SBW) Python interface loading ... (SBW) Examining active modules ... (SBW) Found 2 active modules  python (module: python)  BROKER (module: BROKER) (SBW) Ready. >>> The aim of this tutorial is to load a SBML model and simulate it for some time. Let us begin by loading the SBML model. For this purpose the Broker contains a method called “readFromFile” this method takes a string that is the absolute path to the file to be read, and returns a string that contains the contents of this file. Of course the SBW python bindings support reflection as is usual in python. So let us first try to find the method in case we would not know about it. >>> dir (BROKER) ['__doc__', '__getattr__', '__init__', '__module__', '__repr__', '__str__', 'id', 'pythonName', 'realName', 'services'] >>> If we type dir(<moduleName>) all attributes of the object are returned. Here we see the attribute services. Looking closer at the Service name we find: >>> BROKER.services ['BROKER'] >>>
Page 6 of 8
 ICSB 2005  SBW Tutorial Continuing in that fashion we find all methods provided by the Broker: >>> BROKER.BROKER.methods ['getVersion', 'getModuleInstance', 'getModuleDescriptors', 'getModuleDescriptor', 'getModuleDescriptor', 'findServices', 'getServiceCategories', 'linkBroker', 'getExistingModuleInstanceIds', 'getServiceDescriptor', 'getServiceDescriptor', 'getServiceDescriptors', 'getServiceDescriptors', 'registerModule', 'changeModuleName', 'registerService', 'unregisterModule', 'shutdownBroker', 'getListOfModules', 'getMethodIds', 'getMethodIds', 'readFromFile', 'findLocalServices'] >>> So now we can finally load the SBML file: >>> model = BROKER.BROKER.readFromFile('c:/program files/kgi/sbw/jdesigner/brusselator.xml') >>> If we would like to see the SBML we could type ‘model’. This is omitted here to save space. Now that we have the model loaded we need a simulator (e.g. Jarnac). In order to do so: >>> psbw.getModuleInstance('Jarnac') 1 >>> (SBW) A new module instance has started up: edu.caltech.NOMClipboard (SBW) A new module instance has started up: Jarnac >>> As soon as we start ‘Jarnac’ we see two messages informing us about two new SBW modules are available. The ‘NOMClipboard’ module allows for SBML interrogation while ‘Jarnac’ allows performing timecourse simulations.
Page 7 of 8
 ICSB 2005  SBW Tutorial Let us simulate the loaded model fromt0=0tot=1with a100points. In python this would look like this: >>> Jarnac.sim.loadSBML(model) >>> Jarnac.sim.setTimeStart(0.0) >>> Jarnac.sim.setTimeEnd(1.0) >>> Jarnac.sim.setNumPoints(100) >>> Jarnac.sim.simulate() array([[0.0, 3.0, 3.0], [0.51020408163265307, 3.3711895593085814, 0.8249691090131307], [1.0204081632653061, 1.8459455165002059, 1.2993190450883301], … [omitted] …]]) >>> We have now seen how to interrogate SBW modules, in order to find out what methods they support and used that to simulate a SBML model.
More Information All about SBW C# (language bindings/Visual Studio Addin): http://public.kgi.edu/~fbergman/sbw_c.htmMore on the SBW Python Bindings: http://sbw.kgi.edu/caltechSBW/sbwDocs/docs/api/Python/pythonDoc.pdfMore documentation: http://sbw.kgi.edu/caltechSBW/sbwDocs/docs/index.html
Page 8 of 8
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents