コード例 #1
0
def makeChemModel(compt):
    """
This function sets up a simple oscillatory chemical system within
the script. The reaction system is::

    s ---a---> a  // s goes to a, catalyzed by a.
    s ---a---> b  // s goes to b, catalyzed by a.
    a ---b---> s  // a goes to s, catalyzed by b.
    b -------> s  // b is degraded irreversibly to s.

in sum, **a** has a positive feedback onto itself and also forms **b**.
**b** has a negative feedback onto **a**.
Finally, the diffusion constant for **a** is 1/10 that of **b**.

    """
    # create container for model
    diffConst = 10e-12  # m^2/sec
    motorRate = 1e-6  # m/sec
    concA = 1  # millimolar

    # create molecules and reactions
    a = moose.Pool(compt.path + '/a')
    b = moose.Pool(compt.path + '/b')
    s = moose.Pool(compt.path + '/s')
    e1 = moose.MMenz(compt.path + '/e1')
    e2 = moose.MMenz(compt.path + '/e2')
    e3 = moose.MMenz(compt.path + '/e3')
    r1 = moose.Reac(compt.path + '/r1')

    a.concInit = 0.1
    b.concInit = 0.1
    s.concInit = 1

    moose.connect(e1, 'sub', s, 'reac')
    moose.connect(e1, 'prd', a, 'reac')
    moose.connect(a, 'nOut', e1, 'enzDest')
    e1.Km = 1
    e1.kcat = 1

    moose.connect(e2, 'sub', s, 'reac')
    moose.connect(e2, 'prd', b, 'reac')
    moose.connect(a, 'nOut', e2, 'enzDest')
    e2.Km = 1
    e2.kcat = 0.5

    moose.connect(e3, 'sub', a, 'reac')
    moose.connect(e3, 'prd', s, 'reac')
    moose.connect(b, 'nOut', e3, 'enzDest')
    e3.Km = 0.1
    e3.kcat = 1

    moose.connect(r1, 'sub', b, 'reac')
    moose.connect(r1, 'prd', s, 'reac')
    r1.Kf = 0.3  # 1/sec
    r1.Kb = 0  # 1/sec

    # Assign parameters
    a.diffConst = diffConst / 10
    b.diffConst = diffConst
    s.diffConst = 0
コード例 #2
0
def dephosphorylate(frmPool, toPool, michealson_mentis=False):
    global molecules_
    global curr_subsec_
    dephospho_.append(frmPool.name)
    if michealson_mentis:
        e = moose.MMenz('%s/%s.dephospho' % (frmPool.path, frmPool.name))
        moose.connect(e, 'sub', frmPool, 'reac')
        moose.connect(e, 'prd', toPool, 'reac')
        moose.connect(molecules_['PP1'], 'nOut', e, 'enzDest')
        e.Km = _p.K_M
        e.kcat = 10
    else:
        # if not Michealson-Mentis scheme and use this.
        inter = moose.Pool('%s/pp1_%s_cplx' % (frmPool.path, frmPool.name))
        inter.name = curr_subsec_ + '.' + inter.name
        inter.nInit = 0
        r = add_reaction('%s/%s.add_pp1' % (frmPool.path, frmPool.name))
        moose.connect(r, 'sub', frmPool, 'reac')
        moose.connect(r, 'sub', molecules_[curr_subsec_ + '.' + 'PP1'], 'reac')
        moose.connect(r, 'prd', inter, 'reac')
        r.Kf = (_p.k_2) / _p.K_M
        r.Kb = 0.0

        rr = add_reaction('%s/%s.dephospho' % (frmPool.path, frmPool.name))
        moose.connect(rr, 'sub', inter, 'reac')
        moose.connect(rr, 'prd', molecules_[curr_subsec_ + '.' + 'PP1_'],
                      'reac')
        moose.connect(rr, 'prd', toPool, 'reac')
        rr.numKf = 10.0
        rr.numKb = 0.0

    _logger.debug("Reaction (dephospho): %s -> %s, enzymatic=%s" %
                  (frmPool.name, toPool.name, michealson_mentis))
コード例 #3
0
def setupMMEnzymeReaction(reac, rName, specInfoMap, reactSBMLIdMooseId,
                          modelAnnotaInfo, model, globparameterIdValue):
    msg = ""
    errorFlag = ""
    numRcts = reac.getNumReactants()
    numPdts = reac.getNumProducts()
    nummodifiers = reac.getNumModifiers()
    if (nummodifiers):
        parent = reac.getModifier(0)
        parentSp = parent.getSpecies()
        parentSp = str(idBeginWith(parentSp))
        enzParent = specInfoMap[parentSp]["Mpath"]
        MMEnz = moose.MMenz(enzParent.path + '/' + rName)
        moose.connect(enzParent, "nOut", MMEnz, "enzDest")
        reactionCreated = True
        reactSBMLIdMooseId[rName] = {"MooseId": MMEnz, "className": "MMEnz"}
        if reactionCreated:
            if (reac.isSetNotes):
                pullnotes(reac, MMEnz)
                reacAnnoInfo = {}
                reacAnnoInfo = getObjAnnotation(reac, modelAnnotaInfo)
                if reacAnnoInfo:
                    if not moose.exists(MMEnz.path + '/info'):
                        reacInfo = moose.Annotator(MMEnz.path + '/info')
                    else:
                        reacInfo = moose.element(MMEnz.path + '/info')
                    for k, v in list(reacAnnoInfo.items()):
                        if k == 'xCord':
                            reacInfo.x = float(v)
                        elif k == 'yCord':
                            reacInfo.y = float(v)
                        elif k == 'bgColor':
                            reacInfo.color = v
                        else:
                            reacInfo.textColor = v
            return (reactionCreated, MMEnz)
コード例 #4
0
ファイル: time_stim.py プロジェクト: vinuvargheseijk/new_mod
def makeModel():
    """
    This example illustrates how to set up a oscillatory Turing pattern 
    in 1-D using reaction diffusion calculations.
    Reaction system is::

        s ---a---> a  // s goes to a, catalyzed by a.
        s ---a---> b  // s goes to b, catalyzed by a.
        a ---b---> s  // a goes to s, catalyzed by b.
        b -------> s  // b is degraded irreversibly to s.
        s ----Receptor---> a  // Receptor is activated by the ligand to cause an increase the conc of a. Here ligand-receptor interaction is not accounted for.
    in sum, **a** has a positive feedback onto itself and also forms **b**.
    **b** has a negative feedback onto **a**.
    Finally, the diffusion constant for **a** is 1/10 that of **b**.

    This chemical system is present in a 1-dimensional (cylindrical) 
    compartment. The entire reaction-diffusion system is set up 
    within the script.
    """
    # create container for model
    r0 = 1e-6  # m
    r1 = 1e-6  # m
    num = 100
    diffLength = 1e-7  # m
    len = num * diffLength  # m
    diffConst = 1e-13  # m^2/sec
    motorRate = 1e-6  # m/sec
    concA = 1  # millimolar
    dt4 = 0.5  # for the diffusion
    dt5 = 0.2  # for the reaction

    model = moose.Neutral('model')
    compartment = moose.CylMesh('/model/compartment')
    compartment.r0 = r0
    compartment.r1 = r1
    compartment.x0 = 0
    compartment.x1 = len
    compartment.diffLength = diffLength

    assert (compartment.numDiffCompts == num)

    # create molecules and reactions
    a = moose.Pool('/model/compartment/a')
    b = moose.Pool('/model/compartment/b')
    s = moose.Pool('/model/compartment/s')
    e1 = moose.MMenz('/model/compartment/e1')
    e2 = moose.MMenz('/model/compartment/e2')
    e3 = moose.MMenz('/model/compartment/e3')
    e4 = moose.MMenz('/model/compartment/e4')
    r1 = moose.Reac('/model/compartment/r1')
    rec = moose.Pool('/model/compartment/rec')

    moose.connect(e1, 'sub', s, 'reac')
    moose.connect(e1, 'prd', a, 'reac')
    moose.connect(a, 'nOut', e1, 'enzDest')
    e1.Km = 1
    e1.kcat = 1

    moose.connect(e2, 'sub', s, 'reac')
    moose.connect(e2, 'prd', b, 'reac')
    moose.connect(a, 'nOut', e2, 'enzDest')
    e2.Km = 1
    e2.kcat = 0.5

    moose.connect(e3, 'sub', a, 'reac')
    moose.connect(e3, 'prd', s, 'reac')
    moose.connect(b, 'nOut', e3, 'enzDest')
    e3.Km = 0.1
    e3.kcat = 1

    moose.connect(r1, 'sub', b, 'reac')
    moose.connect(r1, 'prd', s, 'reac')
    r1.Kf = 0.3  # 1/sec
    r1.Kb = 0.  # 1/sec

    moose.connect(e4, 'sub', s, 'reac')
    moose.connect(e4, 'prd', a, 'reac')
    moose.connect(rec, 'nOut', e4, 'enzDest')
    e4.Km = 0.001
    e4.kcat = 4

    # Assign parameters
    a.diffConst = diffConst / 10
    b.diffConst = diffConst
    s.diffConst = diffConst
    rec.diffConst = diffConst / 20

    # Make solvers
    ksolve = moose.Ksolve('/model/compartment/ksolve')
    dsolve = moose.Dsolve('/model/dsolve')
    # Set up clocks. The dsolver to know before assigning stoich
    moose.setClock(4, dt4)
    moose.setClock(5, dt5)
    moose.useClock(4, '/model/dsolve', 'process')
    # Ksolve must be scheduled after dsolve.
    moose.useClock(5, '/model/compartment/ksolve', 'process')

    stoich = moose.Stoich('/model/compartment/stoich')
    stoich.compartment = compartment
    stoich.ksolve = ksolve
    stoich.dsolve = dsolve
    stoich.path = "/model/compartment/##"
    assert (dsolve.numPools == 4)
    a.vec.concInit = [0.1] * num
    #    a.vec[50].concInit *= 1.2 # slight perturbation at one end.
    a.vec[10].concInit *= 1.2
    a.vec[35].concInit *= 1.2
    a.vec[60].concInit *= 1.2
    a.vec[85].concInit *= 1.2
    print moose.showfields(a)
    b.vec.concInit = [0.1] * num
    s.vec.concInit = [1] * num
    rec.vec.concInit = [0] * num
コード例 #5
0
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)
コード例 #6
0
ファイル: TuringInNeuron.py プロジェクト: lhhhu1990/moose
def makeChemModel( cellId ):
        # create container for model
        r0 = 1e-6    # m
        r1 = 1e-6    # m
        num = 2800
        diffLength = 1e-6 # m
        diffConst = 5e-12 # m^2/sec
        motorRate = 1e-6 # m/sec
        concA = 1 # millimolar

        model = moose.element( '/model' )
        compartment = moose.NeuroMesh( '/model/compartment' )
        # FIXME: No attribute cell
        compartment.cell =  cellId
        compartment.diffLength = diffLength
        print(("cell NeuroMesh parameters: numSeg and numDiffCompt: ", compartment.numSegments, compartment.numDiffCompts))
        
        print(("compartment.numDiffCompts == num: ", compartment.numDiffCompts, num))
        assert( compartment.numDiffCompts == num )

        # create molecules and reactions
        a = moose.Pool( '/model/compartment/a' )
        b = moose.Pool( '/model/compartment/b' )
        s = moose.Pool( '/model/compartment/s' )
        e1 = moose.MMenz( '/model/compartment/e1' )
        e2 = moose.MMenz( '/model/compartment/e2' )
        e3 = moose.MMenz( '/model/compartment/e3' )
        r1 = moose.Reac( '/model/compartment/r1' )
        moose.connect( e1, 'sub', s, 'reac' )
        moose.connect( e1, 'prd', a, 'reac' )
        moose.connect( a, 'nOut', e1, 'enzDest' )
        e1.Km = 1
        e1.kcat = 1

        moose.connect( e2, 'sub', s, 'reac' )
        moose.connect( e2, 'prd', b, 'reac' )
        moose.connect( a, 'nOut', e2, 'enzDest' )
        e2.Km = 1
        e2.kcat = 0.5

        moose.connect( e3, 'sub', a, 'reac' )
        moose.connect( e3, 'prd', s, 'reac' )
        moose.connect( b, 'nOut', e3, 'enzDest' )
        e3.Km = 0.1
        e3.kcat = 1

        moose.connect( r1, 'sub', b, 'reac' )
        moose.connect( r1, 'prd', s, 'reac' )
        r1.Kf = 0.3 # 1/sec
        r1.Kb = 0 # 1/sec

        # Assign parameters
        a.diffConst = diffConst/10
        b.diffConst = diffConst
        s.diffConst = 0
                #b.motorConst = motorRate

        # Make solvers
        ksolve = moose.Ksolve( '/model/compartment/ksolve' )
        dsolve = moose.Dsolve( '/model/compartment/dsolve' )
        stoich = moose.Stoich( '/model/compartment/stoich' )
        stoich.compartment = compartment
        #ksolve.numAllVoxels = compartment.numDiffCompts
        stoich.ksolve = ksolve
        stoich.dsolve = dsolve
        stoich.path = "/model/compartment/##"
        assert( dsolve.numPools == 3 )
        a.vec.concInit = [0.1]*num
        a.vec[0].concInit += 0.5
        a.vec[400].concInit += 0.5
        a.vec[800].concInit += 0.5
        a.vec[1200].concInit += 0.5
        a.vec[1600].concInit += 0.5
        a.vec[2000].concInit += 0.5
        a.vec[2400].concInit += 0.5
        #a.vec[num/2].concInit -= 0.1
        b.vec.concInit = [0.1]*num
        s.vec.concInit = [1]*num
コード例 #7
0
def makeModel():
    # create container for model
    num = 1  # number of compartments
    model = moose.Neutral('/model')
    compartment = moose.CylMesh('/model/compartment')
    compartment.x1 = 1.0e-6  # Set it to a 1 micron single-voxel cylinder

    # create molecules and reactions
    prd = moose.Pool('/model/compartment/prd')
    rXfer = moose.Reac('/model/compartment/rXfer')
    #####################################################################
    # Put in endo compartment. Add molecule s
    endo = moose.EndoMesh('/model/endo')
    endo.isMembraneBound = True
    endo.surround = compartment
    sub = moose.Pool('/model/endo/sub')
    enzPool = moose.Pool('/model/endo/enzPool')
    enzPool.concInit = eInit
    enz = moose.MMenz('/model/endo/enzPool/enz')
    #####################################################################
    moose.connect(enz, 'sub', sub, 'reac')
    moose.connect(enz, 'prd', prd, 'reac')
    moose.connect(enzPool, 'nOut', enz, 'enzDest')
    moose.connect(rXfer, 'sub', prd, 'reac')
    moose.connect(rXfer, 'prd', sub, 'reac')
    rXfer.Kf = Kf  # 0.04/sec
    rXfer.Kb = 0.0  # 0.02/sec
    enz.Km = Km
    enz.kcat = kcat
    # v = es.kcat/(s+Km)
    # v = Kf * conc.
    #####################################################################
    fixXreacs.fixXreacs('/model')
    fixXreacs.restoreXreacs('/model')
    fixXreacs.fixXreacs('/model')
    #####################################################################

    # Make solvers
    ksolve = moose.Ksolve('/model/compartment/ksolve')
    dsolve = moose.Dsolve('/model/dsolve')
    eksolve = moose.Ksolve('/model/endo/ksolve')
    edsolve = moose.Dsolve('/model/endo/dsolve')

    stoich = moose.Stoich('/model/compartment/stoich')
    stoich.compartment = compartment
    stoich.ksolve = ksolve
    stoich.dsolve = dsolve
    stoich.path = "/model/compartment/##"
    assert (dsolve.numPools == 2)
    sub.vec.concInit = subInit
    enzPool.vec.concInit = eInit

    estoich = moose.Stoich('/model/endo/stoich')
    estoich.compartment = endo
    estoich.ksolve = eksolve
    estoich.dsolve = edsolve
    estoich.path = "/model/endo/##"
    assert (edsolve.numPools == 3)

    edsolve.buildMeshJunctions(dsolve)

    plot1 = moose.Table2('/model/plot1')
    plot2 = moose.Table2('/model/plot2')
    moose.connect('/model/plot1', 'requestOut', sub, 'getN')
    moose.connect('/model/plot2', 'requestOut', prd, 'getN')
    plot3 = moose.Table2('/model/plot3')
    plot4 = moose.Table2('/model/plot4')
    moose.connect('/model/plot3', 'requestOut', sub, 'getConc')
    moose.connect('/model/plot4', 'requestOut', prd, 'getConc')
コード例 #8
0
def makeModel():
    """
    This example illustrates how to set up a oscillatory Turing pattern 
    in 1-D using reaction diffusion calculations.
    Reaction system is::

        s ---a---> a  // s goes to a, catalyzed by a.
        s ---a---> b  // s goes to b, catalyzed by a.
        a ---b---> s  // a goes to s, catalyzed by b.
        b -------> s  // b is degraded irreversibly to s.

    in sum, **a** has a positive feedback onto itself and also forms **b**.
    **b** has a negative feedback onto **a**.
    Finally, the diffusion constant for **a** is 1/10 that of **b**.

    This chemical system is present in a 1-dimensional (cylindrical) 
    compartment. The entire reaction-diffusion system is set up 
    within the script.
    """
    # create container for model
    r0 = 1e-6  # m
    r1 = 1e-6  # m
    diffLength = 2e-6  # m
    len = num * diffLength  # m
    diffConst = 1e-12  # m^2/sec
    motorRate = 1e-6  # m/sec
    concA = 1  # millimolar
    dt4 = 0.002  # for the diffusion
    dt5 = 0.2  # for the reaction

    model = moose.Neutral('model')
    compartment = moose.CylMesh('/model/compartment')
    compartment.r0 = r0
    compartment.r1 = r1
    compartment.x0 = 0
    compartment.x1 = len
    compartment.diffLength = diffLength

    assert (compartment.numDiffCompts == num)

    # create molecules and reactions
    a = moose.Pool('/model/compartment/a')
    b = moose.Pool('/model/compartment/b')
    s = moose.Pool('/model/compartment/s')
    e1 = moose.MMenz('/model/compartment/e1')
    e2 = moose.MMenz('/model/compartment/e2')
    e3 = moose.MMenz('/model/compartment/e3')
    r1 = moose.Reac('/model/compartment/r1')
    c = moose.Pool('/model/compartment/c')
    d = moose.Pool('/model/compartment/d')
    r2 = moose.Reac('/model/compartment/r2')
    moose.connect(r2, 'sub', a, 'reac')
    moose.connect(r2, 'sub', c, 'reac')
    moose.connect(r2, 'prd', d, 'reac')
    r2.Kf = 0.0
    r2.Kb = 0.0
    #moose.connect( e1, 'sub', s, 'reac' )
    #moose.connect( e1, 'prd', a, 'reac' )
    #moose.connect( a, 'nOut', e1, 'enzDest' )
    #e1.Km = 1
    #e1.kcat = 1

    #moose.connect( e2, 'sub', s, 'reac' )
    #moose.connect( e2, 'prd', b, 'reac' )
    #moose.connect( a, 'nOut', e2, 'enzDest' )
    #e2.Km = 1
    #e2.kcat = 0.5

    #moose.connect( e3, 'sub', a, 'reac' )
    #moose.connect( e3, 'prd', s, 'reac' )
    #moose.connect( b, 'nOut', e3, 'enzDest' )
    #e3.Km = 0.1
    #e3.kcat = 1

    #moose.connect( r1, 'sub', b, 'reac' )
    #moose.connect( r1, 'prd', s, 'reac' )
    #r1.Kf = 0.3 # 1/sec
    #r1.Kb = 0. # 1/sec

    # Assign parameters
    a.diffConst = diffConst
    b.diffConst = 0
    s.diffConst = 0
    c.diffConst = 0
    d.diffConst = 0
    # Make solvers
    ksolve = moose.Ksolve('/model/compartment/ksolve')
    dsolve = moose.Dsolve('/model/dsolve')
    # Set up clocks. The dsolver to know before assigning stoich
    moose.setClock(4, dt4)
    moose.setClock(5, dt5)
    moose.useClock(4, '/model/dsolve', 'process')
    # Ksolve must be scheduled after dsolve.
    moose.useClock(5, '/model/compartment/ksolve', 'process')

    stoich = moose.Stoich('/model/compartment/stoich')
    stoich.compartment = compartment
    stoich.ksolve = ksolve
    stoich.dsolve = dsolve
    stoich.path = "/model/compartment/##"
    assert (dsolve.numPools == 5)
    #a.vec.concInit = [0.1]*num
    #    a.vec[50].concInit *= 1.2 # slight perturbation at one end.
    #a.vec[60].concInit *= 1.2
    #a.vec[40].concInit *= 1.2
    a.vec[0].concInit = 3
    #a.vec[30].concInit *= 1.2
    #a.vec[50].concInit *= 1.2
    #b.vec[99].concInit *= 0.5
    #for i in range(0, num-1,50):
    #c.vec[i].concInit = 0.1
    #c.vec[i].concInit = 0.5
    #d.vec[i].concInit = 0.5
    # print i
    c.vec[0].concInit = 0
    d.vec[0].concInit = 0
コード例 #9
0
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)