Example #1
0
__copyright__ = "Copyright 2015, Dilawar Singh and NCBS Bangalore"
__credits__ = ["NCBS Bangalore"]
__license__ = "GNU GPL"
__version__ = "1.0.0"
__maintainer__ = "Dilawar Singh"
__email__ = "*****@*****.**"
__status__ = "Development"

import sys
import os

import moose
import moose.utils as mu

print('Using moose form %s' % moose.__file__)
print('\t Moose version %s' % moose.version())

# the model lives in the same directory as the test script
modeldir = os.path.dirname(os.path.realpath(__file__))


def main():
    modelname = os.path.join(modeldir, './chem_models/00001-sbml-l3v1.xml')
    model = moose.mooseReadSBML(modelname, '/sbml')
    c = moose.element('/clock')
    moose.reinit()
    moose.start(200)
    check()


def check():
# -*- coding: utf-8 -*-
# Test moose.Function with namedvar and without wrapper.

__author__ = "Dilawar Singh"
__copyright__ = "Copyright 2019-, Dilawar Singh"
__maintainer__ = "Dilawar Singh"
__email__ = "*****@*****.**"

import numpy as np
import moose
print("[INFO ] Using moose %s form %s" % (moose.version(), moose.__file__))


def create_func(funcname, expr):
    f = moose.Function(funcname)
    f.expr = expr
    t = moose.Table(funcname + 'tab')
    t.connect('requestOut', f, 'getValue')
    moose.setClock(f.tick, 0.1)
    moose.setClock(t.tick, 0.1)
    return f, t


def test_var_order():
    nsteps = 5
    simtime = nsteps
    dt = 1.0
    fn1 = moose.Function('/fn1')
    fn1.expr = 'B+A+y0+y1'
    inputs = np.arange(0, nsteps + 1, 1.0)
    x0 = moose.StimulusTable('/x0')
Example #3
0
##    COMPT:    s ----> / s  :ENDO
##                 s =chan= s
##                      \
##
## This becomes:
##                                  \
##    COMPT:    s ----> s_xfer_endo / s     :ENDO
##                             s =chan= s
##                                  \
##
#########################################################################

import math
import numpy as np
import moose
print( '[INFO ] Using moose from %s, %s' % (moose.__file__, moose.version()) )
import moose.fixXreacs as fixXreacs

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
    s = moose.Pool( '/model/compartment/s' )
    rXfer = moose.Reac( '/model/compartment/rXfer' )
    #####################################################################
    # Put in endo compartment. Add molecule s
    endo = moose.EndoMesh( '/model/endo' )
Example #4
0
# -*- coding: utf-8 -*-
"""test_docs.py:

Test if moose.doc is working.

"""

__author__           = "Dilawar Singh"
__copyright__        = "Copyright 2017-, Dilawar Singh"
__version__          = "1.0.0"
__maintainer__       = "Dilawar Singh"
__email__            = "*****@*****.**"
__status__           = "Development"

import sys
import os
import moose
print( '[INFO] Using moose from %s' % moose.__file__ )
print( '[INFO] Version : %s' % moose.version( ) )

def test_doc( ):
    moose.doc( 'Compartment' )

def main():
    test_doc()

if __name__ == '__main__':
    main()
Example #5
0
##                      \
##
## This becomes:
##                                  \
##    COMPT:    s ----> s_xfer_endo / s     :ENDO
##                             s =chan= s
##                                  \
##
#########################################################################

import math
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import moose
print('[INFO ] Using moose from %s, %s' % (moose.__file__, moose.version()))
import moose.fixXreacs as fixXreacs


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
    s = moose.Pool('/model/compartment/s')
    rXfer = moose.Reac('/model/compartment/rXfer')
    #####################################################################
    # Put in endo compartment. Add molecule s
Example #6
0
# This example demonstrates insertion of endo-compartments into the
# dendrite. Here endo_compartments are used for the endoplasmic reticulum
# (ER) in a model of Calcium Induced Calcium Release through the
# IP3 receptor. It generates a series of propagating waves of calcium.
# Note that units of permeability in the ConcChan are 1/(millimolar.sec)
#
# Copyright (C) Upinder S. Bhalla NCBS 2018
# Released under the terms of the GNU Public License V3.
# Converted to a test by Dilawar Singh, 2020

import matplotlib as mpl
mpl.use('Agg')

import os
import moose
print("[INFO ] Using moose from %s (%s)" % (moose.__file__, moose.version()))

import numpy as np
import rdesigneur as rd

np.set_printoptions(precision=3)

sdir_ = os.path.dirname(os.path.realpath(__file__))

E = (np.array([1.09014453e-07, 7.28082797e-13, 2.75389935e-08, 4.09373273e-01,
    5.13839676e-04, 5.04392239e-04, 5.18535951e-04, 5.20332653e-04,
    5.20319412e-04, 5.20315927e-04, 5.20315785e-04, 5.20315780e-04,
    5.20315780e-04, 5.20315780e-04, 5.13839676e-04, 5.04392239e-04,
    5.18535951e-04, 5.20332653e-04, 5.20319412e-04, 5.20315927e-04,
    5.20315785e-04, 5.20315780e-04, 5.20315780e-04, 5.20315780e-04,
    4.03334121e-01, 4.04616316e-01, 4.03839819e-01, 4.03873596e-01,
Example #7
0
__copyright__        = "Copyright 2015, Dilawar Singh and NCBS Bangalore"
__credits__          = ["NCBS Bangalore"]
__license__          = "GNU GPL"
__version__          = "1.0.0"
__maintainer__       = "Dilawar Singh"
__email__            = "*****@*****.**"
__status__           = "Development"

import sys
import os

import moose
import moose.utils as mu

print( 'Using moose form %s' % moose.__file__ )
print( '\t Moose version %s' % moose.version( ) )

# the model lives in the same directory as the test script
modeldir = os.path.dirname( os.path.realpath( __file__ ) )

def main():
    modelname = os.path.join(modeldir, './chem_models/00001-sbml-l3v1.xml' )
    model = moose.mooseReadSBML( modelname, '/sbml' )
    c = moose.element('/clock')
    moose.reinit()
    moose.start(200)
    check(  )

def check( ):
    # TODO: Add more tests here.
    p = moose.wildcardFind( '/sbml/##' )
Example #8
0
"""

__author__ = "Dilawar Singh, HarshaRani"
__copyright__ = "Copyright 2015, Dilawar Singh and NCBS Bangalore"
__credits__ = ["NCBS Bangalore"]
__license__ = "GNU GPL"
__version__ = "1.0.0"
__maintainer__ = "Dilawar Singh"
__email__ = "*****@*****.**"
__status__ = "Development"

import os
import moose

print("Using moose form %s" % moose.__file__)
print("\t Moose version %s" % moose.version())

# the model lives in the same directory as the test script
sdir_ = os.path.dirname(os.path.realpath(__file__))


def test_sbml():
    modelname = os.path.join(sdir_, "..", "data", "00001-sbml-l3v1.xml")
    model = moose.readSBML(modelname, "/sbml")
    if not model:
        print("Most likely python-libsbml is not installed.")
        return 0
    moose.reinit()
    moose.start(200)
    # TODO: Add more tests here.
    p = moose.wildcardFind("/sbml/##")
Example #9
0
import matplotlib as mpl
mpl.use('Agg')
import numpy as np
import matplotlib.pyplot as plt
import moose
print("[INFO ] MOOSE version=%s, loc=%s" % (moose.version(), moose.__file__))
import rdesigneur as rd

expected = (-0.051693861353435865, 0.004062563722923687,
            np.array([7, 8, 11, 17, 34, 1852, 49, 31, 34, 958]),
            np.array([
                -0.065, -0.06309117, -0.06118235, -0.05927352, -0.05736469,
                -0.05545587, -0.05354704, -0.05163822, -0.04972939,
                -0.04782056, -0.04591174
            ]))


def test_msgs():
    if moose.exists('/model'):
        moose.delete('/model')
    rdes = rd.rdesigneur(
        stimList=[['soma', '1', '.', 'inject', '(t>0.1 && t<0.2) * 2e-8']],
        plotList=[['soma', '1', '.', 'Vm', 'Soma membrane potential']])
    rdes.buildModel()
    msgs = moose.listmsg(rdes.soma)
    assert len(msgs) == 3, msgs


def test_current_pulse():
    """Test current pulse.
    """