99__maintainer__ = "Harsha Rani"
10101111__status__ = "Development"
12- __updated__ = "Nov 22 2018"
12+ __updated__ = "Dec 08 2018"
1313
1414# 2018
15+ # Dec 08: using restoreXreacs from fixXreacs
1516# Nov 22: searched for _xfer_ instead of xfer
1617# Nov 21: xfer pool are not written and cleaned up if part of Reaction/Enzyme or notes,
1718# group are checked under all the mesh
2728import moose
2829from moose .chemUtil .chemConnectUtil import *
2930from moose .chemUtil .graphUtils import *
30-
31+ from moose .fixXreacs import restoreXreacs
32+
3133foundmatplotlib_ = False
3234try :
3335 import matplotlib
@@ -75,7 +77,7 @@ def mooseWriteKkit( modelpath, filename, sceneitems={}):
7577 global cmin ,cmax ,xmin ,xmax ,ymin ,ymax
7678 cmin , xmin , ymin = 0 , 0 , 0
7779 cmax , xmax , ymax = 1 , 1 , 1
78-
80+ moose . fixXreacs . restoreXreacs ( modelpath )
7981 compt = moose .wildcardFind (modelpath + '/##[0][ISA=ChemCompt]' )
8082 maxVol = estimateDefaultVol (compt )
8183 positionInfoExist = True
@@ -184,12 +186,10 @@ def calPrime(x):
184186
185187def storeCplxEnzMsgs ( enz , f ):
186188 for sub in enz .neighbors ["subOut" ]:
187- sub = xfer (sub )
188189 s = "addmsg /kinetics/" + trimPath ( moose .element (sub ) ) + " /kinetics/" + trimPath (enz ) + " SUBSTRATE n \n " ;
189190 s = s + "addmsg /kinetics/" + trimPath ( enz ) + " /kinetics/" + trimPath ( sub ) + " REAC sA B \n " ;
190191 f .write (s )
191192 for prd in enz .neighbors ["prd" ]:
192- prd = xfer (prd )
193193 s = "addmsg /kinetics/" + trimPath ( enz ) + " /kinetics/" + trimPath (prd ) + " MM_PRD pA\n " ;
194194 f .write ( s )
195195 for enzOut in enz .neighbors ["enzOut" ]:
@@ -202,13 +202,11 @@ def storeMMenzMsgs( enz, f):
202202 prdList = enz .neighbors ["prd" ]
203203 enzDestList = enz .neighbors ["enzDest" ]
204204 for esub in subList :
205- esub = xfer (esub )
206205 es = "addmsg /kinetics/" + trimPath (moose .element (esub )) + " /kinetics/" + trimPath (enz ) + " SUBSTRATE n \n " ;
207206 es = es + "addmsg /kinetics/" + trimPath (enz ) + " /kinetics/" + trimPath (moose .element (esub )) + " REAC sA B \n " ;
208207 f .write (es )
209208
210209 for eprd in prdList :
211- eprd = xfer (eprd )
212210 es = "addmsg /kinetics/" + trimPath ( enz ) + " /kinetics/" + trimPath ( moose .element (eprd )) + " MM_PRD pA \n " ;
213211 f .write (es )
214212 for eenzDest in enzDestList :
@@ -223,16 +221,6 @@ def storeEnzMsg( enzList, f):
223221 else :
224222 storeCplxEnzMsgs ( enz , f )
225223
226- def xfer (xferpool ):
227- if re .search ("_xfer_" ,xferpool .name ):
228- modelRoot = xferpool .path [0 :xferpool .path .index ('/' ,1 )]
229- xrefPool = xferpool .name [:xferpool .name .index ("_xfer_" )]
230- xrefCompt = xferpool .name [xferpool .name .index ("_xfer_" ) + len ("_xfer_" ):]
231- orgCompt = moose .wildcardFind (modelRoot + '/##[FIELD(name)=' + xrefCompt + ']' )[0 ]
232- orgPool = moose .wildcardFind (orgCompt .path + '/##[FIELD(name)=' + xrefPool + ']' )[0 ]
233- xferpool = orgPool
234- return xferpool
235-
236224def storeChanMsg (chanList ,f ):
237225 for channel in chanList :
238226 for chanOL in channel .neighbors ['out' ]:
@@ -392,13 +380,11 @@ def storeReacMsg(reacList,f):
392380 sublist = reac .neighbors ["subOut" ]
393381 prdlist = reac .neighbors ["prd" ]
394382 for sub in sublist :
395- sub = xfer (sub )
396383 s = "addmsg /kinetics/" + trimPath ( sub ) + " /kinetics/" + reacPath + " SUBSTRATE n \n " ;
397384 s = s + "addmsg /kinetics/" + reacPath + " /kinetics/" + trimPath ( sub ) + " REAC A B \n " ;
398385 f .write (s )
399386
400387 for prd in prdlist :
401- prd = xfer (prd )
402388 s = "addmsg /kinetics/" + trimPath ( prd ) + " /kinetics/" + reacPath + " PRODUCT n \n " ;
403389 s = s + "addmsg /kinetics/" + reacPath + " /kinetics/" + trimPath ( prd ) + " REAC B A\n " ;
404390 f .write ( s )
@@ -599,64 +585,63 @@ def writePool(modelpath,f,volIndex,sceneitems):
599585 textcolor = ""
600586
601587 for p in moose .wildcardFind (modelpath + '/##[0][ISA=PoolBase]' ):
602- if not re .search ("xfer" ,p .name ):
603- if findCompartment (p ) == moose .element ('/' ):
604- error = error + " \n " + p .path + " doesn't have compartment ignored to write to genesis"
605- else :
606- slave_enable = 0
607- if (p .className == "BufPool" or p .className == "ZombieBufPool" ):
608- pool_children = p .children
609- if pool_children == 0 :
610- slave_enable = 4
611- else :
612- for pchild in pool_children :
613- if not (pchild .className == "ZombieFunction" ) and not (pchild .className == "Function" ):
614- slave_enable = 4
615- else :
616- slave_enable = 0
617- break
618- if (p .parent .className != "Enz" and p .parent .className != 'ZombieEnz' ):
619- #Assuming "p.parent.className !=Enzyme is cplx which is not written to genesis"
620-
621- # x = sceneitems[p]['x']
622- # y = sceneitems[p]['y']
623- # if sceneitems != None:
624- # value = sceneitems[p]
625- # x = calPrime(value['x'])
626- # y = calPrime(value['y'])
627-
628- pinfo = p .path + '/info'
629- if moose .exists (pinfo ):
630- x = sceneitems [p ]['x' ]
631- y = sceneitems [p ]['y' ]
632- else :
633- x = 0
634- y = 0
635- error = error + " \n x and y co-ordinates are not specified for `" + p .name + "` zero will be assigned" + " \n "
636-
637- if moose .exists (pinfo ):
638- color = moose .Annotator (pinfo ).getField ('color' )
639- color = getColorCheck (color ,GENESIS_COLOR_SEQUENCE )
640- textcolor = moose .Annotator (pinfo ).getField ('textColor' )
641- textcolor = getColorCheck (textcolor ,GENESIS_COLOR_SEQUENCE )
642- poolsCmpt = findCompartment (p )
643- geometryName = volIndex [float (poolsCmpt .volume )]
644- volume = p .volume * NA * 1e-3
645- if color == "" or color == " " :
646- color = getRandColor ()
647- if textcolor == "" or textcolor == " " :
648- textcolor = getRandColor ()
649- f .write ("simundump kpool /kinetics/" + trimPath (p ) + " 0 " +
650- str (p .diffConst ) + " " +
651- str (0 ) + " " +
652- str (0 ) + " " +
653- str (0 ) + " " +
654- str (p .nInit ) + " " +
655- str (0 ) + " " + str (0 ) + " " +
656- str (volume )+ " " +
657- str (slave_enable ) +
658- " /kinetics" + geometryName + " " +
659- str (color ) + " " + str (textcolor ) + " " + str (int (x )) + " " + str (int (y )) + " " + str (0 )+ "\n " )
588+ if findCompartment (p ) == moose .element ('/' ):
589+ error = error + " \n " + p .path + " doesn't have compartment ignored to write to genesis"
590+ else :
591+ slave_enable = 0
592+ if (p .className == "BufPool" or p .className == "ZombieBufPool" ):
593+ pool_children = p .children
594+ if pool_children == 0 :
595+ slave_enable = 4
596+ else :
597+ for pchild in pool_children :
598+ if not (pchild .className == "ZombieFunction" ) and not (pchild .className == "Function" ):
599+ slave_enable = 4
600+ else :
601+ slave_enable = 0
602+ break
603+ if (p .parent .className != "Enz" and p .parent .className != 'ZombieEnz' ):
604+ #Assuming "p.parent.className !=Enzyme is cplx which is not written to genesis"
605+
606+ # x = sceneitems[p]['x']
607+ # y = sceneitems[p]['y']
608+ # if sceneitems != None:
609+ # value = sceneitems[p]
610+ # x = calPrime(value['x'])
611+ # y = calPrime(value['y'])
612+
613+ pinfo = p .path + '/info'
614+ if moose .exists (pinfo ):
615+ x = sceneitems [p ]['x' ]
616+ y = sceneitems [p ]['y' ]
617+ else :
618+ x = 0
619+ y = 0
620+ error = error + " \n x and y co-ordinates are not specified for `" + p .name + "` zero will be assigned" + " \n "
621+
622+ if moose .exists (pinfo ):
623+ color = moose .Annotator (pinfo ).getField ('color' )
624+ color = getColorCheck (color ,GENESIS_COLOR_SEQUENCE )
625+ textcolor = moose .Annotator (pinfo ).getField ('textColor' )
626+ textcolor = getColorCheck (textcolor ,GENESIS_COLOR_SEQUENCE )
627+ poolsCmpt = findCompartment (p )
628+ geometryName = volIndex [float (poolsCmpt .volume )]
629+ volume = p .volume * NA * 1e-3
630+ if color == "" or color == " " :
631+ color = getRandColor ()
632+ if textcolor == "" or textcolor == " " :
633+ textcolor = getRandColor ()
634+ f .write ("simundump kpool /kinetics/" + trimPath (p ) + " 0 " +
635+ str (p .diffConst ) + " " +
636+ str (0 ) + " " +
637+ str (0 ) + " " +
638+ str (0 ) + " " +
639+ str (p .nInit ) + " " +
640+ str (0 ) + " " + str (0 ) + " " +
641+ str (volume )+ " " +
642+ str (slave_enable ) +
643+ " /kinetics" + geometryName + " " +
644+ str (color ) + " " + str (textcolor ) + " " + str (int (x )) + " " + str (int (y )) + " " + str (0 )+ "\n " )
660645 return error
661646
662647def getColorCheck (color ,GENESIS_COLOR_SEQUENCE ):
0 commit comments