1313** copyright (C) 2003-2017 Upinder S. Bhalla. and NCBS
1414Created : Thu May 13 10:19:00 2016(+0530)
1515Version
16- Last-Updated: Mon Sep 21 12:50 :00 2020 (+0530)
16+ Last-Updated: Tue Apr 5 17:10 :00 2022 (+0530)
1717 By:HarshaRani
1818**********************************************************************/
19+ 2022:
20+ Apr 05: - edge case NN_mapk15.g, extra Neutral path '/kinetics' exist which
21+ was not created in xml file which was causing ex12.0* example break
22+ This is fixed in writeSBML by adding basepath in compartment Annotation
23+ And same is create in ReadSBML
24+
25+ Mar 22: - function connection are done after Enzyme and Reaction are created
26+ this is because cplx path is modified after Enzyme created, which
27+ would be a problem as path changes
28+ - edge case like pool is parent and product to enzyme, Stoichiometry
29+ need to reduce (eg osc_different_vols)
30+ - function expression fixed if multiple of same pool exist
31+
19322020:
2033Sep 21: - Complex pool which is created at species level is copied under enzyme,
2134 ensuring the value set at species is retained.
@@ -156,7 +169,7 @@ def mooseReadSBML(filepath, loadpath, solver="ee",validate="on"):
156169
157170 mapParameter (model , globparameterIdValue )
158171 msgCmpt = ""
159- errorFlag ,msgCmpt = createCompartment (
172+ errorFlag ,msgCmpt , baseId = createCompartment (
160173 baseId , model , comptSbmlidMooseIdMap )
161174
162175 groupInfo = checkGroup (baseId ,model ,comptSbmlidMooseIdMap )
@@ -165,15 +178,18 @@ def mooseReadSBML(filepath, loadpath, solver="ee",validate="on"):
165178 specInfoMap = {}
166179 errorFlag ,warning = createSpecies (
167180 baseId , model , comptSbmlidMooseIdMap , specInfoMap , modelAnnotaInfo ,groupInfo )
181+
168182 if errorFlag :
169- msgRule = createRules (
170- model , specInfoMap , globparameterIdValue )
183+ errorFlag , msgReac = createReaction (
184+ model , specInfoMap , modelAnnotaInfo , globparameterIdValue ,funcDef ,groupInfo )
185+ if len (moose .wildcardFind (moose .element (loadpath ).path + "/##[ISA=Reac],/##[ISA=EnzBase]" )) == 0 :
186+ errorFlag = False
187+ noRE = ("Atleast one reaction should be present to display in the widget " )
188+
171189 if errorFlag :
172- errorFlag , msgReac = createReaction (
173- model , specInfoMap , modelAnnotaInfo , globparameterIdValue ,funcDef ,groupInfo )
174- if len (moose .wildcardFind (moose .element (loadpath ).path + "/##[ISA=Reac],/##[ISA=EnzBase]" )) == 0 :
175- errorFlag = False
176- noRE = ("Atleast one reaction should be present to display in the widget " )
190+ msgRule = createRules (
191+ model , specInfoMap , globparameterIdValue )
192+
177193 getModelAnnotation (model , baseId )
178194 if not errorFlag :
179195 # Any time in the middle if SBML does not read then I
@@ -301,7 +317,8 @@ def setupEnzymaticReaction(enz, groupName, enzName, specInfoMap, modelAnnotaInfo
301317 complx1 = moose .copy (complx ,enzyme_ .path )
302318 else :
303319 complx1 = moose .element (enzyme_ .path + '/' + complx .name )
304- specInfoMap [cplx ]["Mpath" ] = complx1
320+ specInfoMap [cplx ]["Mpath" ] = moose .element (complx1 )
321+
305322 moose .connect (enzyme_ , "cplx" , complx1 , "reac" )
306323 moose .connect (enzyme_ , "enz" , enzParent , "reac" )
307324 sublist = (modelAnnotaInfo [groupName ]["substrate" ])
@@ -321,7 +338,14 @@ def setupEnzymaticReaction(enz, groupName, enzName, specInfoMap, modelAnnotaInfo
321338 for tr in range (0 ,enz .getNumProducts ()):
322339 sp = enz .getProduct (tr )
323340 spspieces = sp .getSpecies ()
324- enz_prdlist [spspieces ] = int (sp .getStoichiometry ())
341+ spspieces = sp .getSpecies ()
342+ # one of the edge (osc_different_vols) case where pool is a enzyme's parent and
343+ # product, which case the stoichiometry = 2 which is ideally correct for SBML simulator
344+ # but for moose we need to reduce stoichiometry as we connect enzyme parent
345+ if enzPool == spspieces and int (sp .getStoichiometry ()) > 1 :
346+ enz_prdlist [spspieces ] = int (sp .getStoichiometry ())- 1
347+ else :
348+ enz_prdlist [spspieces ] = int (sp .getStoichiometry ())
325349
326350 for si in range (0 , len (sublist )):
327351 sl = sublist [si ]
@@ -493,6 +517,8 @@ def getCmptAnnotation(obj):
493517 annotateMap [nodeName ] = nodeValue
494518 if nodeName == "surround" :
495519 annotateMap [nodeName ] = nodeValue
520+ if nodeName == "basePath" :
521+ annotateMap [nodeName ] = nodeValue
496522 return annotateMap
497523
498524def getObjAnnotation (obj , modelAnnotationInfo ):
@@ -1144,7 +1170,8 @@ def createRules(model, specInfoMap, globparameterIdValue):
11441170 comptvolume .append (poolsCompt .name )
11451171 numVars = funcId .numVars
11461172 x = funcId .path + '/x[' + str (numVars ) + ']'
1147- speFunXterm [i ] = 'x' + str (numVars )
1173+ #speFunXterm[i] = 'x' + str(numVars)
1174+ speFunXterm ['x' + str (numVars )] = i
11481175 moose .connect (specMapList , 'nOut' , x , 'input' )
11491176 funcId .numVars = numVars + 1
11501177
@@ -1157,7 +1184,10 @@ def createRules(model, specInfoMap, globparameterIdValue):
11571184 for mem in ruleMemlist :
11581185 if (mem in specInfoMap ):
11591186 #exp1 = exp.replace(mem, str(speFunXterm[mem]))
1160- exp1 = re .sub (r'\b%s\b' % (mem ), speFunXterm [mem ], exp )
1187+ #exp1 = re.sub(r'\b%s\b'% (mem), speFunXterm[mem], exp)
1188+ exp1 = re .sub (r'\b%s\b' % (mem ), list (speFunXterm .keys ())[list (speFunXterm .values ()).index (mem )], exp ,1 )
1189+ speFunXterm .pop (list (speFunXterm .keys ())[list (speFunXterm .values ()).index (mem )])
1190+
11611191 exp = exp1
11621192 elif (mem in globparameterIdValue ):
11631193 #exp1 = exp.replace(mem, str(globparameterIdValue[mem]))
@@ -1427,6 +1457,7 @@ def createCompartment(basePath, model, comptSbmlidMooseIdMap):
14271457 return False , "Model has no compartment, atleast one compartment should exist to display in the widget"
14281458 else :
14291459 endo_surr = {}
1460+ toRewritebasepath = True
14301461 for c in range (0 , model .getNumCompartments ()):
14311462 compt = model .getCompartment (c )
14321463 # print("Compartment " + str(c) + ": "+ UnitDefinition.printUnits(compt.getDerivedUnitDefinition()))
@@ -1461,6 +1492,18 @@ def createCompartment(basePath, model, comptSbmlidMooseIdMap):
14611492 name = sbmlCmptId
14621493 cmptAnnotaInfo = {}
14631494 cmptAnnotaInfo = getCmptAnnotation (compt )
1495+ if "basePath" in cmptAnnotaInfo .keys ():
1496+ nl = list (filter (None , (cmptAnnotaInfo ["basePath" ]).split ('/' )))
1497+ pathAnno = ""
1498+ if len (nl ) > 0 :
1499+ for i in range (0 ,len (nl )):
1500+ pathAnno = pathAnno + '/' + nl [i ]
1501+ if not moose .exists (basePath .path + pathAnno ):
1502+ rewritebasepath = moose .Neutral (basePath .path + pathAnno )
1503+ if toRewritebasepath :
1504+ basePath = rewritebasepath
1505+ toRewritebasepath = False
1506+
14641507 if "Mesh" in cmptAnnotaInfo .keys ():
14651508 if cmptAnnotaInfo ["Mesh" ] == "CubeMesh" or cmptAnnotaInfo ["Mesh" ] == "NeuroMesh" :
14661509 mooseCmptId = moose .CubeMesh (basePath .path + '/' + name )
@@ -1492,7 +1535,7 @@ def createCompartment(basePath, model, comptSbmlidMooseIdMap):
14921535 elif key in comptSbmlidMooseIdMap :
14931536 del (comptSbmlidMooseIdMap [key ])
14941537 return False ," EndoMesh's surrounding compartment missing or wrong deleting the compartment check the file"
1495- return True ,""
1538+ return True ,"" , basePath
14961539
14971540def setupConcChannel (reac , rName , specInfoMap , reactSBMLIdMooseId ,
14981541 modelAnnotaInfo , model , globparameterIdValue ):
0 commit comments