Skip to content

Commit 17e1dd1

Browse files
dilawarDilawar Singh
and
Dilawar Singh
authored
Merged hrani changes and mine from new bindings. (#412)
removed 'basestring' Co-authored-by: Dilawar Singh <[email protected]>
1 parent 0ee20b3 commit 17e1dd1

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

Diff for: python/moose/genesis/writeKkit.py

+26-24
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
__email__ = "[email protected]"
1111
__status__ = "Development"
1212
__updated__ = "Jan 08 2020"
13+
1314
#Jan 8: added a line to add compartment info
1415
# permeability from moose is in uM which to be converted to mM for genesis
1516
#2020
@@ -253,7 +254,7 @@ def writeConcChan(modelpath,f,sceneitems):
253254
if len(moose.element(cChan).neighbors['setNumChan']) == 1:
254255
chanParent = moose.element(moose.element(cChan).neighbors['setNumChan'][0])
255256

256-
if not (isinstance(chanParent,moose.PoolBase)):
257+
if not chanParent.isA['PoolBase']:
257258
print(" raise exception Channel doesn't have pool as parent %s",moose.element(cChan).path)
258259
return False,"raise exception Channel doesn't have pool as parent"
259260
else:
@@ -307,7 +308,7 @@ def writeEnz( modelpath,f,sceneitems):
307308
if len(moose.element(enz).neighbors['enzDest']) == 1:
308309
enzParent = moose.element(moose.element(enz).neighbors['enzDest'][0])
309310

310-
if not (isinstance(enzParent,moose.PoolBase)):
311+
if not enzParent.isA['PoolBase']:
311312
print(" raise exception enz doesn't have pool as parent %s",moose.element(enz).path)
312313
return False
313314
else:
@@ -431,29 +432,28 @@ def writeReac(modelpath,f,sceneitems):
431432
return reacList,error
432433

433434
def trimPath(mobj):
434-
original = mobj
435435
mobj = moose.element(mobj)
436-
found = False
437-
while not isinstance(mobj,moose.ChemCompt) and mobj.path != "/":
436+
original = mobj
437+
while not mobj.isA['ChemCompt'] and mobj.path != "/":
438438
mobj = moose.element(mobj.parent)
439-
found = True
439+
440440
if mobj.path == "/":
441-
print(original, " object doesn't have compartment as a parent ")
441+
print("%s object doesn't have a parent compartment as a parent." % original)
442442
return
443-
#other than the kinetics compartment, all the othername are converted to group in Genesis which are place under /kinetics
443+
444+
# other than the kinetics compartment, all the othername are converted to group in Genesis which are place under /kinetics
444445
# Any moose object comes under /kinetics then one level down the path is taken.
445446
# e.g /group/poolObject or /Reac
446-
if found:
447-
if mobj.name != "kinetics":# and ( (mobj.className != "CubeMesh") and (mobj.className != "CylMesh") and (mobj.className != "EndoMesh") and (mobj.className != "NeuroMesh")):
448-
splitpath = original.path[(original.path.find(mobj.name)):len(original.path)]
449-
else:
450-
pos = original.path.find(mobj.name)
451-
slash = original.path.find('/',pos+1)
452-
splitpath = original.path[slash+1:len(original.path)]
453-
splitpath = re.sub(r"\[[0-9]+\]", "", splitpath)
454-
s = splitpath.replace("_dash_",'-')
455-
s = splitpath.replace("_space_","_")
456-
return s
447+
if mobj.name != "kinetics":# and ( (mobj.className != "CubeMesh") and (mobj.className != "CylMesh") and (mobj.className != "EndoMesh") and (mobj.className != "NeuroMesh")):
448+
splitpath = original.path[(original.path.find(mobj.name)):len(original.path)]
449+
else:
450+
pos = original.path.find(mobj.name)
451+
slash = original.path.find('/',pos+1)
452+
splitpath = original.path[slash+1:len(original.path)]
453+
splitpath = re.sub(r"\[[0-9]+\]", "", splitpath)
454+
s = splitpath.replace("_dash_",'-')
455+
s = splitpath.replace("_space_","_")
456+
return s
457457

458458
# def writeSumtotal( modelpath,f):
459459
# funclist = moose.wildcardFind(modelpath+'/##[ISA=Function]')
@@ -585,22 +585,24 @@ def writePool(modelpath,f,volIndex,sceneitems):
585585

586586
for p in moose.wildcardFind(modelpath+'/##[0][ISA=PoolBase]'):
587587
if findCompartment(p) == moose.element('/'):
588-
error = error + " \n "+p.path+ " doesn't have compartment ignored to write to genesis"
588+
error += "\n%s doesn't have compartment ignored to write to genesis" % p
589589
else:
590590
slave_enable = 0
591-
if (p.className == "BufPool" or p.className == "ZombieBufPool"):
591+
if p.isA["BufPool"] or p.isA["ZombieBufPool"]:
592592
pool_children = p.children
593593
if pool_children== 0:
594594
slave_enable = 4
595595
else:
596596
for pchild in pool_children:
597-
if not(pchild.className == "ZombieFunction") and not(pchild.className == "Function"):
597+
if (not pchild.isA["ZombieFunction"]) and (not pchild.isA["Function"]):
598598
slave_enable = 4
599599
else:
600600
slave_enable = 0
601601
break
602-
if (p.parent.className != "Enz" and p.parent.className !='ZombieEnz'):
603-
#Assuming "p.parent.className !=Enzyme is cplx which is not written to genesis"
602+
603+
pp = moose.element(p.parent)
604+
if (not pp.isA['Enz']) and (not pp.isA['ZombieEnz']):
605+
# Assuming "p.parent.className !=Enzyme is cplx which is not written to genesis"
604606

605607
# x = sceneitems[p]['x']
606608
# y = sceneitems[p]['y']

0 commit comments

Comments
 (0)