diff --git a/moose-examples/README.md b/moose-examples/README.md index d6f12fbe4dc877e6f508dbe33d5469f948192e04..b5e52fa0897f306ecb174862d165d809bfe4a355 100644 --- a/moose-examples/README.md +++ b/moose-examples/README.md @@ -1,3 +1,13 @@ [](https://travis-ci.org/BhallaLab/moose-examples). Examples, tutorial and demo scripts. + +# How to run + +First install `pymoose` from PyPI using `pip`. + + $ pip install pymoose --pre --user # get the latest version + +Make sure that you have `matplotlib`, and `scipy` (optional) installed as well. + +Some scripts might require `PyQt4` or `PyQt5` as well. diff --git a/moose-examples/tutorials/Rdesigneur/chem/CICRspineDend.g b/moose-examples/tutorials/Rdesigneur/chem/CICRspineDend.g index b1211065ca35829879aec98342c812903f3f0a30..f57401f53f47f1232c00e36b963af0df5c67553f 100644 --- a/moose-examples/tutorials/Rdesigneur/chem/CICRspineDend.g +++ b/moose-examples/tutorials/Rdesigneur/chem/CICRspineDend.g @@ -1,7 +1,7 @@ //genesis // kkit Version 11 flat dumpfile -// Saved on Tue Aug 21 06:59:07 2018 +// Saved on Sat Feb 16 15:40:53 2019 include kkit {argv 1} @@ -141,7 +141,7 @@ simundump kpool /kinetics/ActIP3R 0 0.0 0 0 0 0 0 0 1866.9 0 \ simundump text /kinetics/ActIP3R/notes 0 "" call /kinetics/ActIP3R/notes LOAD \ "" -simundump kchan /kinetics/ActIP3R/chan 0 8000 0.1 0 1 0 "" brown 8 2 2 0 +simundump kchan /kinetics/ActIP3R/chan 0 8 0.1 0 1 0 "" brown 8 2 2 0 simundump text /kinetics/ActIP3R/chan/notes 0 "" call /kinetics/ActIP3R/chan/notes LOAD \ "" @@ -207,7 +207,7 @@ simundump kpool /kinetics/DEND_ER/leakPool 0 0 1 1 234 234 0 0 234 0 \ simundump text /kinetics/DEND_ER/leakPool/notes 0 "" call /kinetics/DEND_ER/leakPool/notes LOAD \ "" -simundump kchan /kinetics/DEND_ER/leakPool/leakChan 0 40 0.1 0 1 0 "" brown \ +simundump kchan /kinetics/DEND_ER/leakPool/leakChan 0 0.04 0.1 0 1 0 "" brown \ 45 4 5 0 simundump text /kinetics/DEND_ER/leakPool/leakChan/notes 0 "" call /kinetics/DEND_ER/leakPool/leakChan/notes LOAD \ diff --git a/moose-examples/tutorials/Rdesigneur/chem/CICRwithConcChan.g b/moose-examples/tutorials/Rdesigneur/chem/CICRwithConcChan.g index a8c3792c4a7ade7df37e79227c892882a157dfdb..136de8251370233e84312632024de240fcbd4769 100644 --- a/moose-examples/tutorials/Rdesigneur/chem/CICRwithConcChan.g +++ b/moose-examples/tutorials/Rdesigneur/chem/CICRwithConcChan.g @@ -1,7 +1,7 @@ //genesis // kkit Version 11 flat dumpfile -// Saved on Fri Aug 17 04:02:55 2018 +// Saved on Fri Mar 29 19:34:16 2019 include kkit {argv 1} @@ -71,16 +71,6 @@ simundump kpool /kinetics/CaCyt 0 1e-13 0.079999 0.079999 149.35 149.35 0 0 \ simundump text /kinetics/CaCyt/notes 0 "" call /kinetics/CaCyt/notes LOAD \ "" -simundump kpool /kinetics/phase 0 0.0 100 100 1.8669e+05 1.8669e+05 0 0 \ - 1866.9 0 /kinetics/geometry 49 black 9 9 0 -simundump text /kinetics/phase/notes 0 "" -call /kinetics/phase/notes LOAD \ -"" -simundump kpool /kinetics/ampl 0 0.0 0 0 0 0 0 0 1866.9 0 /kinetics/geometry \ - 63 black 10 5 0 -simundump text /kinetics/ampl/notes 0 "" -call /kinetics/ampl/notes LOAD \ -"" simundump kpool /kinetics/CaIP3_3_R 0 0.0 0 0 0 0 0 0 1866.9 0 \ /kinetics/geometry 20 black 4 7 0 simundump text /kinetics/CaIP3_3_R/notes 0 "" @@ -146,11 +136,6 @@ simundump kpool /kinetics/Ca2_IP3_3_R 0 0.0 0 0 0 0 0 0 1866.9 0 \ simundump text /kinetics/Ca2_IP3_3_R/notes 0 "" call /kinetics/Ca2_IP3_3_R/notes LOAD \ "" -simundump kpool /kinetics/CaStim 0 0.0 0 0 0 0 0 0 1866.9 4 \ - /kinetics/geometry 61 black 7 5 0 -simundump text /kinetics/CaStim/notes 0 "" -call /kinetics/CaStim/notes LOAD \ -"" simundump kpool /kinetics/Mirror_CaIP3_3_R 0 0.0 0 0 0 0 0 0 1866.9 0 \ /kinetics/geometry 4 black -1 4 0 simundump text /kinetics/Mirror_CaIP3_3_R/notes 0 "" @@ -161,20 +146,10 @@ simundump kpool /kinetics/ActIP3R 0 0.0 0 0 0 0 0 0 1866.9 0 \ simundump text /kinetics/ActIP3R/notes 0 "" call /kinetics/ActIP3R/notes LOAD \ "" -simundump kchan /kinetics/ActIP3R/chan 0 12720 0.1 0 1 0 "" brown 8 2 2 0 +simundump kchan /kinetics/ActIP3R/chan 0 8 0.1 0 1 0 "" brown 8 2 2 0 simundump text /kinetics/ActIP3R/chan/notes 0 "" call /kinetics/ActIP3R/chan/notes LOAD \ "" -simundump kpool /kinetics/basal 0 0.0 0 0 0 0 0 0 1866.9 0 /kinetics/geometry \ - 8 black 2 -1 0 -simundump text /kinetics/basal/notes 0 "" -call /kinetics/basal/notes LOAD \ -"" -simundump kpool /kinetics/BufPool 0 0.0 0 0 0 0 0 0 1866.9 4 \ - /kinetics/geometry 26 black 1 9 0 -simundump text /kinetics/BufPool/notes 0 "" -call /kinetics/BufPool/notes LOAD \ -"" simundump kreac /kinetics/CaMreac1 0 0.0045449 8.4853 "" white black 5 0 0 simundump text /kinetics/CaMreac1/notes 0 "" call /kinetics/CaMreac1/notes LOAD \ @@ -212,7 +187,7 @@ simundump kpool /kinetics/leakPool 0 0 1 1 234 234 0 0 234 0 \ simundump text /kinetics/leakPool/notes 0 "" call /kinetics/leakPool/notes LOAD \ "" -simundump kchan /kinetics/leakPool/leakChan 0 15.3 0.1 0 1 0 "" brown 45 4 5 \ +simundump kchan /kinetics/leakPool/leakChan 0 0.04 0.1 0 1 0 "" brown 45 4 5 \ 0 simundump text /kinetics/leakPool/leakChan/notes 0 "" call /kinetics/leakPool/leakChan/notes LOAD \ @@ -229,7 +204,7 @@ simundump xplot /graphs/conc2/CaER.Co 3 524288 \ "delete_plot.w <s> <d>; edit_plot.D <w>" 0 0 0 1 simundump xgraph /moregraphs/conc3 0 0 100 0 1 0 simundump xgraph /moregraphs/conc4 0 0 100 0 1 0 -simundump xcoredraw /edit/draw 0 -3 12 -3 11 +simundump xcoredraw /edit/draw 0 -1.5666 11.334 -1.8008 10.24 simundump xtree /edit/draw/tree 0 \ /kinetics/#[],/kinetics/#[]/#[],/kinetics/#[]/#[]/#[][TYPE!=proto],/kinetics/#[]/#[]/#[][TYPE!=linkinfo]/##[] \ "edit_elm.D <v>; drag_from_edit.w <d> <S> <x> <y> <z>" auto 0.6 diff --git a/moose-examples/tutorials/Rdesigneur/ex7.2_CICR.py b/moose-examples/tutorials/Rdesigneur/ex7.2_CICR.py index 38447a8d0a2c040874cc6c8f1b91e88481a1c1fb..a9725b6faf0b539726f7a5f1df52c814c29183c3 100644 --- a/moose-examples/tutorials/Rdesigneur/ex7.2_CICR.py +++ b/moose-examples/tutorials/Rdesigneur/ex7.2_CICR.py @@ -37,6 +37,6 @@ IP3 = moose.element( '/model/chem/dend/IP3' ) IP3.vec.concInit = 0.004 IP3.vec[0].concInit = 0.02 moose.reinit() -moose.start( 40 ) +moose.start( 20 ) rdes.display() diff --git a/moose-examples/tutorials/Rdesigneur/ex7.6_func_controls_reac_rate.py b/moose-examples/tutorials/Rdesigneur/ex7.6_func_controls_reac_rate.py new file mode 100644 index 0000000000000000000000000000000000000000..b8c8fb4c64b3f80d9014633108baba45a55eaf1d --- /dev/null +++ b/moose-examples/tutorials/Rdesigneur/ex7.6_func_controls_reac_rate.py @@ -0,0 +1,67 @@ +######################################################################## +# This example illustrates how a function can be used to control a reaction +# rate. This kind of calculation is appropriate when we need to link +# different kinds of physical processses with chemical reactions, for +# example, membrane curvature with molecule accumulation. The use of +# functions to modify reaction rates should be avoided in purely chemical +# systems since they obscure the underlying chemistry, and do not map +# cleanly to stochastic calculations. +# +# In this example we simply have a molecule C that controls the forward +# rate of a reaction that converts A to B. C is a function of location +# on the cylinder, and is fixed. In more elaborate computations we could +# have a function of multiple molecules, some of which could be changing and +# others could be buffered. +# +# Copyright (C) Upinder S. Bhalla NCBS 2018 +# Released under the terms of the GNU Public License V3. +######################################################################## + +import numpy as np +import moose +import pylab +import rdesigneur as rd + + +def makeFuncRate(): + model = moose.Neutral( '/library' ) + model = moose.Neutral( '/library/chem' ) + compt = moose.CubeMesh( '/library/chem/compt' ) + compt.volume = 1e-15 + A = moose.Pool( '/library/chem/compt/A' ) + B = moose.Pool( '/library/chem/compt/B' ) + C = moose.Pool( '/library/chem/compt/C' ) + reac = moose.Reac( '/library/chem/compt/reac' ) + func = moose.Function( '/library/chem/compt/reac/func' ) + func.x.num = 1 + func.expr = "(x0/1e8)^2" + moose.connect( C, 'nOut', func.x[0], 'input' ) + moose.connect( func, 'valueOut', reac, 'setNumKf' ) + moose.connect( reac, 'sub', A, 'reac' ) + moose.connect( reac, 'prd', B, 'reac' ) + + A.concInit = 1 + B.concInit = 0 + C.concInit = 0 + reac.Kb = 1 + + +makeFuncRate() + +rdes = rd.rdesigneur( + turnOffElec = True, + #This subdivides the 50-micron cylinder into 2 micron voxels + diffusionLength = 2e-6, + cellProto = [['somaProto', 'soma', 5e-6, 50e-6]], + chemProto = [['chem', 'chem']], + chemDistrib = [['chem', 'soma', 'install', '1' ]], + plotList = [['soma', '1', 'dend/A', 'conc', 'A conc', 'wave'], + ['soma', '1', 'dend/C', 'conc', 'C conc', 'wave']], +) +rdes.buildModel() + +C = moose.element( '/model/chem/dend/C' ) +C.vec.concInit = [ 1+np.sin(x/5.0) for x in range( len(C.vec) ) ] +moose.reinit() +moose.start(10) +rdes.display()