4343import sys
4444import pylab
4545from moose .SBML import *
46+ import os .path
47+
4648def main ():
4749 """ This example illustrates loading, running of an SBML model defined in XML format.\n
4850 The model 00001-sbml-l3v1.xml is taken from l3v1 SBML testcase.\n
@@ -51,37 +53,43 @@ def main():
5153 As a general rule we created model under '/path/model' and plots under '/path/graphs'.\n
5254 """
5355
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 :
6369 runtime = float (sys .argv [2 ])
64-
65- # Loading the sbml file into MOOSE, models are loaded in path/model
66- sbmlId = mooseReadSBML (mfile ,'sbml' )
6770
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' )
6882
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' );
8086
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
8593
8694def displayPlots ():
8795 # Display all plots.
@@ -95,5 +103,6 @@ def displayPlots():
95103 quit ()
96104if __name__ == '__main__' :
97105
98- main ()
99- displayPlots ()
106+ modelPath , modelpathexist = main ()
107+ if modelpathexist == True :
108+ displayPlots ()
0 commit comments