43
43
import sys
44
44
import pylab
45
45
from moose .SBML import *
46
+ import os .path
47
+
46
48
def main ():
47
49
""" This example illustrates loading, running of an SBML model defined in XML format.\n
48
50
The model 00001-sbml-l3v1.xml is taken from l3v1 SBML testcase.\n
@@ -51,37 +53,43 @@ def main():
51
53
As a general rule we created model under '/path/model' and plots under '/path/graphs'.\n
52
54
"""
53
55
54
- mfile = '../genesis/00001-sbml-l3v1.xml'
55
- runtime = 20.0
56
-
57
- if (len (sys .argv ) >= 3 ):
58
- if sys .argv [1 ][0 ]== '/' :
59
- mfile = sys .argv [1 ]
60
- else :
61
- mfile = '../genesis/' + sys .argv [1 ]
62
-
56
+ mfile = "../genesis/00001-sbml-l3v1.xml"
57
+ try :
58
+ sys .argv [1 ]
59
+ except :
60
+ pass
61
+ else :
62
+ mfile = sys .argv [1 ]
63
+
64
+ try :
65
+ sys .argv [2 ]
66
+ except :
67
+ runtime = 20.0
68
+ else :
63
69
runtime = float (sys .argv [2 ])
64
-
65
- # Loading the sbml file into MOOSE, models are loaded in path/model
66
- sbmlId = mooseReadSBML (mfile ,'sbml' )
67
70
71
+ # Loading the sbml file into MOOSE, models are loaded in path/model
72
+ sbmlId = mooseReadSBML (mfile ,'/sbml' )
73
+
74
+ if sbmlId .path != '/' :
75
+ s1 = moose .element ('/sbml/model/compartment/S1' )
76
+ s2 = moose .element ('/sbml/model/compartment/S2' )
77
+
78
+ # Creating MOOSE Table, Table2 is for the chemical model
79
+ graphs = moose .Neutral ( '/sbml/graphs' )
80
+ outputs1 = moose .Table2 ( '/sbml/graphs/concS1' )
81
+ outputs2 = moose .Table2 ( '/sbml/graphs/concS2' )
68
82
69
- s1 = moose .element ('/sbml/model/compartment/S1' )
70
- s2 = moose .element ('/sbml/model/compartment/S2' )
71
-
72
- # Creating MOOSE Table, Table2 is for the chemical model
73
- graphs = moose .Neutral ( '/sbml/graphs' )
74
- outputs1 = moose .Table2 ( '/sbml/graphs/concS1' )
75
- outputs2 = moose .Table2 ( '/sbml/graphs/concS2' )
76
-
77
- # connect up the tables
78
- moose .connect ( outputs1 ,'requestOut' , s1 , 'getConc' );
79
- moose .connect ( outputs2 ,'requestOut' , s2 , 'getConc' );
83
+ # connect up the tables
84
+ moose .connect ( outputs1 ,'requestOut' , s1 , 'getConc' );
85
+ moose .connect ( outputs2 ,'requestOut' , s2 , 'getConc' );
80
86
81
-
82
- # Reset and Run
83
- moose .reinit ()
84
- moose .start (runtime )
87
+
88
+ # Reset and Run
89
+ moose .reinit ()
90
+ moose .start (runtime )
91
+ return sbmlId ,True
92
+ return sbmlId ,False
85
93
86
94
def displayPlots ():
87
95
# Display all plots.
@@ -95,5 +103,6 @@ def displayPlots():
95
103
quit ()
96
104
if __name__ == '__main__' :
97
105
98
- main ()
99
- displayPlots ()
106
+ modelPath , modelpathexist = main ()
107
+ if modelpathexist == True :
108
+ displayPlots ()
0 commit comments