示例#1
0
def simulation():

    # creating the transition graph, the verbose parameter sets the nodes to
    # either short names like 1, 2, 3 or long (binary) names like 10001
    #
    # the logfile contains the transition edges and the identity of the nodes
    trans = network.TransGraph(logfile='timemodel.log', verbose=True)

    # create the model, you may use a text string or a filename
    model = boolean2.Model(text='timemodel.txt', mode='time')

    # here we generates all initial states
    #
    # IMPORTANT: Only uninitialized nodes will get new values,
    # to keep a node the same in all iterations initialize it in the rules
    #
    # when the limit parameter is a number it will takes the first that
    # many initial values, leave it to None to use all initial values
    initializer = state.all_initial_states(model.nodes, limit=None)

    # the data is a dictionary with the inital data, print it to see what it contains
    # the initfunc is the initializer function that can be used
    for data, initfunc in initializer:
        model.initialize(missing=initfunc)
        model.iterate(12)
        trans.add(model.states, times=range(12))

    # saves the transition graph into a gml file
    trans.save('timemodel.gml')
def runSimulations(knockouts=True):
    print "starting Simulations"
    data = {}
    targets = [
        'CPK213', 'HATPase', 'NOGC1', 'NAD', 'ABA', 'Microtubule', 'Depolar',
        'InsP3', 'SphK12', 'ABH1', 'InsP6', 'CIS', 'AnionEM', 'GAPC',
        'KEfflux', 'H2OEfflux', 'VPpase', 'PP2CA', 'MRP5', 'CPK23',
        'Vacidification', 'DAG', 'ROP11', 'NO', 'pHc', 'PIP21', 'PEPC',
        'NitrocGMP', 'HAB1', 'DAGK', 'PLDd', 'PC', 'CPK6', 'PA', 'PLDa', 'PLC',
        'PI3P5K', 'ROS', 'AtRAC1', 'OST1', 'cGMP', 'Ca2ATPase', 'GCR1', 'RCN1',
        'PIP2', 'QUAC1', 'S1P', 'Malate', 'KOUT', 'NADPH', 'MAPK912', 'KEV',
        'SCAB1', 'CaIM', 'TCTP', 'VATPase', 'GPA1', 'PtdIns35P2', 'GTP',
        'GEF1410', 'ARP23', 'PtdInsP4', 'Sph', 'ABI1', 'NIA12', 'ADPRc',
        'RCARs', 'PtdInsP3', 'Nitrite', 'ABI2', 'SPP1', 'RBOH', 'Actin',
        'ERA1', 'NtSyp121', 'Ca2c', 'GHR1', 'cADPR', 'SLAH3', 'SLAC1'
    ]
    for target in targets:
        if knockouts is True:
            mtext = boolean2.modify_states(text=text, turnoff=target)
            fname = 'knockouts.json'
        else:
            mtext = boolean2.modify_states(text=text, turnon=target)
            fname = 'overexpression.json'
        model = boolean2.Model(mode='async', text=mtext)
        coll = util.Collector()
        for i in xrange(repeat):
            model.initialize(missing=util.randbool)
            model.iterate(steps=steps)
            coll.collect(states=model.states, nodes='Closure')
        data[target] = {'Timesteps': coll.get_averages(normalize=True)}
        data[target]['Closure AUC'] = sum(data[target]['Timesteps']['Closure'])
    with open(fname, 'w') as fp:
        json.dump(data, fp)
示例#3
0
def runSimulations(knockouts=True):
    print "starting Simulations"
    data = {}
    #use the following set of targets if running the simulation for the reduced model
    #targets = ['NOGC1', 'PLDdel', 'InsP3', 'nitrocGMP', 'CIS', 'Actin', 'AnionEM', 'K_efflux', 'PP2CA', 'H2O_Efflux', 'DAG', 'NO', 'pHc', 'PEPC', 'HAB1', 'PA',
    #'PLDa', 'PLC', 'PI3P5K', 'OST1', 'SLAH3', 'ABA', 'H_ATPase', 'Malate', 'KOUT', 'Depolarization', 'QUAC1', 'CaIM', 'TCTP', 'AtRAC1', 'SPHK12', 'Ca_ATPase',
    #'CPKa', 'CPKb', 'ABI2', 'Microtubule_Depolymerization', 'Ca', 'ABI1', 'NIA12', 'MPK', 'RCARs', 'VATPase', 'Vacuolar_Acidification', 'ROP11', 'RBOH', 'KEV',
    #'GHR1', 'SLAC1', 'WT']

    #use the following set of targets when running the simulation for the full model
    #targets = ['CPK321', 'H_ATPase', 'NOGC1', 'ABA', 'Microtubule_Depolymerization', 'Depolarization', 'InsP3', 'SPHK12', 'ABH1', 'InsP6', 'CIS', 'AnionEM',
    #'GAPC12', 'K_efflux', 'H2O_Efflux', 'VPPase', 'PP2CA', 'MRP5', 'CPK23', 'Vacuolar_Acidification', 'DAG', 'ROP11', 'NO', 'pHc', 'PIP', 'PEPC', 'nitrocGMP',
    #'HAB1', 'DAGK', 'PLDdel', 'PC', 'CPK6', 'PA', 'PLDa', 'PLC', 'PI3P5K', 'ROS', 'AtRAC1', 'OST1', 'cGMP', 'Ca2_ATPase', 'GCR1', 'RCN1', 'QUAC1', 'S1P',
    #'Malate', 'KOUT', 'NADPH', 'MPK912', 'KEV', 'SCAB1', 'CaIM', 'TCTP', 'VATPase', 'GPA1', 'PtdIns35P2', 'GTP', 'GEF', 'ARP_Complex', 'PtdInsP4', 'Sph',
    #'ABI1', 'NIA12', 'ADPRc', 'RCARs', 'PtdInsP3', 'Nitrite', 'ABI2', 'SPP1', 'RBOH', 'Actin_Reorganization', 'ERA1', 'NtSyp121', 'Ca2', 'GHR1', 'cADPR',
    #'SLAH3', 'SLAC1', 'WT', 'PtdIns45P2']

    for target in targets:
        print 'Processing target', target
        if knockouts is True:
            mtext = boolean2.modify_states(text=text, turnoff=target)
            fname = 'results_KO.json'
        else:
            mtext = boolean2.modify_states(text=text, turnon=target)
            fname = 'results_CA.json'
        model = boolean2.Model(mode='async', text=mtext)
        coll = util.Collector()
        for i in xrange(repeat):
            model.initialize(missing=util.randbool)
            model.iterate(steps=steps)
            coll.collect(states=model.states, nodes='Closure')
        data[target] = {'Timesteps': coll.get_averages(normalize=True)}
        data[target]['Closure AUC'] = sum(data[target]['Timesteps']['Closure'])
    with open(fname, 'w') as fp:
        json.dump(data, fp)
示例#4
0
def get_states( mode, text, steps, missing=None):
    """
    Helper function that generates the states based on 
    """
    model  = boolean2.Model( mode=mode, text=text )
    model.initialize( missing=missing )
    model.iterate( steps=steps )
    return model.states
示例#5
0
def get_states(mode, text, steps, missing=None):
    """
    Helper function to generate the states
    """
    eng = boolean2.Model(mode=mode, text=text)
    eng.initialize(missing=missing)
    eng.iterate(steps=steps)
    return eng.states
示例#6
0
def simulation(trans):
    "One simulation step will update the transition graph"

    # create the model
    model = boolean2.Model(text=rules, mode='async')

    # generates all states, set limit to a value to keep only the first that many states
    # when limit is a number it will take the first that many initial states
    initializer = state.all_initial_states(model.nodes, limit=None)

    # the data is the inital data, the func is the initializer
    for data, initfunc in initializer:
        model.initialize(missing=initfunc)
        model.iterate(5)
        trans.add(model.states, times=range(5))
示例#7
0
 def test_initializer( self ):
     "Testing initializer"
     
     text = """
     A = False
     1: A* = A
     2: B* = A and B
     3: C* = not C
     """
     model  = boolean2.Model( mode='sync', text=text )
     model.initialize( missing= util.false, defaults=dict(A=True, B=True) )
     model.iterate( steps=10 )
     self.EQ( model.first.A, True )
     self.EQ( model.first.B, True )
     self.EQ( model.first.C, False )
     self.EQ( len(model.states), 11)
示例#8
0
    def test_plde_engine(self):
        "Testing PLDE (no ranks)"

        EQ = self.assertEqual

        text = """
        A = B = True
        C = False
        A* = A
        B* = A and B
        C* = not C
        """
        eng = boolean2.Model(mode='plde', text=text)
        eng.initialize()
        eng.iterate(fullt=1, steps=10)
        EQ(len(eng.data), 3)
        EQ(len(eng.data['A']), 10)
示例#9
0
def get_sim_avgs(bn_str, nsim=100, nsteps=20, off=None, on=None):
    if off is None:
        off_nodes = []
    else:
        off_nodes = off
    if on is None:
        on_nodes = []
    else:
        on_nodes = on
    coll = boolean2.util.Collector()
    bn_str = boolean2.modify_states(bn_str, turnon=on, turnoff=off)
    model = boolean2.Model(text=bn_str, mode='async')
    for i in range(nsim):
        model.initialize()
        model.iterate(steps=nsteps)
        coll.collect(states=model.states, nodes=model.nodes)
    avgs = coll.get_averages(normalize=True)
    return avgs
示例#10
0
    def test_initializer(self):
        "Testing initializer (no ranks)"

        EQ = self.assertEqual

        text = """
        A = False
        A* = A
        B* = A and B
        C* = not C
        """
        eng = boolean2.Model(mode='sync', text=text)
        eng.initialize(missing=boolean2.util.allfalse,
                       defaults=dict(A=True, B=True))
        eng.iterate(steps=10)
        EQ(eng.start.A, True)
        EQ(eng.start.B, True)
        EQ(eng.start.C, False)
        EQ(len(eng.states), 11)
示例#11
0
    def test_modeline( self ):
        "Basic operation"
        
        text = """
        A = B = True
        C = False
        1: A* = A
        2: B* = A and B
        3: C* = not C
        """
        model  = boolean2.Model( mode='sync', text=text )
        model.initialize()

        model.iterate( steps=5 )
        
        self.EQ( model.first.A, True )
        self.EQ( model.first.B, True )
        self.EQ( model.first.C, False )

        self.EQ( model.last.A, True )
        self.EQ( model.last.B, True )
        self.EQ( model.last.C, True )
示例#12
0
    def test_model(self):
        "Basic operation"

        EQ = self.assertEqual

        text = """
        A = B = True
        C = False
        A* = A
        B* = A and B
        C* = not C
        """
        eng = boolean2.Model(mode='sync', text=text)
        eng.initialize()
        eng.iterate(steps=5)

        EQ(eng.start.A, True)
        EQ(eng.start.B, True)
        EQ(eng.start.C, False)

        EQ(eng.last.A, True)
        EQ(eng.last.B, True)
        EQ(eng.last.C, True)
示例#13
0
#
off = ["B"]

#
# this modifies the original states to apply to overexpressed and knockouts
#
text = boolean2.modify_states(text, turnon=on, turnoff=off)

#
# see tutorial 3 for more details on what happens below
#

seen = {}

for i in range(10):
    model = boolean2.Model(text, mode='sync')
    model.initialize()
    model.iterate( steps=20 )

    size, index = model.detect_cycles() 
    
    # fingerprint of the first state
    key = model.first.fp()

    # keep only the first 10 states out of the 20
    values = [ x.fp() for x in model.states[:10] ]

    # store the fingerprinted values for each initial state
    seen [ key ] = (index, size, values )   

# print out the observed states
示例#14
0
import boolean2, pylab

text = """
A = True
B = True 
C = False
1: A* = not C 
2: B* = A and B
3: C* = B
"""

model = boolean2.Model(text=text, mode='plde')
model.initialize()
model.iterate(fullt=7, steps=100)

p1 = pylab.plot(model.data['A'], 'ob-')
p2 = pylab.plot(model.data['B'], 'sr-')
p3 = pylab.plot(model.data['C'], '^g-')
pylab.legend([p1, p2, p3], "A B C".split(), loc="best")

pylab.show()
示例#15
0
import boolean2
from boolean2 import util, state, network

# updating rules

rules = """
    CIS* = Ca
    CaATPase* = Ca
    Ca* = CIS and (not CaATPase)
"""

# create the model
model = boolean2.Model( text=rules, mode='async')

# generates all states, set limit to a value to keep only the first that many states
# when limit is a number it will take the first that many initial states
initializer = state.all_initial_states( model.nodes, limit=None )

# the data is the inital data, the func is the initializer
for data, initfunc in initializer:
    # shows the initial values
    print(data)
    model.initialize(missing=initfunc)
    model.iterate(5)
'''

model_definition = """
ATM=False
ATR = Random
PMID = Random
P53 = Random
CHEK1 = Random
ATR* = ATM
P53* = ATM
CHEK1* = ATR
PMID* = P53
CHEK1* = not PMID
P53* = not PMID
"""
model = b2.Model(text=model_definition, mode='sync')
model.initialize()
model.iterate(steps=10)
for state in model.states:
    print state.ATM, state.ATR, state.PMID, state.P53, state.CHEK1
model.report_cycles()
#The model coverage to a steady state.
'''
Herceptin is a drug used for the treatment of some types of breast cancer. The action of Herceptin is modulated by dual specificity phosphatases (DUSPs), but their precise function in the cellular response to Herceptin is unknown. We hypothesize that the regulatory mechanism of DUSP1 acts as follows:
Herceptin inhibits HER2
HER2 activates ERK
HER2 activates JNK
HER2 activates P38
ERK activates DUSP1
P38 activates DUSP1
DUSP1 inhibits JNK