Esempio n. 1
0
def singlerun(T):

    sigma = 5e-9
    r0 = sigma
    D = 1e-12
    D_tot = D * 2

    tau = sigma * sigma / D_tot

    kf = 100 * sigma * D_tot
    koff = 0.1 / tau

    m = model.ParticleModel(1e-3)

    A = model.Species('A', D, sigma/2)
    B = model.Species('B', D, sigma/2)
    C = model.Species('C', D, sigma/2)

    m.add_species_type(A)
    m.add_species_type(B)
    m.add_species_type(C)

    r1 = model.create_binding_reaction_rule(A, B, C, kf)
    m.network_rules.add_reaction_rule(r1)

    r2 = model.create_unbinding_reaction_rule(C, A, B, koff)
    m.network_rules.add_reaction_rule(r2)

    w = gfrdbase.create_world(m, 3)
    nrw = _gfrd.NetworkRulesWrapper(m.network_rules)
    s = _gfrd._EGFRDSimulator(w, nrw, myrandom.rng)

    place_particle(w, A, [0,0,0])
    place_particle(w, B, 
                   [(float(A['radius']) + float(B['radius']))+1e-23,
                    0,0])

    end_time = T

    while s.step(end_time):
        pass

    if len(s.world.get_particle_ids(C.id)) != 0:
        return 0, s.t

    pid1 = list(s.world.get_particle_ids(A.id))[0]
    pid2 = list(s.world.get_particle_ids(B.id))[0]
    p1 = s.world.get_particle(pid1)[1]
    p2 = s.world.get_particle(pid2)[1]
    distance = w.distance(p1.position, p2.position)

    return distance, s.t
Esempio n. 2
0
File: run.py Progetto: Jintram/egfrd
def singlerun(T):

    sigma = 5e-9
    r0 = sigma
    D = 1e-12
    D_tot = D * 2

    tau = sigma * sigma / D_tot

    kf = 100 * sigma * D_tot
    koff = 0.1 / tau

    m = model.ParticleModel(1e-3)

    A = model.Species('A', D, sigma/2)
    B = model.Species('B', D, sigma/2)
    C = model.Species('C', D, sigma/2)

    m.add_species_type(A)
    m.add_species_type(B)
    m.add_species_type(C)

    r1 = model.create_binding_reaction_rule(A, B, C, kf)
    m.network_rules.add_reaction_rule(r1)

    r2 = model.create_unbinding_reaction_rule(C, A, B, koff)
    m.network_rules.add_reaction_rule(r2)

    w = gfrdbase.create_world(m, 3)
    nrw = _gfrd.NetworkRulesWrapper(m.network_rules)
    s = EGFRDSimulator(w, myrandom.rng, nrw)

    place_particle(w, A, [0,0,0])
    place_particle(w, B, [(float(A['radius']) + float(B['radius']))+1e-23,0,0])

    end_time = T
    s.step()

    while 1:
        next_time = s.get_next_time()
        if next_time > end_time:
            s.stop(end_time)
            break
        s.step()

    
    if len(s.world.get_particle_ids(C.id)) != 0:
        return 0, s.t

    distance = w.distance(s.get_position(A.id), s.get_position(B.id))

    return distance, s.t
Esempio n. 3
0
def singlerun(T):

    sigma = 5e-9
    r0 = sigma
    D = 1e-12
    D_tot = D * 2

    tau = sigma * sigma / D_tot

    kf = 100 * sigma * D_tot
    koff = 0.1 / tau

    m = model.ParticleModel(1e-3)

    A = model.Species('A', D, sigma / 2)
    B = model.Species('B', D, sigma / 2)
    C = model.Species('C', D, sigma / 2)

    m.add_species_type(A)
    m.add_species_type(B)
    m.add_species_type(C)

    r1 = model.create_binding_reaction_rule(A, B, C, kf)
    m.network_rules.add_reaction_rule(r1)

    r2 = model.create_unbinding_reaction_rule(C, A, B, koff)
    m.network_rules.add_reaction_rule(r2)

    w = gfrdbase.create_world(m, 3)
    nrw = _gfrd.NetworkRulesWrapper(m.network_rules)
    s = EGFRDSimulator(w, myrandom.rng, nrw)

    place_particle(w, A, [0, 0, 0])
    place_particle(w, B,
                   [(float(A['radius']) + float(B['radius'])) + 1e-23, 0, 0])

    end_time = T
    s.step()

    while 1:
        next_time = s.get_next_time()
        if next_time > end_time:
            s.stop(end_time)
            break
        s.step()

    if len(s.world.get_particle_ids(C.id)) != 0:
        return 0, s.t

    distance = w.distance(s.get_position(A.id), s.get_position(B.id))

    return distance, s.t
Esempio n. 4
0
def singlerun(T):

    sigma = 5e-9
    r0 = sigma
    D = 1e-12
    D_tot = D * 2

    tau = sigma * sigma / D_tot

    kf = 100 * sigma * D_tot
    koff = 0.1 / tau

    m = model.ParticleModel(1e-3)

    A = model.Species('A', D, sigma / 2)
    B = model.Species('B', D, sigma / 2)
    C = model.Species('C', D, sigma / 2)

    m.add_species_type(A)
    m.add_species_type(B)
    m.add_species_type(C)

    r1 = model.create_binding_reaction_rule(A, B, C, kf)
    m.network_rules.add_reaction_rule(r1)

    r2 = model.create_unbinding_reaction_rule(C, A, B, koff)
    m.network_rules.add_reaction_rule(r2)

    w = gfrdbase.create_world(m, 3)
    nrw = _gfrd.NetworkRulesWrapper(m.network_rules)
    s = _gfrd._EGFRDSimulator(w, nrw, myrandom.rng)

    place_particle(w, A, [0, 0, 0])
    place_particle(w, B,
                   [(float(A['radius']) + float(B['radius'])) + 1e-23, 0, 0])

    end_time = T

    while s.step(end_time):
        pass

    if len(s.world.get_particle_ids(C.id)) != 0:
        return 0, s.t

    pid1 = list(s.world.get_particle_ids(A.id))[0]
    pid2 = list(s.world.get_particle_ids(B.id))[0]
    p1 = s.world.get_particle(pid1)[1]
    p2 = s.world.get_particle(pid2)[1]
    distance = w.distance(p1.position, p2.position)

    return distance, s.t
Esempio n. 5
0
    def add_reactions(self):
        A = self.A
        B = self.B
        C = self.C

        r = model.create_unimolecular_reaction_rule(A, B, self.kf_1)
        self.m.network_rules.add_reaction_rule(r)
        r = model.create_unimolecular_reaction_rule(B, A, self.kb_1)
        self.m.network_rules.add_reaction_rule(r)
        r = model.create_binding_reaction_rule(A, B, C, self.kf_2)
        self.m.network_rules.add_reaction_rule(r)
        r = model.create_unbinding_reaction_rule(C, A, B, self.kb_2)
        self.m.network_rules.add_reaction_rule(r)
        r = model.create_decay_reaction_rule(C, self.kb_1)
        self.m.network_rules.add_reaction_rule(r)
Esempio n. 6
0
N = 300

L = 5e-6
#L = 2e-6
#L = 5e-8
#L = 3e-7

# Creating a model with species S and P that can reversibly bind
m = model.ParticleModel(L)
S = model.Species('S', 1.5e-12, 5e-9)
P = model.Species('P', 1e-12, 7e-9)
m.add_species_type(S)
m.add_species_type(P)
r1 = model.create_binding_reaction_rule(S, S, P, 1e7 / N_A)
r2 = model.create_unbinding_reaction_rule(P, S, S, 1e3)
m.network_rules.add_reaction_rule(r1)
m.network_rules.add_reaction_rule(r2)
m.set_all_repulsive()

# Set up simulator
world = create_world(m, int((N * 6) ** (1. / 3.)))
nrw = _gfrd.NetworkRulesWrapper(m.network_rules)
s = EGFRDSimulator(world, myrandom.rng, nrw)
#s = BDSimulator(world. myrandom.rng, nrw)

# Throw in particles
throw_in_particles(s.world, S, N / 2)
throw_in_particles(s.world, P, N / 2)

Esempio n. 7
0
File: run.py Progetto: Jintram/egfrd
def single_run(N, LOGGING):
    """ Single run of simulation """
    global w, A, C, k1, k2
    # Basic set up simulator
    # ===============================
    # Model
    m = model.ParticleModel(world_size)
    # Species
    A = model.Species('A', 0, sigma/2)                                   
    m.add_species_type(A) 
    B = model.Species('B', D, sigma/2)                                   
    m.add_species_type(B) 
    C = model.Species('C', 0, sigma/2)                                   
    m.add_species_type(C) 
    # Reaction rules
    r1 = model.create_binding_reaction_rule(A, B, C, k1)
    m.network_rules.add_reaction_rule(r1)
    r2 = model.create_unbinding_reaction_rule(C, A, B, k2)
    m.network_rules.add_reaction_rule(r2)

    # World
    w = gfrdbase.create_world(m, 3)
    # Simulator   
    s = EGFRDSimulator(w, myrandom.rng)

    # Put in cluster
    make_cluster(N, world_size/2, world_size/2, world_size/2)

    # Put in reactants
    # place_particle(w, B, [world_size/2, world_size/2, world_size/2+sigma+spacing])    

    # Enable VTK Logger
    # ===============================
    if (LOGGING == True):
        vtk_output_directory = 'VTK_out'
        if (os.path.exists(vtk_output_directory)):
            print '** Warning: VTK directory already exists.'
        l = vtklogger.VTKLogger(s, vtk_output_directory, extra_particle_step=True) 
    
    # Running 
    # ===============================
    numberDetected = 0

    if (LOGGING == True):
        while 1:
            l.log() # log
            s.step() # and make eGFRD step
            if s.last_reaction:
                numberDetected = numberDetected+1
                if (numberDetected == 2):
                    # print "2nd Reaction detected at: " + str(s.t) + "(" + str(s.last_reaction) + ")"
                    reaction_time = s.t - previous_time
                    break  
                else: previous_time = s.t
        l.stop() 
    else:
        while 1:
            s.step() # make eGFRD step
            if s.last_reaction:
                numberDetected = numberDetected+1
                if (numberDetected == 2):
                    # print "2nd Reaction detected at: " + str(s.t) + "(" + str(s.last_reaction) + ")"
                    reaction_time = s.t - previous_time
                    break  
                else: previous_time = s.t

    s.stop(s.t)
    return (reaction_time)
Esempio n. 8
0
File: tf.py Progetto: Jintram/egfrd
Mribo = model.Species('Mribo', 1e-12, 1e-8)

m.add_species_type(O)
m.add_species_type(R)
m.add_species_type(P)
m.add_species_type(OR)
m.add_species_type(ORp)
m.add_species_type(ORpa)
m.add_species_type(T)
m.add_species_type(M)
m.add_species_type(Mribo)

# Reaction rules
r1 = model.create_binding_reaction_rule(O, R, OR, k_fR)
m.network_rules.add_reaction_rule(r1)
r2 = model.create_unbinding_reaction_rule(OR, O, R, k_bR)
m.network_rules.add_reaction_rule(r2)
r3 = model.create_unimolecular_reaction_rule(O, ORp, k_f_rp)
m.network_rules.add_reaction_rule(r3)
r4 = model.create_unimolecular_reaction_rule(ORp, O, k_b_rp)
m.network_rules.add_reaction_rule(r4)
r5 = model.create_unimolecular_reaction_rule(ORp, ORpa, k_OC)
m.network_rules.add_reaction_rule(r5)
r6 = model.create_unbinding_reaction_rule(ORpa, T, O, 1 / t_clear)
m.network_rules.add_reaction_rule(r6)
r7 = model.create_decay_reaction_rule(M, k_dm)
m.network_rules.add_reaction_rule(r7)
r8 = model.create_unbinding_reaction_rule(M, M, Mribo, k_ribo)
m.network_rules.add_reaction_rule(r8)
r9 = model.create_unimolecular_reaction_rule(Mribo, P, 1 / t_trans)
m.network_rules.add_reaction_rule(r9)
Esempio n. 9
0
File: run.py Progetto: Jintram/egfrd
def singlerun(T_list, N_B, N_X):
    """ 
    Function that performs one simulation run of binding/
    rebinding. 

    Arguments:
        - T_list:       List of times at which distance between 
                        particles is evaluated and logged.
        - N_B:          Number of instances ("molecules") of 
                        particle B.
        - N_X:          Number of instances ("molecules") of 
                        particle X.
    """ 

    ################# Define the model:
    
    # Create model class
    m = model.ParticleModel(L)

    # Particle species classes
    A = model.Species('A', D, radius)
    m.add_species_type(A)
    B = model.Species('B', D, radius)
    m.add_species_type(B)
    C = model.Species('C', D, radius)
    m.add_species_type(C)
    X = model.Species('X', DX, radius)
    m.add_species_type(X)
    
    # Reaction rules
    r1 = model.create_binding_reaction_rule(A, B, C, kf)
    m.network_rules.add_reaction_rule(r1)

    r2 = model.create_unbinding_reaction_rule(C, A, B, 1e3)
    m.network_rules.add_reaction_rule(r2)

    ################# Set up simulator

    w = gfrdbase.create_world(m, matrix_size)
    nrw = gfrdbase.create_network_rules_wrapper(m)
    s = EGFRDSimulator(w, myrandom.rng, nrw)

    ################# Place particles 

    # Throw in some X particles and stirr
    if N_X != 0:
        gfrdbase.throw_in_particles(w, X, N_X)

        end_time = tau * 1
        while 1:
            s.step()
            next_time = s.get_next_time()
            if next_time > end_time:
                s.stop(end_time)
                break

    # Reset simulation, so stirring has no effect on output data
    s.reset()

    # Define positions for particles to place.
    A_pos = [0,0,0]
    B_pos = [(float(A['radius']) + float(B['radius']))+1e-23,0,0]

    # Clear an area at position A_pos and place particle A there
    # 
    # How this should be done:
    #    - find particles at position A_pos within species A radius
    #    - delete those
    #    - add a number of X particles _randomly to the box_, the 
    #      number being equal to # removed particles.
    #    - if a particle is accidently placed within the "cleared"
    #      area, repeat the process (in very crowded box, this 
    #      leads to infinite loop)
    #
    # Currently, however, it doesn't get the particles within a certain radius, 
    # but the particles which domain lies within a certain radius. 
    #
    # Therefore, you might be removing particles that after bursting are not 
    # within the radius anymore, but whose (now bursted) domains were.
    # 
    # TODO
    # This code should thus be adapted to solve this problem.
    # 
    # Perhaps it would be more easy to just place all the particles at
    # the beginning, but give A and B initially a diffusion constant of
    # 0, then stirr, and then set the diffusion constant to their
    # desired values.."""

    while 1:

        # Burst domains within a certain volume and collect their ids
        dd = s.clear_volume(A_pos, float(A['radius'])) 

        if not dd:
            break
        for d in dd:
            for p in d.particle_id_pair:
                s.remove_particle(p)
        s.throw_in_particles(X, len(pp), box1)

    place_particle(w, A, A_pos)

    # Idem for a particle B:
    while 1:
    
        # Burst domains within a certain volume and collect their ids
        dd = s.clear_volume(B_pos, float(B['radius'])) 

        if not dd:
            break
        for d in dd:
            for p in d.particle_id_pair:
                s.remove_particle(p)
        s.throw_in_particles(X, len(pp), box1)

    place_particle(w, B, B_pos) 

    # Place rest of B at random positions
    if N_B > 1:
        gfrdbase.throw_in_particles(w, B, N_B-1)

    # Create some vars and perform first simulation step
    r_list = []
    t_list = []
    t_last = 0

    s.step()

    next_stop = T_list[0] 

    i_T = 0

    #  ### Start simulating
    while 1:

        # What happens in the following if-statement: 
        # Create a list of the durations particles were in bound state.
        #
        # If there was a reaction:
        #     - Binding: Indicated by the fact that there are no C-particles.
        #       In this case: record the current time (s.t) to t_last.
        #     - Unbinding: Indicated because this is the only other case when
        #       a reaction has taken place. 
        #       In this case: record the time binding lasted, i.e. dt between
        #       current time (s.t) and last reaction time (t_last).
        if s.last_reaction: # aka if there was a reaction

            if len(s.world.get_particle_ids(C.id)) == 0:  #A,B
                print '    - set t_last', str(s.t)
                # set t_last to "current time" in simulator
                t_last = s.t  
            else:    
                print '    - reaction: ', str(s.t - t_last)
                t_list.append(s.t - t_last)

        # If it's time to log, then log distance between particles. 
        next_time = s.get_next_time()
        if next_time > next_stop:
            print '* Measuring distances at ', str(next_stop),\
                            '(measurement #', str(i_T), ')'
            s.stop(next_stop)
            print '* stopped'
            # If there is a particle C, the distance is "0".
            if len(s.world.get_particle_ids(C.id)) != 0:  #A,B
                r_list.append(0)
            # If particles are manifested as A and B, log distance
            # inbetween.
            else: # C = 0, i.e. there are particles A and B

                # Calculate distances:
                A_pos = s.get_position(A.id)
                distance_list = []
                # If there are >1 B particles, we want to log all   
                # distances seperately, hence the loop:
                for particle_id in w.get_particle_ids(B.id):
                    B_pos = s.get_position(particle_id)
                    distance = w.distance(A_pos, B_pos)
                    distance_list.append(distance)

                # Write list to distances table
                r_list.append(distance_list)

            i_T += 1
            next_stop = T_list[i_T]
        
        # If there are no measuring moments on the list any more, and
        # a duration of being bounded has been recorded, then stop
        if (next_stop == INF) and (len(t_list) != 0):
            print 'break', s.t
            break

        s.step()

    return r_list, t_list
Esempio n. 10
0
nS = 909
# matrix_size = 3 # min matrix size
matrix_size = max(3, int(min(numpy.power(nE+nS, 1.0 / 3.0), L / (2 * R)))) 
m = model.ParticleModel(L)

E = model.Species('E', D, R)
S = model.Species('S', D, R)
ES = model.Species('ES', D, R)
P = model.Species('P', D, R)
m.add_species_type(E)
m.add_species_type(S)
m.add_species_type(ES)
m.add_species_type(P)

fwd = model.create_binding_reaction_rule(E, S, ES, 0.01e-18)
back = model.create_unbinding_reaction_rule(ES, E, S, 0.1)
prod = model.create_unbinding_reaction_rule(ES, E, P, 0.1)
m.network_rules.add_reaction_rule(fwd)
m.network_rules.add_reaction_rule(back)
m.network_rules.add_reaction_rule(prod)
m.set_all_repulsive() 

w = gfrdbase.create_world(m, matrix_size)
gfrdbase.throw_in_particles(w, E, nE)
gfrdbase.throw_in_particles(w, S, nS)

nrw = gfrdbase.create_network_rules_wrapper(m)
sim = _gfrd._EGFRDSimulator(w, nrw, myrandom.rng) 

start = time.time()
t = 0
Esempio n. 11
0
N = 300

L = 5e-6
#L = 2e-6
#L = 5e-8
#L = 3e-7

# Creating a model with species S and P that can reversibly bind
m = model.ParticleModel(L)
S = model.Species('S', 1.5e-12, 5e-9)
P = model.Species('P', 1e-12, 7e-9)
m.add_species_type(S)
m.add_species_type(P)
r1 = model.create_binding_reaction_rule(S, S, P, 1e7 / N_A)
r2 = model.create_unbinding_reaction_rule(P, S, S, 1e3)
m.network_rules.add_reaction_rule(r1)
m.network_rules.add_reaction_rule(r2)
m.set_all_repulsive()

# Set up simulator
world = create_world(m, int((N * 6)**(1. / 3.)))
nrw = _gfrd.NetworkRulesWrapper(m.network_rules)
s = EGFRDSimulator(world, myrandom.rng, nrw)
#s = BDSimulator(world. myrandom.rng, nrw)

# Throw in particles
throw_in_particles(s.world, S, N / 2)
throw_in_particles(s.world, P, N / 2)

#l = Logger('dimer')
Esempio n. 12
0
File: tf.py Progetto: Jintram/egfrd
Mribo = model.Species('Mribo', 1e-12, 1e-8)

m.add_species_type(O) 
m.add_species_type(R) 
m.add_species_type(P) 
m.add_species_type(OR) 
m.add_species_type(ORp) 
m.add_species_type(ORpa) 
m.add_species_type(T) 
m.add_species_type(M) 
m.add_species_type(Mribo) 

# Reaction rules
r1 = model.create_binding_reaction_rule(O, R, OR, k_fR)
m.network_rules.add_reaction_rule(r1)
r2 = model.create_unbinding_reaction_rule(OR, O, R, k_bR)
m.network_rules.add_reaction_rule(r2)
r3 = model.create_unimolecular_reaction_rule(O, ORp, k_f_rp)
m.network_rules.add_reaction_rule(r3)
r4 = model.create_unimolecular_reaction_rule(ORp, O, k_b_rp)
m.network_rules.add_reaction_rule(r4)
r5 = model.create_unimolecular_reaction_rule(ORp, ORpa, k_OC)
m.network_rules.add_reaction_rule(r5)
r6 = model.create_unbinding_reaction_rule(ORpa, T, O, 1/t_clear)
m.network_rules.add_reaction_rule(r6)
r7 = model.create_decay_reaction_rule(M, k_dm)
m.network_rules.add_reaction_rule(r7)
r8 = model.create_unbinding_reaction_rule(M, M, Mribo, k_ribo)
m.network_rules.add_reaction_rule(r8)
r9 = model.create_unimolecular_reaction_rule(Mribo, P, 1/t_trans)
m.network_rules.add_reaction_rule(r9)
Esempio n. 13
0
def singlerun(T_list, N_B, N_X):
    """ 
    Function that performs one simulation run of binding/
    rebinding. 

    Arguments:
        - T_list:       List of times at which distance between 
                        particles is evaluated and logged.
        - N_B:          Number of instances ("molecules") of 
                        particle B.
        - N_X:          Number of instances ("molecules") of 
                        particle X.
    """

    ################# Define the model:

    # Create model class
    m = model.ParticleModel(L)

    # Particle species classes
    A = model.Species('A', D, radius)
    m.add_species_type(A)
    B = model.Species('B', D, radius)
    m.add_species_type(B)
    C = model.Species('C', D, radius)
    m.add_species_type(C)
    X = model.Species('X', DX, radius)
    m.add_species_type(X)

    # Reaction rules
    r1 = model.create_binding_reaction_rule(A, B, C, kf)
    m.network_rules.add_reaction_rule(r1)

    r2 = model.create_unbinding_reaction_rule(C, A, B, 1e3)
    m.network_rules.add_reaction_rule(r2)

    ################# Set up simulator

    w = gfrdbase.create_world(m, matrix_size)
    nrw = gfrdbase.create_network_rules_wrapper(m)
    s = EGFRDSimulator(w, myrandom.rng, nrw)

    ################# Place particles

    # Throw in some X particles and stirr
    if N_X != 0:
        gfrdbase.throw_in_particles(w, X, N_X)

        end_time = tau * 1
        while 1:
            s.step()
            next_time = s.get_next_time()
            if next_time > end_time:
                s.stop(end_time)
                break

    # Reset simulation, so stirring has no effect on output data
    s.reset()

    # Define positions for particles to place.
    A_pos = [0, 0, 0]
    B_pos = [(float(A['radius']) + float(B['radius'])) + 1e-23, 0, 0]

    # Clear an area at position A_pos and place particle A there
    #
    # How this should be done:
    #    - find particles at position A_pos within species A radius
    #    - delete those
    #    - add a number of X particles _randomly to the box_, the
    #      number being equal to # removed particles.
    #    - if a particle is accidently placed within the "cleared"
    #      area, repeat the process (in very crowded box, this
    #      leads to infinite loop)
    #
    # Currently, however, it doesn't get the particles within a certain radius,
    # but the particles which domain lies within a certain radius.
    #
    # Therefore, you might be removing particles that after bursting are not
    # within the radius anymore, but whose (now bursted) domains were.
    #
    # TODO
    # This code should thus be adapted to solve this problem.
    #
    # Perhaps it would be more easy to just place all the particles at
    # the beginning, but give A and B initially a diffusion constant of
    # 0, then stirr, and then set the diffusion constant to their
    # desired values.."""

    while 1:

        # Burst domains within a certain volume and collect their ids
        dd = s.clear_volume(A_pos, float(A['radius']))

        if not dd:
            break
        for d in dd:
            for p in d.particle_id_pair:
                s.remove_particle(p)
        s.throw_in_particles(X, len(pp), box1)

    place_particle(w, A, A_pos)

    # Idem for a particle B:
    while 1:

        # Burst domains within a certain volume and collect their ids
        dd = s.clear_volume(B_pos, float(B['radius']))

        if not dd:
            break
        for d in dd:
            for p in d.particle_id_pair:
                s.remove_particle(p)
        s.throw_in_particles(X, len(pp), box1)

    place_particle(w, B, B_pos)

    # Place rest of B at random positions
    if N_B > 1:
        gfrdbase.throw_in_particles(w, B, N_B - 1)

    # Create some vars and perform first simulation step
    r_list = []
    t_list = []
    t_last = 0

    s.step()

    next_stop = T_list[0]

    i_T = 0

    #  ### Start simulating
    while 1:

        # What happens in the following if-statement:
        # Create a list of the durations particles were in bound state.
        #
        # If there was a reaction:
        #     - Binding: Indicated by the fact that there are no C-particles.
        #       In this case: record the current time (s.t) to t_last.
        #     - Unbinding: Indicated because this is the only other case when
        #       a reaction has taken place.
        #       In this case: record the time binding lasted, i.e. dt between
        #       current time (s.t) and last reaction time (t_last).
        if s.last_reaction:  # aka if there was a reaction

            if len(s.world.get_particle_ids(C.id)) == 0:  #A,B
                print '    - set t_last', str(s.t)
                # set t_last to "current time" in simulator
                t_last = s.t
            else:
                print '    - reaction: ', str(s.t - t_last)
                t_list.append(s.t - t_last)

        # If it's time to log, then log distance between particles.
        next_time = s.get_next_time()
        if next_time > next_stop:
            print '* Measuring distances at ', str(next_stop),\
                            '(measurement #', str(i_T), ')'
            s.stop(next_stop)
            print '* stopped'
            # If there is a particle C, the distance is "0".
            if len(s.world.get_particle_ids(C.id)) != 0:  #A,B
                r_list.append(0)
            # If particles are manifested as A and B, log distance
            # inbetween.
            else:  # C = 0, i.e. there are particles A and B

                # Calculate distances:
                A_pos = s.get_position(A.id)
                distance_list = []
                # If there are >1 B particles, we want to log all
                # distances seperately, hence the loop:
                for particle_id in w.get_particle_ids(B.id):
                    B_pos = s.get_position(particle_id)
                    distance = w.distance(A_pos, B_pos)
                    distance_list.append(distance)

                # Write list to distances table
                r_list.append(distance_list)

            i_T += 1
            next_stop = T_list[i_T]

        # If there are no measuring moments on the list any more, and
        # a duration of being bounded has been recorded, then stop
        if (next_stop == INF) and (len(t_list) != 0):
            print 'break', s.t
            break

        s.step()

    return r_list, t_list
Esempio n. 14
0
    next_time = s.get_next_time()
    if next_time > stir_time:
        s.stop(stir_time)
        break

s.reset()

#  1 2 S + K  <-> KS
#  3   KS      -> K + Sp
#  4 5 Sp + P <-> PSp
#  6   PSp     -> P + S

# Create reaction rules (can this be done after rest is already performed?) TODO
r1 = model.create_binding_reaction_rule(S, K, KS, ka)
m.network_rules.add_reaction_rule(r1)
r2 = model.create_unbinding_reaction_rule(KS, S, K, kd1)
m.network_rules.add_reaction_rule(r2)
r3 = model.create_unbinding_reaction_rule(KS, K, Sp, kcat1)
m.network_rules.add_reaction_rule(r3)
r4 = model.create_binding_reaction_rule(Sp, P, PSp, ka)
m.network_rules.add_reaction_rule(r4)
r5 = model.create_unbinding_reaction_rule(PSp, Sp, P, kd2)
m.network_rules.add_reaction_rule(r5)
r6 = model.create_unbinding_reaction_rule(PSp, P, S, kcat2)
m.network_rules.add_reaction_rule(r6)

model = 'pushpull'

# 'pushpull-Keq-koff_ratio-N_K-N_P-V-mode.dat'
l = logger.Logger(
    logname=model + '_' + '_'.join(sys.argv[1:8]) + '_'  # +\
Esempio n. 15
0
        break

s.reset()

#  1 2 S + K  <-> KS
#  3   KS      -> K + Sp
#  4 5 Sp + P <-> PSp
#  6   PSp     -> P + S




# Create reaction rules (can this be done after rest is already performed?) TODO
r1 = model.create_binding_reaction_rule(S, K, KS, ka)
m.network_rules.add_reaction_rule(r1)
r2 = model.create_unbinding_reaction_rule(KS, S, K, kd1)
m.network_rules.add_reaction_rule(r2)
r3 = model.create_unbinding_reaction_rule(KS, K, Sp, kcat1)
m.network_rules.add_reaction_rule(r3)
r4 = model.create_binding_reaction_rule(Sp, P, PSp, ka)
m.network_rules.add_reaction_rule(r4)
r5 = model.create_unbinding_reaction_rule(PSp, Sp, P, kd2)
m.network_rules.add_reaction_rule(r5)
r6 = model.create_unbinding_reaction_rule(PSp, P, S, kcat2)
m.network_rules.add_reaction_rule(r6)


model = 'pushpull'

# 'pushpull-Keq-koff_ratio-N_K-N_P-V-mode.dat'
l = logger.Logger(logname = model + '_' + '_'.join(sys.argv[1:8]) + '_' # +\