Example #1
0
 def parameterize_full_model(self, I, param_LP=None, y0_LP=None,
                                     LP_process_func=None):
     """Re-parameterizes the full model.
     ----
     I : casadi-evaluable light input
     param_LP : parameters for the full L and P model
     
     """
     if LP_process_func is not None:
         self.LP_process_func = LP_process_func
     elif self.LP_process_func==None:
         raise Exception("No model provided to parameterize.")
     # creates the Oscillator
     if param_LP is not None:
         self.param_LP = param_LP
     if y0_LP is not None:
         self.y0_LP = y0_LP
     
     self.LP_process = ctb.Oscillator(self.LP_process_func(I), self.param_LP,
                                         self.y0_LP)
Example #2
0
    SSA_builder.SSA_MM('Reaction3','vd',
                       km=['kd'],Rct=['Pc'])

    SSA_builder.SSA_MA_cytonuc('Reaction4','Pc',
                               'Pn','k1_','k2_')
        

    return SSAmodel,state_names,param_names
    

if __name__=='__main__':
    
    # runs and compares one stochastic trajectory with deterministic solution
import matplotlib.gridspec as gridspec

odes = ctb.Oscillator(ODEmodel(), param, y0in)
odes.calc_y0()
odes.limit_cycle()
odes.first_order_sensitivity()
odes.find_prc()

tf=500.
inc = 0.1

SSAnet,state_names,param_names = SSAmodel(ODEmodel(),
                                                y0in,param)
                                                
traj = stk.stochkit(SSAnet,job_id='threestate',t=tf,
                           number_of_trajectories=300,increment=inc,
                           seed=11)
Example #3
0
        rxn4 = gillespy.Reaction(name='Y1_deg',
                                 reactants={Y1: 2},
                                 products={Y1: 1},
                                 rate=c4)

        rxn5 = gillespy.Reaction(name='Y3_to_Y2',
                                 reactants={Y3: 1},
                                 products={Y2: 1},
                                 rate=c5x3)

        self.add_reaction([rxn1, rxn2, rxn3, rxn4, rxn5])


if __name__ == "__main__":

    import circadiantoolbox as ctb

    oreg = ctb.Oscillator(model(), param, y0in)
    dsol = oreg.int_odes(10, numsteps=1000)
    oreg.calc_y0()
    oreg.limit_cycle()
    oreg.first_order_sensitivity()
    oreg.find_prc()

    ssa = oregonator_ssa(param=param)
    trajectories = ssa.run(number_of_trajectories=1)

    plt.plot(oreg.ts, dsol)
    plt.plot(trajectories[0][:, 0], trajectories[0][:, 1:] / ssa.volume)
Example #4
0
        return bhat, nn

    return bhat_func
    '''
    Bhat = np.asarray([G*alpha(ti)*(1-nn[i]) for i,ti in enumerate(t)])

    # circadian modulation of photic sensitivity
    Bhat_spline = UnivariateSpline(t, Bhat, k=3, ext=0)
    return Bhat_spline
    '''


if __name__ == "__main__":

    import circadiantoolbox as ctb

    # test the full model with light input--does it integrate?
    kron = ctb.Oscillator(kronauer(), param, y0in)
    kron.intoptions['constraints'] = None

    # integrating with the test light input
    dsol = kron.int_odes(100, numsteps=1000)
    dts = kron.ts
    plt.plot(dts, dsol)

    kron.calc_y0()
    kron.limit_cycle()

    kron.first_order_sensitivity()
    kron.find_prc()
Example #5
0
    fn.setOption("name", "kronauer_LP")

    return fn


def null_I(t):
    """
    Test light input function. No light.
    """
    return 0


if __name__ == "__main__":

    import circadiantoolbox as ctb
    import light_functions as lf

    # test the full model with light input--does it integrate?
    krona = ctb.Oscillator(kronauer(null_I, param, y0in))
    krona.intoptions['constraints'] = None

    # integrating with the test light input
    dsol = krona.int_odes(48, numsteps=4801)
    dts = krona.ts
    y0_dawn = dsol[800]

# parts that do not work
#kron.limit_cycle() # because it's discontinuous
#kron.first_order_sensitivity()
#kron.find_prc()
Example #6
0




if __name__=="__main__":
    import PlotOptions as plo
    import matplotlib.pyplot as plt
    import jha_utilities as jha
    
    # reproduce the comparison from compare_kronauer_responses.py
    from LocalModels import kronauer_model as km
    from LocalModels import simplified_kronauer_model as skm
    
    #set up Pprocess oscillator
    Pprocess = ctb.Oscillator(skm.kronauer(), skm.param, skm.y0in)
    Pprocess.intoptions['constraints']=None
    
    #set up the Lprocess object
    lproc = Lprocess(Pprocess, skm.process_L, skm.param_L)
    
    # let's see how it responds to a perturbation of 1.0h at different times
    end_ts=np.linspace(1.1,24.,100)
    start_ts=np.linspace(0.1,23.,100)
    
    errs = []
    exact_shifts = []
    approximated_shifts = []
    
    timer = jha.laptimer()
    for i,startt in enumerate(start_ts):
Example #7
0
    ode[5] = k3 * X2 - v4 * Y2 / (K4 + Y2)
    ode[6] = k5 * Y2 - v6 * Z2 / (K6 + Z2)
    ode[7] = k7 * X2 - v8 * V2 / (K8 + V2)

    ode = cs.vertcat(ode)

    fn = cs.SXFunction(cs.daeIn(t=t, x=state_set, p=param_set),
                       cs.daeOut(ode=ode))

    fn.setOption("name", "gonze_model")

    return fn


if __name__ == "__main__":
    """
    Test suite for the model. We will run with both casadi deterministic 
    and gillespy stochastic simulations.
    """

    import circadiantoolbox as ctb

    # create deterministic circadian object
    gonze_odes = ctb.Oscillator(gonze_model_ode(), param, y0in)
    gonze_odes.burnTransient_sim()
    gonze_odes.intODEs_sim(200)

    # plot deterministic solutions
    plt.plot(gonze_odes.ts, gonze_odes.sol[:, (0, 4)])
    plt.show()
Example #8
0
        SSA_builder.SSA_MM('Cell'+str(indx)+'_Reaction3','vd',
                           km=['kd'],Rct=['Pc'+index])
        
        #The complexing four:
        SSA_builder.SSA_MA_cytonuc('Cell'+str(indx)+'_Reaction4','Pc'+index,
                                   'Pn'+index,'k1_','k2_')
        

    return SSAmodel,state_names,param_names
    

if __name__=='__main__':
    
    print param
    
    ODEsolC = ctb.Oscillator(ODEmodel(), np.asarray(param), y0in)
    sol = ODEsolC.int_odes(y0in,100)
    tsol = ODEsolC.ts
    plt.plot(tsol,sol)
    plt.show()
    
    pdb.set_trace()
    tf=10
    inc = 0.05
    cellcount=3
    adjacency = np.array([[1,1,0],[0,1,1],[0,0,1]])#, 
                              #[0,0.5,0.5,0], 
                              #[0,0,0.5,0],
                              #[0,0,0,0]])
    
    SSAnet,state_names,param_names = ssa_desync(ODEmodel(),
Example #9
0
        
def interpolating_polynomial( ):
    pass



if __name__ == "__main__":

    import circadiantoolbox as ctb
    from Models.tyson_model import model, param, y0in, period, EqCount

    
    lap = jha.laptimer()
    
    #get model run
    tyson = ctb.Oscillator(model(), param, np.ones(EqCount))
    tyson.calc_y0()
    tyson.limit_cycle()
    
    
    # say we are using collocation on the tyson model
    coll = Collocation(model=model)
    
    
    #attach some data from the Tyson model
    time_steps = [0,10,13,40,70,130,165]
    datat = tyson.ts[time_steps]
    datay = tyson.sol[time_steps]
    errors = 0.3*np.random.rand(*datay.shape)
    
    # setup collocation problem