def createChemModel(neuroCompt, spineCompt, psdCompt): # Stuff in spine + psd #psdCa = createPool( psdCompt, 'Ca', 0.0001 ) psdGluR = createPool(psdCompt, 'psdGluR', 1) headCa = createPool(spineCompt, 'Ca', 1e-4) headGluR = createPool(spineCompt, 'headGluR', 2) toPsd = createPool(spineCompt, 'toPsd', 0) toPsdInact = createPool(spineCompt, 'toPsdInact', 1e-3) turnOnPsd = moose.Reac(spineCompt.path + '/turnOnPsd') moose.connect(turnOnPsd, 'sub', headCa, 'reac', 'OneToOne') moose.connect(turnOnPsd, 'sub', toPsdInact, 'reac', 'OneToOne') moose.connect(turnOnPsd, 'prd', toPsd, 'reac', 'OneToOne') turnOnPsd.Kf = 1e3 turnOnPsd.Kb = 1 toPsdEnz = moose.Enz(toPsd.path + '/enz') toPsdEnzCplx = moose.Pool(toPsdEnz.path + '/cplx') toPsdEnzCplx.concInit = 0 moose.connect(toPsdEnz, 'enz', toPsd, 'reac', 'OneToOne') moose.connect(toPsdEnz, 'sub', headGluR, 'reac', 'OneToOne') moose.connect(toPsdEnz, 'prd', psdGluR, 'reac', 'OneToOne') moose.connect(toPsdEnz, 'cplx', toPsdEnzCplx, 'reac', 'OneToOne') toPsdEnz.Km = 1.0e-3 toPsdEnz.kcat = 10.0 fromPsd = moose.Reac(psdCompt.path + '/fromPsd') moose.connect(fromPsd, 'sub', psdGluR, 'reac', 'OneToOne') moose.connect(fromPsd, 'prd', headGluR, 'reac', 'OneToOne') fromPsd.Kf = 0.5 fromPsd.Kb = 0.0 # Stuff in dendrite dendCa = createPool(neuroCompt, 'Ca', 1e-4) bufCa = moose.Pool(neuroCompt.path + '/bufCa') bufCa.concInit = 1e-4 pumpCa = moose.Reac(neuroCompt.path + '/pumpCa') moose.connect(pumpCa, 'sub', dendCa, 'reac', 'OneToOne') moose.connect(pumpCa, 'prd', bufCa, 'reac', 'OneToOne') pumpCa.Kf = 1 pumpCa.Kb = 1 dendKinaseInact = createPool(neuroCompt, 'inact_kinase', 1e-4) dendKinase = createPool(neuroCompt, 'Ca.kinase', 0.0) dendTurnOnKinase = moose.Reac(neuroCompt.path + '/turnOnKinase') moose.connect(dendTurnOnKinase, 'sub', dendCa, 'reac') moose.connect(dendTurnOnKinase, 'sub', dendKinaseInact, 'reac') moose.connect(dendTurnOnKinase, 'prd', dendKinase, 'reac') dendTurnOnKinase.Kf = 50000 dendTurnOnKinase.Kb = 1 dendKinaseEnz = moose.Enz(dendKinase.path + '/enz') dendKinaseEnzCplx = moose.Pool(dendKinase.path + '/enz/cplx') kChan = createPool(neuroCompt, 'kChan', 1e-3) kChan_p = createPool(neuroCompt, 'kChan_p', 0.0) moose.connect(dendKinaseEnz, 'enz', dendKinase, 'reac', 'OneToOne') moose.connect(dendKinaseEnz, 'sub', kChan, 'reac', 'OneToOne') moose.connect(dendKinaseEnz, 'prd', kChan_p, 'reac', 'OneToOne') moose.connect(dendKinaseEnz, 'cplx', dendKinaseEnzCplx, 'reac', 'OneToOne') dendKinaseEnz.Km = 1e-4 dendKinaseEnz.kcat = 20 dendPhosphatase = moose.Reac(neuroCompt.path + '/phosphatase') moose.connect(dendPhosphatase, 'sub', kChan_p, 'reac') moose.connect(dendPhosphatase, 'prd', kChan, 'reac') dendPhosphatase.Kf = 1 dendPhosphatase.Kb = 0.0
def makeModel(): """ This function creates a bistable reaction system using explicit MOOSE calls rather than load from a file. The reaction is:: a ---b---> 2b # b catalyzes a to form more of b. 2b ---c---> a # c catalyzes b to form a. a <======> 2b # a interconverts to b. """ # create container for model model = moose.Neutral('model') compartment = moose.CubeMesh('/model/compartment') compartment.volume = 1e-15 # the mesh is created automatically by the compartment mesh = moose.element('/model/compartment/mesh') # create molecules and reactions size = 100 for i in range(size): a = moose.Pool('/model/compartment/a%s' % i) b = moose.Pool('/model/compartment/b%s' % i) c = moose.Pool('/model/compartment/c%s' % i) enz1 = moose.Enz('%s/enz1' % a.path) enz2 = moose.Enz('%s/enz2' % c.path) cplx1 = moose.Pool('%s/cplx' % enz1.path) cplx2 = moose.Pool('%s/cplx' % enz2.path) reac = moose.Reac('/model/compartment/reac%s' % i) # connect them up for reactions moose.connect(enz1, 'sub', a, 'reac') moose.connect(enz1, 'prd', b, 'reac') moose.connect(enz1, 'prd', b, 'reac') # Note 2 molecules of b. moose.connect(enz1, 'enz', b, 'reac') moose.connect(enz1, 'cplx', cplx1, 'reac') moose.connect(enz2, 'sub', b, 'reac') moose.connect(enz2, 'sub', b, 'reac') # Note 2 molecules of b. moose.connect(enz2, 'prd', a, 'reac') moose.connect(enz2, 'enz', c, 'reac') moose.connect(enz2, 'cplx', cplx2, 'reac') moose.connect(reac, 'sub', a, 'reac') moose.connect(reac, 'prd', b, 'reac') moose.connect(reac, 'prd', b, 'reac') # Note 2 order in b. add_table(a) add_table(b) add_table(c) # Assign parameters a.concInit = 1 b.concInit = 0 c.concInit = 0.01 enz1.kcat = 0.4 enz1.Km = 4 enz2.kcat = 0.6 enz2.Km = 0.01 reac.Kf = 0.001 reac.Kb = 0.01 return compartment
def makeModel(): # create container for model model = moose.Neutral( 'model' ) compartment = moose.CubeMesh( '/model/compartment' ) compartment.volume = 1e-20 # the mesh is created automatically by the compartment mesh = moose.element( '/model/compartment/mesh' ) # create molecules and reactions a = moose.Pool( '/model/compartment/a' ) b = moose.Pool( '/model/compartment/b' ) c = moose.Pool( '/model/compartment/c' ) enz1 = moose.Enz( '/model/compartment/b/enz1' ) enz2 = moose.Enz( '/model/compartment/c/enz2' ) cplx1 = moose.Pool( '/model/compartment/b/enz1/cplx' ) cplx2 = moose.Pool( '/model/compartment/c/enz2/cplx' ) reac = moose.Reac( '/model/compartment/reac' ) # connect them up for reactions moose.connect( enz1, 'sub', a, 'reac' ) moose.connect( enz1, 'prd', b, 'reac' ) moose.connect( enz1, 'enz', b, 'reac' ) moose.connect( enz1, 'cplx', cplx1, 'reac' ) moose.connect( enz2, 'sub', b, 'reac' ) moose.connect( enz2, 'prd', a, 'reac' ) moose.connect( enz2, 'enz', c, 'reac' ) moose.connect( enz2, 'cplx', cplx2, 'reac' ) moose.connect( reac, 'sub', a, 'reac' ) moose.connect( reac, 'prd', b, 'reac' ) # connect them up to the compartment for volumes #for x in ( a, b, c, cplx1, cplx2 ): # moose.connect( x, 'mesh', mesh, 'mesh' ) # Assign parameters a.concInit = 1 b.concInit = 0 c.concInit = 0.01 enz1.kcat = 0.4 enz1.Km = 4 enz2.kcat = 0.6 enz2.Km = 0.01 reac.Kf = 0.001 reac.Kb = 0.01 # Create the output tables graphs = moose.Neutral( '/model/graphs' ) outputA = moose.Table2( '/model/graphs/concA' ) outputB = moose.Table2( '/model/graphs/concB' ) # connect up the tables moose.connect( outputA, 'requestOut', a, 'getConc' ); moose.connect( outputB, 'requestOut', b, 'getConc' ); '''
def makeModel(): """This function creates a bistable reaction system using explicit MOOSE calls rather than load from a file. The reaction is:: a ---b---> 2b # b catalyzes a to form more of b. 2b ---c---> a # c catalyzes b to form a. a <======> 2b # a interconverts to b. """ # create container for model model = moose.Neutral("model") compartment = moose.CubeMesh("/model/compartment") compartment.volume = 1e-15 # the mesh is created automatically by the compartment mesh = moose.element("/model/compartment/mesh") # create molecules and reactions a = moose.BufPool("/model/compartment/a") b = moose.Pool("/model/compartment/b") c = moose.Pool("/model/compartment/c") enz1 = moose.Enz("/model/compartment/b/enz1") enz2 = moose.Enz("/model/compartment/c/enz2") cplx1 = moose.Pool("/model/compartment/b/enz1/cplx") cplx2 = moose.Pool("/model/compartment/c/enz2/cplx") reac = moose.Reac("/model/compartment/reac") # connect them up for reactions moose.connect(enz1, "sub", a, "reac") moose.connect(enz1, "prd", b, "reac") moose.connect(enz1, "prd", b, "reac") # Note 2 molecules of b. moose.connect(enz1, "enz", b, "reac") moose.connect(enz1, "cplx", cplx1, "reac") moose.connect(enz2, "sub", b, "reac") moose.connect(enz2, "sub", b, "reac") # Note 2 molecules of b. moose.connect(enz2, "prd", a, "reac") moose.connect(enz2, "enz", c, "reac") moose.connect(enz2, "cplx", cplx2, "reac") moose.connect(reac, "sub", a, "reac") moose.connect(reac, "prd", b, "reac") moose.connect(reac, "prd", b, "reac") # Note 2 order in b. # Assign parameters a.concInit = 1 b.concInit = 0 c.concInit = 0.01 enz1.kcat = 0.4 enz1.Km = 4 enz2.kcat = 0.6 enz2.Km = 0.01 reac.Kf = 0.001 reac.Kb = 0.01 return compartment
def createChemModel(neuroCompt): dendCa = createPool(neuroCompt, 'Ca', 1e-4) dendKinaseInact = createPool(neuroCompt, 'inact_kinase', 1e-4) dendKinase = createPool(neuroCompt, 'Ca.kinase', 0.0) dendTurnOnKinase = moose.Reac(neuroCompt.path + '/turnOnKinase') moose.connect(dendTurnOnKinase, 'sub', dendCa, 'reac') moose.connect(dendTurnOnKinase, 'sub', dendKinaseInact, 'reac') moose.connect(dendTurnOnKinase, 'prd', dendKinase, 'reac') dendTurnOnKinase.Kf = 50000 dendTurnOnKinase.Kb = 1 dendKinaseEnz = moose.Enz(dendKinase.path + '/enz') dendKinaseEnzCplx = moose.Pool(dendKinase.path + '/enz/cplx') kChan = createPool(neuroCompt, 'kChan', 1e-3) kChan_p = createPool(neuroCompt, 'kChan_p', 0.0) moose.connect(dendKinaseEnz, 'enz', dendKinase, 'reac', 'OneToOne') moose.connect(dendKinaseEnz, 'sub', kChan, 'reac', 'OneToOne') moose.connect(dendKinaseEnz, 'prd', kChan_p, 'reac', 'OneToOne') moose.connect(dendKinaseEnz, 'cplx', dendKinaseEnzCplx, 'reac', 'OneToOne') dendKinaseEnz.Km = 1e-4 dendKinaseEnz.kcat = 20 dendPhosphatase = moose.Reac(neuroCompt.path + '/phosphatase') moose.connect(dendPhosphatase, 'sub', kChan_p, 'reac') moose.connect(dendPhosphatase, 'prd', kChan, 'reac') dendPhosphatase.Kf = 1 dendPhosphatase.Kb = 0.0
def setupEnzymaticReaction(enz, groupName, enzName, specInfoMap, modelAnnotaInfo): enzPool = (modelAnnotaInfo[groupName]["enzyme"]) enzPool = str(idBeginWith(enzPool)) enzParent = specInfoMap[enzPool]["Mpath"] cplx = (modelAnnotaInfo[groupName]["complex"]) cplx = str(idBeginWith(cplx)) complx = moose.element(specInfoMap[cplx]["Mpath"].path) enzyme_ = moose.Enz(enzParent.path + '/' + enzName) moose.move(complx, enzyme_) moose.connect(enzyme_, "cplx", complx, "reac") moose.connect(enzyme_, "enz", enzParent, "reac") sublist = (modelAnnotaInfo[groupName]["substrate"]) prdlist = (modelAnnotaInfo[groupName]["product"]) for si in range(0, len(sublist)): sl = sublist[si] sl = str(idBeginWith(sl)) mSId = specInfoMap[sl]["Mpath"] moose.connect(enzyme_, "sub", mSId, "reac") for pi in range(0, len(prdlist)): pl = prdlist[pi] pl = str(idBeginWith(pl)) mPId = specInfoMap[pl]["Mpath"] moose.connect(enzyme_, "prd", mPId, "reac") if (enz.isSetNotes): pullnotes(enz, enzyme_) return enzyme_, True
def makeModel(): # create container for model model = moose.Neutral('model') compartment = moose.CubeMesh('/model/compartment') compartment.volume = 1e-20 # the mesh is created automatically by the compartment mesh = moose.element('/model/compartment/mesh') # create molecules and reactions a = moose.Pool('/model/compartment/a') b = moose.Pool('/model/compartment/b') c = moose.Pool('/model/compartment/c') enz1 = moose.Enz('/model/compartment/b/enz1') enz2 = moose.Enz('/model/compartment/c/enz2') cplx1 = moose.Pool('/model/compartment/b/enz1/cplx') cplx2 = moose.Pool('/model/compartment/c/enz2/cplx') reac = moose.Reac('/model/compartment/reac') # connect them up for reactions moose.connect(enz1, 'sub', a, 'reac') moose.connect(enz1, 'prd', b, 'reac') moose.connect(enz1, 'enz', b, 'reac') moose.connect(enz1, 'cplx', cplx1, 'reac') moose.connect(enz2, 'sub', b, 'reac') moose.connect(enz2, 'prd', a, 'reac') moose.connect(enz2, 'enz', c, 'reac') moose.connect(enz2, 'cplx', cplx2, 'reac') moose.connect(reac, 'sub', a, 'reac') moose.connect(reac, 'prd', b, 'reac') # connect them up to the compartment for volumes #for x in ( a, b, c, cplx1, cplx2 ): # moose.connect( x, 'mesh', mesh, 'mesh' ) # Assign parameters a.concInit = 1 b.concInit = 0 c.concInit = 0.01 enz1.kcat = 0.4 enz1.Km = 4 enz2.kcat = 0.6 enz2.Km = 0.01 reac.Kf = 0.001 reac.Kb = 0.01 # Create the output tables graphs = moose.Neutral('/model/graphs') outputA = moose.Table('/model/graphs/concA') outputB = moose.Table('/model/graphs/concB') # connect up the tables moose.connect(outputA, 'requestOut', a, 'getConc') moose.connect(outputB, 'requestOut', b, 'getConc') # Schedule the whole lot moose.setClock(4, 0.01) # for the computational objects moose.setClock(8, 1.0) # for the plots # The wildcard uses # for single level, and ## for recursive. moose.useClock(4, '/model/compartment/##', 'process') moose.useClock(8, '/model/graphs/#', 'process')
def checkCreate(scene, view, modelpath, mobj, string, ret_string, num, event_pos, layoutPt): # The variable 'compt' will be empty when dropping cubeMesh,cyclMesh, but rest it shd be # compartment # if modelpath.find('/',1) > -1: # modelRoot = modelpath[0:modelpath.find('/',1)] # else: # modelRoot = modelpath print "28 ", modelpath if moose.exists(modelpath + '/info'): mType = moose.Annotator((moose.element(modelpath + '/info'))).modeltype itemAtView = view.sceneContainerPt.itemAt(view.mapToScene(event_pos)) pos = view.mapToScene(event_pos) modelpath = moose.element(modelpath) if num: string_num = ret_string + str(num) else: string_num = ret_string if string == "CubeMesh" or string == "CylMesh": if string == "CylMesh": mobj = moose.CylMesh(modelpath.path + '/' + string_num) else: mobj = moose.CubeMesh(modelpath.path + '/' + string_num) mobj.volume = 1e-15 mesh = moose.element(mobj.path + '/mesh') qGItem = ComptItem(scene, pos.toPoint().x(), pos.toPoint().y(), 100, 100, mobj) qGItem.setPen( QtGui.QPen(Qt.QColor(66, 66, 66, 100), 1, Qt.Qt.SolidLine, Qt.Qt.RoundCap, Qt.Qt.RoundJoin)) view.sceneContainerPt.addItem(qGItem) qGItem.cmptEmitter.connect( qGItem.cmptEmitter, QtCore.SIGNAL("qgtextPositionChange(PyQt_PyObject)"), layoutPt.positionChange1) qGItem.cmptEmitter.connect( qGItem.cmptEmitter, QtCore.SIGNAL("qgtextItemSelectedChange(PyQt_PyObject)"), layoutPt.objectEditSlot) compartment = qGItem layoutPt.qGraCompt[mobj] = qGItem view.emit(QtCore.SIGNAL("dropped"), mobj) elif string == "Pool" or string == "BufPool": #getting pos with respect to compartment otherwise if compartment is moved then pos would be wrong posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() if string == "Pool": poolObj = moose.Pool(mobj.path + '/' + string_num) else: poolObj = moose.BufPool(mobj.path + '/' + string_num) poolinfo = moose.Annotator(poolObj.path + '/info') #Compartment's one Pool object is picked to get the font size qGItem = PoolItem(poolObj, itemAtView) layoutPt.mooseId_GObj[poolObj] = qGItem posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() bgcolor = getRandColor() qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y(), QtGui.QColor('green'), bgcolor) poolinfo.color = str(bgcolor.getRgb()) view.emit(QtCore.SIGNAL("dropped"), poolObj) setupItem(modelpath.path, layoutPt.srcdesConnection) layoutPt.drawLine_arrow(False) x, y = roundoff(qGItem.scenePos(), layoutPt) poolinfo.x = x poolinfo.y = y #Dropping is on compartment then update Compart size if isinstance(mobj, moose.ChemCompt): compt = layoutPt.qGraCompt[moose.element(mobj)] updateCompartmentSize(compt) elif string == "Reac": posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() reacObj = moose.Reac(mobj.path + '/' + string_num) reacinfo = moose.Annotator(reacObj.path + '/info') qGItem = ReacItem(reacObj, itemAtView) qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y(), "white", "white") #if mType == "new_kkit": # reacinfo.x = posWrtComp.x() # reacinfo.y = posWrtComp.y() layoutPt.mooseId_GObj[reacObj] = qGItem view.emit(QtCore.SIGNAL("dropped"), reacObj) setupItem(modelpath.path, layoutPt.srcdesConnection) layoutPt.drawLine_arrow(False) #Dropping is on compartment then update Compart size if isinstance(mobj, moose.ChemCompt): compt = layoutPt.qGraCompt[moose.element(mobj)] updateCompartmentSize(compt) x, y = roundoff(qGItem.scenePos(), layoutPt) reacinfo.x = x reacinfo.y = y elif string == "StimulusTable": posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() tabObj = moose.StimulusTable(mobj.path + '/' + string_num) tabinfo = moose.Annotator(tabObj.path + '/info') qGItem = TableItem(tabObj, itemAtView) qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y(), QtGui.QColor('white'), QtGui.QColor('white')) #if mType == "new_kkit": #tabinfo.x = posWrtComp.x() #tabinfo.y = posWrtComp.y() layoutPt.mooseId_GObj[tabObj] = qGItem view.emit(QtCore.SIGNAL("dropped"), tabObj) setupItem(modelpath.path, layoutPt.srcdesConnection) layoutPt.drawLine_arrow(False) #Dropping is on compartment then update Compart size if isinstance(mobj, moose.ChemCompt): compt = layoutPt.qGraCompt[moose.element(mobj)] updateCompartmentSize(compt) x, y = roundoff(qGItem.scenePos(), layoutPt) tabinfo.x = x tabinfo.y = y elif string == "Function": posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() funcObj = moose.Function(mobj.path + '/' + string_num) funcinfo = moose.Annotator(funcObj.path + '/info') #moose.connect( funcObj, 'valueOut', mobj ,'setN' ) poolclass = ["ZombieBufPool", "BufPool"] comptclass = ["CubeMesh", "cyclMesh"] if mobj.className in poolclass: funcParent = layoutPt.mooseId_GObj[element(mobj.path)] elif mobj.className in comptclass: funcParent = layoutPt.qGraCompt[moose.element(mobj)] posWrtComp = funcParent.mapFromScene(pos).toPoint() #posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() qGItem = FuncItem(funcObj, funcParent) #print " function ", posWrtComp.x(),posWrtComp.y() qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y(), QtGui.QColor('red'), QtGui.QColor('green')) layoutPt.mooseId_GObj[funcObj] = qGItem #if mType == "new_kkit": #funcinfo.x = posWrtComp.x() #funcinfo.y = posWrtComp.y() view.emit(QtCore.SIGNAL("dropped"), funcObj) setupItem(modelpath.path, layoutPt.srcdesConnection) layoutPt.drawLine_arrow(False) #Dropping is on compartment then update Compart size mooseCmpt = findCompartment(mobj) if isinstance(mooseCmpt, moose.ChemCompt): compt = layoutPt.qGraCompt[moose.element(mooseCmpt)] updateCompartmentSize(compt) x, y = roundoff(qGItem.scenePos(), layoutPt) funcinfo.x = x funcinfo.y = y elif string == "Enz" or string == "MMenz": #If 2 enz has same pool parent, then pos of the 2nd enz shd be displaced by some position, need to check how to deal with it posWrtComp = pos enzPool = layoutPt.mooseId_GObj[mobj] if ((mobj.parent).className == "Enz"): QtGui.QMessageBox.information( None, 'Drop Not possible', '\'{newString}\' has to have Pool as its parent and not Enzyme Complex' .format(newString=string), QtGui.QMessageBox.Ok) return else: enzparent = findCompartment(mobj) parentcompt = layoutPt.qGraCompt[enzparent] if string == "Enz": enzObj = moose.Enz(moose.element(mobj).path + '/' + string_num) enzinfo = moose.Annotator(enzObj.path + '/info') moose.connect(enzObj, 'enz', mobj, 'reac') qGItem = EnzItem(enzObj, parentcompt) layoutPt.mooseId_GObj[enzObj] = qGItem posWrtComp = pos bgcolor = getRandColor() qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y() - 40, QtGui.QColor('green'), bgcolor) x, y = roundoff(qGItem.scenePos(), layoutPt) enzinfo.x = x enzinfo.y = y enzinfo.color = str(bgcolor.name()) enzinfo.textColor = str(QtGui.QColor('green').name()) #if mType == "new_kkit": #enzinfo.x = posWrtComp.x() #enzinfo.y = posWrtComp.y() #enzinfo.color = str(bgcolor.name()) e = moose.Annotator(enzinfo) #e.x = posWrtComp.x() #e.y = posWrtComp.y() Enz_cplx = enzObj.path + '/' + string_num + '_cplx' cplxItem = moose.Pool(Enz_cplx) cplxinfo = moose.Annotator(cplxItem.path + '/info') qGEnz = layoutPt.mooseId_GObj[enzObj] qGItem = CplxItem(cplxItem, qGEnz) layoutPt.mooseId_GObj[cplxItem] = qGItem enzboundingRect = qGEnz.boundingRect() moose.connect(enzObj, 'cplx', cplxItem, 'reac') qGItem.setDisplayProperties(enzboundingRect.height() / 2, enzboundingRect.height() - 40, QtGui.QColor('white'), QtGui.QColor('white')) #cplxinfo.x = enzboundingRect.height()/2 #cplxinfo.y = enzboundingRect.height()-60 view.emit(QtCore.SIGNAL("dropped"), enzObj) else: enzObj = moose.MMenz(mobj.path + '/' + string_num) enzinfo = moose.Annotator(enzObj.path + '/info') moose.connect(mobj, "nOut", enzObj, "enzDest") qGItem = MMEnzItem(enzObj, parentcompt) posWrtComp = pos bgcolor = getRandColor() qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y() - 30, QtGui.QColor('green'), bgcolor) #enzinfo.x = posWrtComp.x() #enzinfo.y = posWrtComp.y() enzinfo.color = str(bgcolor.name()) layoutPt.mooseId_GObj[enzObj] = qGItem view.emit(QtCore.SIGNAL("dropped"), enzObj) x, y = roundoff(qGItem.scenePos(), layoutPt) enzinfo.x = x enzinfo.y = y setupItem(modelpath.path, layoutPt.srcdesConnection) layoutPt.drawLine_arrow(False) #Dropping is on compartment then update Compart size if isinstance(enzparent, moose.ChemCompt): updateCompartmentSize(parentcompt) if view.iconScale != 1: view.updateScale(view.iconScale)
def createChemModel(neuroCompt, spineCompt, psdCompt): # Stuff in spine + psd # The psdCa pool is an unfortunate necessity because of limitations in # the solver setup that require molecules to diffuse through all # compartments, at least as of the July 2013 version. psdCa = createPool(psdCompt, 'Ca', 0.0001) psdGluR = createPool(psdCompt, 'psdGluR', 1) headCa = createPool(spineCompt, 'Ca', 1e-4) headGluR = createPool(spineCompt, 'headGluR', 2) toPsd = createPool(spineCompt, 'toPsd', 0) toPsdInact = createPool(spineCompt, 'toPsdInact', 1e-3) turnOnPsd = moose.Reac(spineCompt.path + '/turnOnPsd') moose.connect(turnOnPsd, 'sub', headCa, 'reac', 'OneToOne') moose.connect(turnOnPsd, 'sub', toPsdInact, 'reac', 'OneToOne') moose.connect(turnOnPsd, 'prd', toPsd, 'reac', 'OneToOne') turnOnPsd.Kf = 1e3 turnOnPsd.Kb = 1 toPsdEnz = moose.Enz(toPsd.path + '/enz') toPsdEnzCplx = moose.Pool(toPsdEnz.path + '/cplx') mesh = moose.element(spineCompt.path + '/mesh') moose.connect(toPsdEnzCplx, 'mesh', mesh, 'mesh') toPsdEnzCplx.concInit = 0 moose.connect(toPsdEnz, 'enz', toPsd, 'reac', 'OneToOne') moose.connect(toPsdEnz, 'sub', headGluR, 'reac', 'OneToOne') moose.connect(toPsdEnz, 'prd', psdGluR, 'reac', 'OneToOne') moose.connect(toPsdEnz, 'cplx', toPsdEnzCplx, 'reac', 'OneToOne') toPsdEnz.Km = 1.0e-3 toPsdEnz.kcat = 10.0 fromPsd = moose.Reac(psdCompt.path + '/fromPsd') moose.connect(fromPsd, 'sub', psdGluR, 'reac', 'OneToOne') moose.connect(fromPsd, 'prd', headGluR, 'reac', 'OneToOne') fromPsd.Kf = 0.5 fromPsd.Kb = 0.0 # Stuff in dendrite dendCa = createPool(neuroCompt, 'Ca', 1e-4) bufCa = moose.Pool(neuroCompt.path + '/bufCa') mesh = moose.element(neuroCompt.path + '/mesh') moose.connect(mesh, 'mesh', bufCa, 'mesh', 'Single') bufCa.concInit = 1e-4 pumpCa = moose.Reac(neuroCompt.path + '/pumpCa') moose.connect(pumpCa, 'sub', dendCa, 'reac', 'OneToOne') moose.connect(pumpCa, 'prd', bufCa, 'reac', 'OneToOne') pumpCa.Kf = 1 pumpCa.Kb = 1 dendKinaseInact = createPool(neuroCompt, 'inact_kinase', 1e-4) dendKinase = createPool(neuroCompt, 'Ca.kinase', 0.0) dendTurnOnKinase = moose.Reac(neuroCompt.path + '/turnOnKinase') moose.connect(dendTurnOnKinase, 'sub', dendCa, 'reac') moose.connect(dendTurnOnKinase, 'sub', dendKinaseInact, 'reac') moose.connect(dendTurnOnKinase, 'prd', dendKinase, 'reac') dendTurnOnKinase.Kf = 50000 dendTurnOnKinase.Kb = 1 dendKinaseEnz = moose.Enz(dendKinase.path + '/enz') dendKinaseEnzCplx = moose.Pool(dendKinase.path + '/enz/cplx') moose.connect(dendKinaseEnzCplx, 'mesh', mesh, 'mesh') kChan = createPool(neuroCompt, 'kChan', 1e-3) kChan_p = createPool(neuroCompt, 'kChan_p', 0.0) moose.connect(dendKinaseEnz, 'enz', dendKinase, 'reac', 'OneToOne') moose.connect(dendKinaseEnz, 'sub', kChan, 'reac', 'OneToOne') moose.connect(dendKinaseEnz, 'prd', kChan_p, 'reac', 'OneToOne') moose.connect(dendKinaseEnz, 'cplx', dendKinaseEnzCplx, 'reac', 'OneToOne') dendKinaseEnz.Km = 1e-4 dendKinaseEnz.kcat = 20 dendPhosphatase = moose.Reac(neuroCompt.path + '/phosphatase') moose.connect(dendPhosphatase, 'sub', kChan_p, 'reac') moose.connect(dendPhosphatase, 'prd', kChan, 'reac') dendPhosphatase.Kf = 1 dendPhosphatase.Kb = 0.0
def makeModel(): # create container for model model = moose.Neutral('model') compartment = moose.CubeMesh('/model/compartment') compartment.volume = 1e-15 # the mesh is created automatically by the compartment moose.le('/model/compartment') mesh = moose.element('/model/compartment/mesh') # create molecules and reactions a = moose.Pool('/model/compartment/a') b = moose.Pool('/model/compartment/b') c = moose.Pool('/model/compartment/c') enz1 = moose.Enz('/model/compartment/b/enz1') enz2 = moose.Enz('/model/compartment/c/enz2') cplx1 = moose.Pool('/model/compartment/b/enz1/cplx') cplx2 = moose.Pool('/model/compartment/c/enz2/cplx') reac = moose.Reac('/model/compartment/reac') # connect them up for reactions moose.connect(enz1, 'sub', a, 'reac') moose.connect(enz1, 'prd', b, 'reac') moose.connect(enz1, 'enz', b, 'reac') moose.connect(enz1, 'cplx', cplx1, 'reac') moose.connect(enz2, 'sub', b, 'reac') moose.connect(enz2, 'prd', a, 'reac') moose.connect(enz2, 'enz', c, 'reac') moose.connect(enz2, 'cplx', cplx2, 'reac') moose.connect(reac, 'sub', a, 'reac') moose.connect(reac, 'prd', b, 'reac') # connect them up to the compartment for volumes #for x in ( a, b, c, cplx1, cplx2 ): # moose.connect( x, 'mesh', mesh, 'mesh' ) # Assign parameters a.concInit = 1 b.concInit = 0 c.concInit = 0.01 enz1.kcat = 0.4 enz1.Km = 4 enz2.kcat = 0.6 enz2.Km = 0.01 reac.Kf = 0.001 reac.Kb = 0.01 # Create the output tables graphs = moose.Neutral('/model/graphs') outputA = moose.Table2('/model/graphs/concA') outputB = moose.Table2('/model/graphs/concB') # connect up the tables moose.connect(outputA, 'requestOut', a, 'getConc') moose.connect(outputB, 'requestOut', b, 'getConc') # We need a finer timestep than the default 0.1 seconds, # in order to get numerical accuracy. for i in range(11, 15): moose.setClock(i, 0.001) # for computational objects
QtCore.SIGNAL("qgtextPositionChange(PyQt_PyObject)"), self.mobj) if change == QGraphicsItem.ItemSelectedChange and value == True: self.qgtextPositionChange.emit(self.mobj) # self.cmptEmitter.emit( # QtCore.SIGNAL("qgtextItemSelectedChange(PyQt_PyObject)"), # self.mobj) return QGraphicsItem.itemChange(self, change, value) if __name__ == '__main__': import sys from PyQt5.QtWidgets import QApplication, QGraphicsView, QGraphicsScene app = QApplication(sys.argv) a = moose.Pool('pool') b = moose.Reac('reac') c = moose.Enz('enzyme') gview = QGraphicsView() scene = QGraphicsScene(gview) reacItem = ReacItem(b) reacItem.setDisplayProperties(50, 5, QtGui.QColor('yellow'), QtGui.QColor('green')) enzItem = EnzItem(c) enzItem.setDisplayProperties(100, 10, QtGui.QColor('blue'), QtGui.QColor('yellow')) scene.addItem(reacItem) scene.addItem(enzItem) gview.setScene(scene) gview.show() sys.exit(app.exec_())
def makeModel(): """ This function creates a bistable reaction system using explicit MOOSE calls rather than load from a file """ # create container for model model = moose.Neutral( 'model' ) compartment = moose.CubeMesh( '/model/compartment' ) compartment.volume = 1e-15 # the mesh is created automatically by the compartment mesh = moose.element( '/model/compartment/mesh' ) # create molecules and reactions a = moose.Pool( '/model/compartment/a' ) b = moose.Pool( '/model/compartment/b' ) c = moose.Pool( '/model/compartment/c' ) enz1 = moose.Enz( '/model/compartment/b/enz1' ) enz2 = moose.Enz( '/model/compartment/c/enz2' ) cplx1 = moose.Pool( '/model/compartment/b/enz1/cplx' ) cplx2 = moose.Pool( '/model/compartment/c/enz2/cplx' ) reac = moose.Reac( '/model/compartment/reac' ) # connect them up for reactions moose.connect( enz1, 'sub', a, 'reac' ) moose.connect( enz1, 'prd', b, 'reac' ) moose.connect( enz1, 'enz', b, 'reac' ) moose.connect( enz1, 'cplx', cplx1, 'reac' ) moose.connect( enz2, 'sub', b, 'reac' ) moose.connect( enz2, 'prd', a, 'reac' ) moose.connect( enz2, 'enz', c, 'reac' ) moose.connect( enz2, 'cplx', cplx2, 'reac' ) moose.connect( reac, 'sub', a, 'reac' ) moose.connect( reac, 'prd', b, 'reac' ) # Assign parameters a.concInit = 1 b.concInit = 0 c.concInit = 0.01 enz1.kcat = 0.4 enz1.Km = 4 enz2.kcat = 0.6 enz2.Km = 0.01 reac.Kf = 0.001 reac.Kb = 0.01 # Create the output tables graphs = moose.Neutral( '/model/graphs' ) outputA = moose.Table ( '/model/graphs/concA' ) outputB = moose.Table ( '/model/graphs/concB' ) outputC = moose.Table ( '/model/graphs/concC' ) outputCplx1 = moose.Table ( '/model/graphs/concCplx1' ) outputCplx2 = moose.Table ( '/model/graphs/concCplx2' ) # connect up the tables moose.connect( outputA, 'requestOut', a, 'getConc' ); moose.connect( outputB, 'requestOut', b, 'getConc' ); moose.connect( outputC, 'requestOut', c, 'getConc' ); moose.connect( outputCplx1, 'requestOut', cplx1, 'getConc' ); moose.connect( outputCplx2, 'requestOut', cplx2, 'getConc' ); return compartment
def checkCreate(scene, view, modelpath, mobj, string, ret_string, num, event_pos, layoutPt): # The variable 'compt' will be empty when dropping cubeMesh,cyclMesh, # but rest it shd be compartment logger_.debug( "checkCreate is called") if moose.exists(modelpath + '/info'): moose.Annotator((moose.element(modelpath + '/info'))).modeltype itemAtView = view.sceneContainerPt.itemAt(view.mapToScene(event_pos)) pos = view.mapToScene(event_pos) modelpath = moose.element(modelpath) if num: string_num = ret_string + str(num) else: string_num = ret_string if string == "CubeMesh" or string == "CylMesh": if string == "CylMesh": mobj = moose.CylMesh(modelpath.path + '/' + string_num) else: mobj = moose.CubeMesh(modelpath.path + '/' + string_num) mobj.volume = 1e-15 qGItem = kkitQGraphics.ComptItem(scene, pos.toPoint().x(), pos.toPoint().y(), 100, 100, mobj) qGItem.setPen( QtGui.QPen(Qt.QColor(66, 66, 66, 100), 1, Qt.Qt.SolidLine, Qt.Qt.RoundCap, Qt.Qt.RoundJoin)) view.sceneContainerPt.addItem(qGItem) qGItem.cmptEmitter.connect( qGItem.cmptEmitter, QtCore.SIGNAL("qgtextPositionChange(PyQt_PyObject)"), layoutPt.positionChange1) qGItem.cmptEmitter.connect( qGItem.cmptEmitter, QtCore.SIGNAL("qgtextItemSelectedChange(PyQt_PyObject)"), layoutPt.objectEditSlot) layoutPt.qGraCompt[mobj] = qGItem # Attach a drop signal. qGItem.dropped.emit() elif string == "Pool" or string == "BufPool": #getting pos with respect to compartment otherwise if compartment is moved then pos would be wrong posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() if string == "Pool": poolObj = moose.Pool(mobj.path + '/' + string_num) else: poolObj = moose.BufPool(mobj.path + '/' + string_num) poolinfo = moose.Annotator(poolObj.path + '/info') qGItem = kkitQGraphics.PoolItem(poolObj, itemAtView) layoutPt.mooseId_GObj[poolObj] = qGItem posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() bgcolor = kkitUtil.getRandColor() qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y(), QtGui.QColor('green'), bgcolor) poolinfo.color = str(bgcolor.getRgb()) qGItem.dropped.emit() kkitUtil.setupItem(modelpath.path, layoutPt.srcdesConnection) layoutPt.drawLine_arrow(False) x, y = roundoff(qGItem.scenePos(), layoutPt) poolinfo.x = x poolinfo.y = y #Dropping is on compartment then update Compart size if isinstance(mobj, moose.ChemCompt): compt = layoutPt.qGraCompt[moose.element(mobj)] updateCompartmentSize(compt) elif string == "Reac": posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() reacObj = moose.Reac(mobj.path + '/' + string_num) reacinfo = moose.Annotator(reacObj.path + '/info') qGItem = kkitQGraphics.ReacItem(reacObj, itemAtView) qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y(), "white", "white") layoutPt.mooseId_GObj[reacObj] = qGItem qGItem.dopped.emit() # view.emit(QtCore.SIGNAL("dropped"), reacObj) kkitUtil.setupItem(modelpath.path, layoutPt.srcdesConnection) layoutPt.drawLine_arrow(False) #Dropping is on compartment then update Compart size if isinstance(mobj, moose.ChemCompt): compt = layoutPt.qGraCompt[moose.element(mobj)] updateCompartmentSize(compt) x, y = roundoff(qGItem.scenePos(), layoutPt) reacinfo.x = x reacinfo.y = y elif string == "StimulusTable": posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() tabObj = moose.StimulusTable(mobj.path + '/' + string_num) tabinfo = moose.Annotator(tabObj.path + '/info') qGItem = kkitQGraphics.TableItem(tabObj, itemAtView) qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y(), QtGui.QColor('white'), QtGui.QColor('white')) layoutPt.mooseId_GObj[tabObj] = qGItem qGItem.dropped.emit() # view.emit(QtCore.SIGNAL("dropped"), tabObj) kkitUtil.setupItem(modelpath.path, layoutPt.srcdesConnection) layoutPt.drawLine_arrow(False) # Dropping is on compartment then update Compart size if isinstance(mobj, moose.ChemCompt): compt = layoutPt.qGraCompt[moose.element(mobj)] updateCompartmentSize(compt) x, y = roundoff(qGItem.scenePos(), layoutPt) tabinfo.x = x tabinfo.y = y elif string == "Function": posWrtComp = (itemAtView.mapFromScene(pos)).toPoint() funcObj = moose.Function(mobj.path + '/' + string_num) funcinfo = moose.Annotator(funcObj.path + '/info') #moose.connect( funcObj, 'valueOut', mobj ,'setN' ) poolclass = ["ZombieBufPool", "BufPool"] comptclass = ["CubeMesh", "cyclMesh"] if mobj.className in poolclass: funcParent = layoutPt.mooseId_GObj[moose.element(mobj.path)] elif mobj.className in comptclass: funcParent = layoutPt.qGraCompt[moose.element(mobj)] posWrtComp = funcParent.mapFromScene(pos).toPoint() elif mobj.className in "Neutral": funcParent = layoutPt.qGraGrp[moose.element(mobj)] qGItem = kkitQGraphics.FuncItem(funcObj, funcParent) qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y(), QtGui.QColor('red'), QtGui.QColor('green')) layoutPt.mooseId_GObj[funcObj] = qGItem qGItem.dropped.emit() # view.emit(QtCore.SIGNAL("dropped"), funcObj) kkitUtil.setupItem(modelpath.path, layoutPt.srcdesConnection) layoutPt.drawLine_arrow(False) #Dropping is on compartment then update Compart size mooseCmpt = findCompartment(mobj) if isinstance(mooseCmpt, moose.ChemCompt): compt = layoutPt.qGraCompt[moose.element(mooseCmpt)] updateCompartmentSize(compt) x, y = roundoff(qGItem.scenePos(), layoutPt) funcinfo.x = x funcinfo.y = y elif string == "Enz" or string == "MMenz": # FIXME: If 2 enz has same pool parent, then pos of the 2nd enz shd be # displaced by some position, need to check how to deal with it posWrtComp = pos if ((mobj.parent).className == "Enz"): QMessageBox.information( None, "Drop Not possible", "'{}' has to have Pool as its parent and not Enzyme Complex". format(string), QMessageBox.Ok) return None else: enzparent = findCompartment(mobj) parentcompt = layoutPt.qGraCompt[enzparent] if string == "Enz": enzObj = moose.Enz(moose.element(mobj).path + '/' + string_num) enzinfo = moose.Annotator(enzObj.path + '/info') moose.connect(enzObj, 'enz', mobj, 'reac') qGItem = kkitQGraphics.EnzItem(enzObj, parentcompt) layoutPt.mooseId_GObj[enzObj] = qGItem posWrtComp = pos bgcolor = kkitUtil.getRandColor() qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y() - 40, QtGui.QColor('green'), bgcolor) x, y = roundoff(qGItem.scenePos(), layoutPt) enzinfo.x = x enzinfo.y = y enzinfo.color = str(bgcolor.name()) enzinfo.textColor = str(QtGui.QColor('green').name()) moose.Annotator(enzinfo) Enz_cplx = enzObj.path + '/' + string_num + '_cplx' cplxItem = moose.Pool(Enz_cplx) moose.Annotator(cplxItem.path + '/info') qGEnz = layoutPt.mooseId_GObj[enzObj] kkitQGraphics.CplxItem(cplxItem, qGEnz) layoutPt.mooseId_GObj[cplxItem] = qGItem enzboundingRect = qGEnz.boundingRect() moose.connect(enzObj, 'cplx', cplxItem, 'reac') qGItem.setDisplayProperties(int(enzboundingRect.height() / 2), enzboundingRect.height() - 40, QtGui.QColor('white'), QtGui.QColor('white')) qGItem.dropped.emit() # view.emit(QtCore.SIGNAL("dropped"), enzObj) else: enzObj = moose.MMenz(mobj.path + '/' + string_num) enzinfo = moose.Annotator(enzObj.path + '/info') moose.connect(mobj, "nOut", enzObj, "enzDest") qGItem = kkitQGraphics.MMEnzItem(enzObj, parentcompt) posWrtComp = pos bgcolor = kkitUtil.getRandColor() qGItem.setDisplayProperties(posWrtComp.x(), posWrtComp.y() - 30, QtGui.QColor('green'), bgcolor) enzinfo.color = str(bgcolor.name()) layoutPt.mooseId_GObj[enzObj] = qGItem qGItem.dropped.emit() # view.emit(QtCore.SIGNAL("dropped"), enzObj) x, y = roundoff(qGItem.scenePos(), layoutPt) enzinfo.x = x enzinfo.y = y kkitUtil.setupItem(modelpath.path, layoutPt.srcdesConnection) layoutPt.drawLine_arrow(False) # Dropping is on compartment then update Compart size if isinstance(enzparent, moose.ChemCompt): updateCompartmentSize(parentcompt) if view.iconScale != 1: view.updateScale(view.iconScale)