Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bdb18bb

Browse files
author
Kiri Choi
committedNov 21, 2014
Minor changes in sedml2py and test files
1 parent b9d7fd4 commit bdb18bb

File tree

6 files changed

+35
-19
lines changed

6 files changed

+35
-19
lines changed
 

‎SedmlToRr.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import re
2020
import libsedml # C:\WinPython-32bit-2.7.5.3\python-2.7.5\Lib\site-packages\libsedml\libsedml.py
2121
import zipfile
22+
#import string
2223
from collections import namedtuple
2324

2425
MatchingSetsOfVariableIDs = namedtuple("MatchingSetsOfVariableIDs", "datagenID, taskReference, sedmlID, sbmlID")
@@ -63,23 +64,25 @@ def write(self, obj):
6364
original = sys.stdout
6465
#sys.stdout = Tee(sys.stdout, f) # output to console and file
6566
sys.stdout = Tee(f) # output to file only
66-
67+
68+
print "# Translated SED-ML"
6769
print "# Beginning of generated script"
6870
print "import roadrunner"
6971
print ""
7072
for i in range(0, sedmlDoc.getNumModels()):
7173
currentModel = sedmlDoc.getModel(i)
72-
print "# Execute the tasks of model " + currentModel.getName()
73-
rrName = "rr" + str(i)
74+
print "# Execute the tasks of model: " + currentModel.getId()
75+
rrName = currentModel.getId()
76+
#rrName = "rr" + str(i)
7477
print rrName + " = roadrunner.RoadRunner()"
7578
generateTasks(rrName, sedmlDoc, currentModel, path)
7679
print ""
77-
print "# The Data Generators"
80+
print "# List of Data Generators"
7881
dataGeneratorsList = []
7982
for i in range(0, sedmlDoc.getNumModels()):
8083
currentModel = sedmlDoc.getModel(i)
8184
generateData(sedmlDoc, currentModel, dataGeneratorsList)
82-
print "# The Plots"
85+
print "# List of Plots"
8386
generatePlots(sedmlDoc, dataGeneratorsList)
8487
print "# End of generated script\n"
8588

@@ -89,7 +92,6 @@ def write(self, obj):
8992
return contents
9093

9194
def generateTasks(rrName, sedmlDoc, currentModel, path):
92-
9395
listOfChanges = []
9496
loadModel(rrName, sedmlDoc, currentModel, path)
9597
#print(rrName + ".simulateOptions.structuredResult = False")
@@ -117,7 +119,7 @@ def generateTasks(rrName, sedmlDoc, currentModel, path):
117119
aStr = "# Unsupported change " + aChange.getElementName() + " for model " + currentModel.getId()
118120
print aStr
119121
return
120-
122+
121123
# The 'selections' are a list of all the 'variable' elements from the dataGenerators
122124
# we first deal with normal tasks, if any
123125
for e in range(0,sedmlDoc.getNumTasks()):
@@ -203,8 +205,11 @@ def loadModel(rrName, sedmlDoc, currentModel, path):
203205
if isId(string): # it's the Id of a model
204206
originalModel = sedmlDoc.getModel(string)
205207
string = originalModel.getSource() # !!! for now, we reuse the original model to which the current model is referring to
206-
if string.startswith("../"): # relative location, we trust it but need it trimmed
207-
string = string[3:]
208+
if string.startswith("."): # relative location, we trust it but need it trimmed
209+
if string.startswith("../"):
210+
string = string[3:]
211+
elif string.startswith("./"):
212+
string = string[2:]
208213
print rrName + ".load('" + path.replace("\\","/") + string + "')" # SBML model name recovered from "source" attr
209214
#from os.path import expanduser
210215
#path = expanduser("~")
@@ -288,6 +293,7 @@ def generateSimulation(rrName, sedmlDoc, currentModel, task1, variablesList, var
288293
taskId = task1.getId()
289294
else:
290295
taskId = repeatedTask.getId() + "_" + str(repeatedTaskIndex)
296+
taskId = taskId.replace('repeatedTask', 'rT')
291297
string = taskId + " = " + rrName + ".simulate("
292298
tc = currentSimulation
293299
totNumPoints = tc.getOutputEndTime() * tc.getNumberOfPoints() / (tc.getOutputEndTime() - tc.getOutputStartTime())
@@ -410,6 +416,7 @@ def generateDataLoop(sedmlDoc, currentModel, task1, variablesList, variablesDict
410416
dataGeneratorsList[position] = rtdg
411417

412418
dataGeneratorOutput = '\n'.join(dataGeneratorOutputList)
419+
dataGeneratorOutput = dataGeneratorOutput.replace('repeatedTask', 'rT')
413420
print dataGeneratorOutput
414421

415422
def generatePlots(sedmlDoc, dataGeneratorsList):
@@ -443,6 +450,8 @@ def generatePlots(sedmlDoc, dataGeneratorsList):
443450
curve = output.getCurve(k)
444451
xDataReference = curve.getXDataReference()
445452
yDataReference = curve.getYDataReference()
453+
xDataReference = xDataReference.replace('repeatedTask', 'rT')
454+
yDataReference = yDataReference.replace('repeatedTask', 'rT')
446455
if not len(dataGeneratorsList) == 0:
447456
allX += xDataReference + "_" + str(l) + ","
448457
allY += yDataReference + "_" + str(l) + ","
@@ -455,7 +464,7 @@ def generatePlots(sedmlDoc, dataGeneratorsList):
455464
print allY
456465
print "plt.plot(allX_" + str(l) + ", allY_" + str(l) + ")\n"
457466
elif "repeatedTask" not in checklist: #There is no repeated tasks
458-
if output.getNumCurves() > 1:
467+
if output.getNumCurves() > 0:
459468
allX = "allX_" + str(i) + " = numpy.array(["
460469
allY = "allY_" + str(i) + " = numpy.array(["
461470
for k in range(0, output.getNumCurves()):

‎testing/app2sim/app2sim.sedml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</uniformTimeCourse>
1717
</listOfSimulations>
1818
<listOfModels>
19-
<model id="Application0" name="Application0" language="urn:sedml:language:sbml" source="../BioModel1_Application0.xml" />
19+
<model id="Application0" name="Application0" language="urn:sedml:language:sbml" source="./BioModel1_Application0.xml" />
2020
<model id="Application0_0" name="Application0 modified" language="urn:sedml:language:sbml" source="Application0">
2121
<listOfChanges>
2222
<changeAttribute newValue="10.0" target="/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id='s1']" />

‎testing/asedml3repeat/asedml3repeat.sedml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</uniformTimeCourse>
1111
</listOfSimulations>
1212
<listOfModels>
13-
<model id="Application0" name="Application0" language="urn:sedml:language:sbml" source="../asedml3repeat_Application0.xml" />
13+
<model id="Application0" name="Application0" language="urn:sedml:language:sbml" source="./asedml3repeat_Application0.xml" />
1414
</listOfModels>
1515
<listOfTasks>
1616
<task id="task_0_0" name="task_0_0" modelReference="Application0" simulationReference="Simulation0" />

‎testing/asedmlComplex/asedmlComplex.sedml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</uniformTimeCourse>
1111
</listOfSimulations>
1212
<listOfModels>
13-
<model id="Application0" name="Application0" language="urn:sedml:language:sbml" source="../asedmlComplex_Application0.xml" />
13+
<model id="Application0" name="Application0" language="urn:sedml:language:sbml" source="./asedmlComplex_Application0.xml" />
1414
<model id="Application0_0" name="Application0 modified" language="urn:sedml:language:sbml" source="Application0">
1515
<listOfChanges>
1616
<changeAttribute newValue="25.0" target="/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id='s0']" />

‎testing/constant_maybe/BioModel1.sedml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</uniformTimeCourse>
1111
</listOfSimulations>
1212
<listOfModels>
13-
<model id="repressor_activator_oscillations" name="repressor_activator_oscillations" language="urn:sedml:language:sbml" source="../BioModel1_repressor_activator_oscillations.xml" />
13+
<model id="repressor_activator_oscillations" name="repressor_activator_oscillations" language="urn:sedml:language:sbml" source="./BioModel1_repressor_activator_oscillations.xml" />
1414
</listOfModels>
1515
<listOfTasks>
1616
<task id="task_0_0" name="task_0_0" modelReference="repressor_activator_oscillations" simulationReference="scan_for_delta_A" />

‎testing/constant_maybe/BioModel1_repressor_activator_oscillations.xml

+12-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@
4646
<unit kind="second" exponent="-1" scale="0" multiplier="1"/>
4747
</listOfUnits>
4848
</unitDefinition>
49-
<unitDefinition id="uM_um3_molecules_1">
49+
<unitDefinition id="uM3">
50+
<listOfUnits>
51+
<unit kind="dimensionless" exponent="1" scale="0" multiplier="1e-021"/>
52+
<unit kind="item" exponent="-1" scale="0" multiplier="1"/>
53+
<unit kind="mole" exponent="1" scale="0" multiplier="1"/>
54+
</listOfUnits>
55+
</unitDefinition>
56+
<unitDefinition id="uM2">
5057
<listOfUnits>
5158
<unit kind="dimensionless" exponent="1" scale="0" multiplier="1e-021"/>
5259
<unit kind="item" exponent="-1" scale="0" multiplier="1"/>
@@ -71,7 +78,7 @@
7178
</unitDefinition>
7279
</listOfUnitDefinitions>
7380
<listOfCompartments>
74-
<compartment id="cell" name="cell" spatialDimensions="3" size="4.18879020478639" units="um3" outside="PM" constant="true">
81+
<compartment id="cell" name="cell" spatialDimensions="3" size="4.18879020478639" units="uM3" outside="PM" constant="true">
7582
<annotation>
7683
<vcell:VCellInfo xmlns:vcell="http://sourceforge.net/projects/vcell">
7784
<vcell:VCMLSpecific>
@@ -80,8 +87,8 @@
8087
</vcell:VCellInfo>
8188
</annotation>
8289
</compartment>
83-
<compartment id="EC" name="EC" spatialDimensions="3" size="8" units="um3" constant="true"/>
84-
<compartment id="PM" name="PM" spatialDimensions="2" size="12.5663706143592" units="um2" outside="EC" constant="true">
90+
<compartment id="EC" name="EC" spatialDimensions="3" size="8" units="uM3" constant="true"/>
91+
<compartment id="PM" name="PM" spatialDimensions="2" size="12.5663706143592" units="uM2" outside="EC" constant="true">
8592
<annotation>
8693
<vcell:VCellInfo xmlns:vcell="http://sourceforge.net/projects/vcell">
8794
<vcell:VCMLSpecific>
@@ -176,7 +183,7 @@
176183
</listOfSpecies>
177184
<listOfParameters>
178185
<parameter id="common_delta_A" value="1" units="s_1" constant="true"/>
179-
<parameter id="KMOLE1" value="0.00166112956810631" units="uM_um3_molecules_1" constant="true"/>
186+
<parameter id="KMOLE1" value="0.00166112956810631" units="uM3" constant="true"/>
180187
<parameter id="delta_A_C_decay" units="s_1" constant="false"/>
181188
<parameter id="delta_A_A_decay" units="s_1" constant="false"/>
182189
<parameter id="gamma_C_AR_binding" units="s_1_uM_1" constant="false"/>

0 commit comments

Comments
 (0)
Please sign in to comment.