SBML model optimisation
This workflow modifies reaction kinetic parameters against experimental data stored in the MCISB key results database
Preview
Run
Run this Workflow in the Taverna Workbench...
Option 1:
Copy and paste this link into File > 'Open workflow location...'
http://www.myexperiment.org/workflows/1201/download?version=1
[ More Info ]
Taverna is available from http://taverna.sourceforge.net/
If you are having problems downloading it in Taverna, you may need to provide your username and password in the URL so that Taverna can access the Workflow:
Replace http:// in the link above with http://yourusername:yourpassword@
Workflow Components
Peter Li |
SBML model optimisation |
This workflow modifies reaction kinetic parameters against experimental data stored in the MCISB key results database |
sqlitejdbc-v053.jar |
libsbmlj.jar |
libsbml_helpers.jar |
Name | Description |
---|---|
sbml | A parameterised SBML model |
Name | Type | Description |
---|---|---|
createSysbioDataSource | beanshell |
Scriptimport org.sbml.libsbml.*; import java.sql.*; import org.sqlite.JDBC; String DATABASE_NAME = "taverna_sbml"; String databaseURL = "jdbc:sqlite:" + DATABASE_NAME + ".db"; //Set up database try { //System.loadLibrary("sbmlj"); driver = "org.sqlite.JDBC"; Class.forName(driver); Connection conn = DriverManager.getConnection(databaseURL); Statement stat = conn.createStatement(); //Create compartment table stat.executeUpdate("drop table if exists compartment;"); stat.executeUpdate("create table compartment (id, name, outside, sboTerm, goId);"); //Create species table for holding metabolite and enzyme data stat.executeUpdate("drop table if exists species;"); stat.executeUpdate("create table species (id, name, compartmentId, sboTerm, chebi, kegg, inchi, sgd, uniprot);"); //Create reaction table for holding reactants and products stat.executeUpdate("drop table if exists reaction;"); stat.executeUpdate("create table reaction (id, name, sboTerm, subsystem, ec, pubmed, tag);"); //Create reactionspecies table for holding associations between species and reaction stat.executeUpdate("drop table if exists reactionspecies;"); stat.executeUpdate("create table reactionspecies (reactionId, speciesId, stoichiometry, role);"); //==================== //For storing kinetics //==================== //Create kineticlaw table stat.executeUpdate("drop table if exists kineticlaw;"); stat.executeUpdate("create table kineticlaw (id, reactionId, formula, generalId, reversible);"); //Create kineticlawvariable table stat.executeUpdate("drop table if exists kineticlawvariable;"); stat.executeUpdate("create table kineticlawvariable (kineticLawId, variableId, relFormula);"); //Create parameter table stat.executeUpdate("drop table if exists parameter;"); stat.executeUpdate("create table parameter (id INTEGER PRIMARY KEY AUTOINCREMENT, name, role, type, kineticLawId, speciesId, comment, stValue, stDeviation, endValue, unitId);"); //Create unit table stat.executeUpdate("drop table if exists unit;"); stat.executeUpdate("create table unit (id, description, sbmlUnitId, comment);"); //Create sbmlunit table stat.executeUpdate("drop table if exists sbmlunit;"); stat.executeUpdate("create table sbmlunit (id, kind, exponent, scale, multiplier, offset);"); //Create envkineticlaw table stat.executeUpdate("drop table if exists envkineticlaw;"); stat.executeUpdate("create table envkineticlaw (kineticLawId, environDataId);"); //Create environmentaldata table stat.executeUpdate("drop table if exists environmentaldata;"); stat.executeUpdate("create table environmentaldata (id, stValue, endValue, bufferDescription, description, unitId, comment);"); //============================ //Load compartments into table //============================ PreparedStatement prep1 = conn.prepareStatement("insert into compartment values (?, ?, ?, ?, ?);"); SBMLReader reader = new SBMLReader(); SBMLDocument doc = reader.readSBMLFromString(sbml); Model m = doc.getModel(); System.out.println("Model id: " + m.getId()); ListOfCompartments compList = m.getListOfCompartments(); for (int i = 0; i < compList.size(); i++) { Compartment comp = (Compartment) compList.get(i); String id = comp.getId(); String name = comp.getName(); String outside = comp.getOutside(); int sboTerm = comp.getSBOTerm(); String goId = ""; for (int x = 0; x < comp.getNumCVTerms(); x++) { CVTerm term = comp.getCVTerm(x); XMLAttributes att = term.getResources(); for (int y = 0; y < att.getLength(); y++) { String uri = att.getValue(y); if (uri.contains("obo.go")) { goId = uri; } } } prep1.setString(1, id); prep1.setString(2, name); prep1.setString(3, outside); prep1.setInt(4, sboTerm); prep1.setString(5, goId); prep1.addBatch(); } //============================ //Load species into table //============================ PreparedStatement prep = conn.prepareStatement("insert into species values (?, ?, ?, ?, ?, ?, ?, ?, ?);"); ListOfSpecies spList = m.getListOfSpecies(); for (int i = 0; i < spList.size(); i++) { Species sp = (Species) spList.get(i); String id = sp.getId(); String name = sp.getName(); String compartment = sp.getCompartment(); int sboTerm = sp.getSBOTerm(); if (sboTerm == -1) sboTerm = 0; String chebi = ""; String kegg = ""; String inchi = ""; String sgd = ""; String uniprot = ""; try { XMLNode node = sp.getAnnotation(); XMLNode node2 = node.getChild(0); XMLNode node3 = node2.getChild(0); if(XMLNode.convertXMLNodeToString(node3).contains("InChI")) inchi = node3.getCharacters(); } catch (NullPointerException e) //Catch metabolites with no inchi codes { System.err.println("No inchi code"); inchi = ""; } StringBuffer uniprotSb = new StringBuffer(); for (int x = 0; x < sp.getNumCVTerms(); x++) { CVTerm term = sp.getCVTerm(x); XMLAttributes att = term.getResources(); for (int y = 0; y < att.getLength(); y++) { String uri = att.getValue(y); if (uri.contains("chebi")) { chebi = uri; } else if (uri.contains("kegg")) { kegg = uri; } else if (uri.contains("sgd")) { sgd = uri; } else if (uri.contains("uniprot")) { uniprotSb.append("," + uri); } } } prep.setString(1, id); prep.setString(2, name); prep.setString(3, compartment); prep.setInt(4, sboTerm); prep.setString(5, chebi); prep.setString(6, kegg); prep.setString(7, inchi); prep.setString(8, sgd); uniprot = uniprotSb.toString(); uniprot = uniprot.replaceFirst(",", ""); prep.setString(9, uniprot); prep.addBatch(); } //============================ //Load reactions into table //============================ PreparedStatement prep4 = conn.prepareStatement("insert into reaction values (?, ?, ?, ?, ?, ?, ?);"); PreparedStatement prep2 = conn.prepareStatement("insert into reactionspecies values (?, ?, ?, ?);"); PreparedStatement prep5 = conn.prepareStatement("insert into kineticlaw values (?, ?, ?, ?, ?);"); PreparedStatement prep6 = conn.prepareStatement("insert into parameter values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"); ListOfReactions reactions = m.getListOfReactions(); for (int i = 0; i < reactions.size(); i++) { Reaction r = (Reaction) reactions.get(i); String id = r.getId(); String name = r.getName(); int sboTerm = r.getSBOTerm(); //Sort out subsystem String anno = r.getNotesString(); int start = anno.indexOf(" |
userId | stringconstant |
Valuedada |
createSimulationResource | workflow | |
sendModel | workflow | |
sendExptalDataSbrml | workflow | |
queryKRDB | workflow | |
checkData | beanshell |
Scriptimport org.sbml.libsbml.*; //To hold model species ids spIds = new ArrayList(); //For output sb = new StringBuffer(); sb2 = new StringBuffer(); //Extract species ids and names from sbml model SBMLDocument doc = libsbml.readSBMLFromString(sbml); Model m = doc.getModel(); ListOfSpecies splist = m.getListOfSpecies(); sb.append("Species in SBML model\n"); for(int i = 0; i < splist.size(); i++) { Species s = splist.get(i); sb.append(s.getId() + "\t"); spIds.add(s.getId()); sb.append(s.getName() + "\n"); } //String out = sb.toString(); //Extract species ids from SBRML file sb.append("Species in SBRML file\n"); String[] lines = sbrml.split("\n"); for(int x = 0; x < lines.length; x ++) { //Check String line = lines[x]; if(line.contains("compositeValue indexValue")) { if(line.contains("CHEBI")) { x = x + 2; continue; } else { int start = line.indexOf("\""); int end = line.lastIndexOf("\""); String id = line.substring(start + 1, end); if(!spIds.contains(id)) { x = x + 2; continue; } else { sb2.append(line + "\n"); continue; } } } sb2.append(line + "\n"); } String out = sb.toString(); String newSbrml = sb2.toString(); |
parameterEditor | beanshell |
Scriptimport javax.swing.*; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionEvent; import javax.swing.table.AbstractTableModel; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Container; import java.io.*; import java.util.Hashtable; import java.util.ArrayList; import java.sql.*; class Parameter { String name; double value; String type; String modelId; String parameterId; Parameter(String name, String value, String type, String modelId, String parameterId) { this.name = name; this.value = Double.parseDouble(value); this.type = type; this.modelId = modelId; this.parameterId = parameterId; } String getName() { return name; } String setName(String name) { this.name = name; } double getValue() { return value; } String setValue(String value) { this.value = Double.parseDouble(value); } String getType() { return type; } String setType(String type) { this.type = type; } String getModelId() { return this.modelId; } String setModelId(String modelId) { this.modelId = modelId; } String getParameterId() { return parameterId; } String setParameterId(String parameterId) { this.parameterId = parameterId; } } /** * New table model for storing parameter data */ class MyTableModel extends AbstractTableModel { //Set up data for table String[] colnames = {"Parameter name", "Value", "Lower bound", "Upper bound", "Affected experiment", "Object type", "Model Id"}; int numrows = params.size(); int numcols = 7; data = new String[numrows][numcols]; //Iterate thru parameters for(int i = 0; i < params.size(); i++) { p = params.get(i); data[i][0] = p.getName(); double value = p.getValue(); data[i][1] = Double.toString(value); if(p.getType().equals("arbitraryVariable")) { //Lower bound value data[i][2] = Double.toString(value / 4); //Upper bound value data[i][3] = Double.toString(value * 4); data[i][5] = "arbitraryVariable"; } else if(p.getType().equals("reaction")) { //Lower bound value data[i][2] = Double.toString(value / 1000000); //Upper bound value data[i][3] = Double.toString(value * 1000000); data[i][5] = "reaction"; } //Affected experiment data[i][4] = "all"; //ModelId data[i][6] = p.getModelId(); } public int getColumnCount() { return colnames.length; } public int getRowCount() { return data.length; } public String getColumnName(int col) { return colnames[col]; } public Object getValueAt(int row, int col) { return data[row][col]; } /* * JTable uses this method to determine the default renderer/ * editor for each cell. If we didn't implement this method, * then the last column would contain text ("true"/"false"), * rather than a check box. */ public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } /* * Don't need to implement this method unless your table's * editable. */ public boolean isCellEditable(int row, int col) { //Note that the data/cell address is constant, //no matter where the cell appears onscreen. if (col < 2) return false; else return true; } /* * Don't need to implement this method unless your table's * data can change. */ public void setValueAt(Object value, int row, int col) { data[row][col] = value; fireTableCellUpdated(row, col); } public String[][] getData() { return data; } } String DATABASE_NAME = "taverna_sbml"; String databaseURL = "jdbc:sqlite:" + DATABASE_NAME + ".db"; //Get parameter data from database params = new ArrayList(); try { driver = "org.sqlite.JDBC"; Class.forName(driver); Connection conn = DriverManager.getConnection(databaseURL); Statement stat = conn.createStatement(); sql = "select name, stValue, type, kineticLawId from parameter;"; ResultSet rs = stat.executeQuery(sql); while (rs.next()) { name = rs.getString(1); stValue = rs.getString(2); type = rs.getString(3); kineticLawId = rs.getString(4); System.out.println(kineticLawId); if(kineticLawId.equals("")) modelId = name; else modelId = kineticLawId.replaceFirst("kl_", ""); if(type.equals("reaction")) parameterId = name; else parameterId = ""; p = new Parameter(name, stValue, type, modelId, parameterId); params.add(p); } rs.close(); conn.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } /** * Class representing the SetFitItemsAndMethod XML document */ class Document { String contents; Document() { this.contents = ""; } synchronized void setContents(String data) { this.contents = data; notifyAll(); } synchronized String getContents() { while (contents.equals("")) { try { wait(); } catch (InterruptedException e) { e.printStackTrace(); } } return contents; } } /** * Class representing the GUI for selecting the values to be * processed by the remainder of the workflow. */ MultipleSelectWorkerGUI(Document doc) { JTable table; DefaultTableModel tablemodel; JSplitPane splitPane; JTextArea expCondition; JList list; JButton submitButton; Document doc; void init() { super.frame = new JFrame("Select data for downstream analysis"); super.frame.setLocationRelativeTo(null); //Place window in centre pane = new JPanel(); super.frame.getContentPane().add(pane); pane.setLayout(new BoxLayout(pane, BoxLayout.PAGE_AXIS)); this.doc = doc; table = new JTable(new MyTableModel()); //Detect row clicked rowListener = new ListSelectionListener() { void valueChanged(ListSelectionEvent event) { if (event.getValueIsAdjusting()) { return; } //Selected row changed, do something... showReactionInstIds(); } }; table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); DefaultListSelectionModel lst = table.getSelectionModel(); lst.addListSelectionListener(rowListener); JScrollPane tableScrollPane = new JScrollPane(table); pane.add(tableScrollPane); //Create a panel JPanel buttonPane = new JPanel(); submitButton = new JButton("Submit"); submitButton.setActionCommand("submit"); submitButton.addActionListener(this); submitButton.setEnabled(false); buttonPane.add(submitButton); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); pane.add(submitButton); //frame.setSize(800,500); frame.setVisible(true); frame.pack(); } //This method is called only if there is a valid selection //and if the submit button is clicked void actionPerformed(ActionEvent e) { ArrayList al = new ArrayList(); //New String command = e.getActionCommand(); tmodel = table.getModel(); data = tmodel.getData(); if("submit".equals(command)) { //Generate setFitItem XML document StringBuffer sb = new StringBuffer(); //Set userId and resourceId sb.append(" |
setFitItemsAndMethod | workflow | |
startSimulator | workflow | |
pollStatus | workflow | |
getResults | workflow | |
releaseResources | workflow |
Name | Description | Inputs | Outputs |
---|---|---|---|
createSysbioDataSource | sbml | databaseURL | |
checkData |
sbml sbrml |
out newSbrml |
|
parameterEditor |
userId resourceId |
setFitItemsAndMethodXML | |
createCountUrl |
date title |
url | |
cleanCountData | inStr | outStr | |
createQueryUrl |
count date title |
url | |
cleanData | inStr | outStr | |
extractChebiIds | sbrml | chebiIds | |
merge |
speciesIds chebiIds sbrml |
sbrml_out |
Name | Description |
---|---|
optimised_sbml | An SBML model optimised against data from the MCISB key results database. |
Source | Sink |
---|---|
sbml | createSysbioDataSource:sbml |
userId:value | createSimulationResource:userId |
createSimulationResource:resourceId | sendModel:resourceId |
userId:value | sendModel:userId |
sbml | sendModel:sbml |
userId:value | sendExptalDataSbrml:userId |
createSimulationResource:resourceId | sendExptalDataSbrml:resourceId |
checkData:newSbrml | sendExptalDataSbrml:sbrml |
queryKRDB:new_sbrml | checkData:sbrml |
sbml | checkData:sbml |
createSimulationResource:resourceId | parameterEditor:resourceId |
userId:value | parameterEditor:userId |
parameterEditor:setFitItemsAndMethodXML | setFitItemsAndMethod:fitItemsAndMethodXML |
userId:value | startSimulator:userId |
createSimulationResource:resourceId | startSimulator:resourceId |
userId:value | pollStatus:userId |
createSimulationResource:resourceId | pollStatus:resourceId |
userId:value | getResults:userId |
createSimulationResource:resourceId | getResults:resourceId |
userId:value | releaseResources:userId |
createSimulationResource:resourceId | releaseResources:resourceId |
getResults:result | optimised_sbml |
Controller | Target |
---|---|
startSimulator | pollStatus |
getResults | releaseResources |
setFitItemsAndMethod | startSimulator |
createSysbioDataSource | parameterEditor |
sendExptalDataSbrml | setFitItemsAndMethod |
pollStatus | getResults |
sendModel | sendExptalDataSbrml |
Workflow Type
Version 1 (of 1)
Log in to add Tags
Shared with Groups (0)
None
Log in to add to one of your Packs
Statistics
Reviews (0)
Other workflows that use similar services (2)
Construction of skeleton SBML model using ... (1)
Created: 2010-03-26 | Last updated: 2010-03-26
Credits: Peter Li
Construction of skeleton SBML model using ... (1)
Created: 2010-03-26 | Last updated: 2010-03-26
Credits: Peter Li
Comments (0)
No comments yet
Log in to make a comment