def parfunc(x,ntraj):
        kaoi = x[0]
        nCi = x[1]
        models.append(LSCmodel.LSCModel(nL,nCi))
        dt = models[-1].dt

        basedir = "./boxsize_5_5_5/run_bulk_nL{}_nC{}/trajectory_{}".format(nL,nCi,traj_number)
        dissocdatafile = basedir+"/accepted_dissociation_moves.txt"
        unbounddata_template = basedir+"/unbound_simulations_fine_output/unbound_reaction_event_density_nL_{}_*.npy".format(nL)

        # Load reaction probability data for each timepoint for each trajectory
        unbound_data_zipfile =  "./boxsize_5_5_5/run_bulk_nL{}_nC{}".format(nL,nCi)+"/unbound_output_combined.zip"

        coarse = 10
        tstart = pytime.time()
        #out = qan.process_quasireversible_simulations(kaoi,kdo,dt,dissocdatafile,unbound_data_files,coarse) 
        out = qan.process_quasireversible_simulations(kaoi,kdo,dt,dissocdatafile,unbound_data_zipfile,coarse,
                                                      zipped=True,target_surv_prob=target_surv_prob,nsteps=nsteps,ntraj=ntraj) 
        print("Processed run nC = {}, kao = {}, ntraj = {} in {:.2f} min".format(nCi,kaoi,ntraj,(pytime.time()-tstart)/60.))
            
        # Save output to .npz file for plotting
        out['nC'] = nCi
        out['kao'] = kaoi
        out['kdo'] = kdo
        if isinstance(ntraj,tuple):
            outfilename = "./analyzed_data/analysis_out_nC_{}_kao_{}_kdo_{}_targetprob_{}_nsteps_{}_ntraj_{}_{}.npz".format(
                                                        nCi,kaoi,kdo,target_surv_prob,nsteps,ntraj[1]-ntraj[0],ntraj[0])
        else:
            outfilename = "./analyzed_data/analysis_out_nC_{}_kao_{}_kdo_{}_targetprob_{}_nsteps_{}_ntraj_{}.npz".format(
                                                        nCi,kaoi,kdo,target_surv_prob,nsteps,ntraj)
        np.savez(outfilename,out)

        return 1
    def parfunc(x):
        kaoi = x[0]
        nCi = x[1]
        models.append(LSCmodel.LSCModel(nL, nCi))
        dt = models[-1].dt

        basedir = "./rundir/run_bulk_nL{}_nC{}/trajectory_{}".format(
            nL, nCi, traj_number)
        dissocdatafile = basedir + "/accepted_dissociation_moves.txt"
        unbounddata_template = basedir + "/unbound_simulations_fine_output/unbound_reaction_event_density_nL_{}_*.npy".format(
            nL)

        # Load reaction probability data for each timepoint for each trajectory
        unbound_data_files = []
        for datai in glob.glob(unbounddata_template):
            unbound_data_files.append(datai)
        unbound_data_zipfile = basedir + "/unbound_output.zip"

        coarse = 10
        target_surv_prob = 1e-4  # where to extrapolate to with exponential function
        tstart = pytime.time()
        #out = qan.process_quasireversible_simulations(kaoi,kdo,dt,dissocdatafile,unbound_data_files,coarse)
        out = qan.process_quasireversible_simulations(
            kaoi,
            kdo,
            dt,
            dissocdatafile,
            unbound_data_zipfile,
            coarsening=coarse,
            zipped=True,
            target_surv_prob=target_surv_prob)
        print("Processed run nC = {}, kao = {} in {:.2f} min".format(
            nCi, kaoi, (pytime.time() - tstart) / 60.))

        return out
    pos_dissocL = orientation_data[2:5].reshape((1, 3))
    pos_dissocS = orientation_data[5:].reshape((1, 3))

    idsi = np.array([traj.species_name(j) for j in types[config_time_ind]])

    indsL = np.char.equal(idsi, "L")
    posLi = positions[config_time_ind][indsL]
    indsC = np.char.equal(idsi, "C")
    posCi = positions[config_time_ind][indsC]

    #-----------------------------------------------------------------------------------
    #### Set up a reaction-diffusion system ####
    #-----------------------------------------------------------------------------------

    # Create LSCModel object to get parameters
    model = LSCmodel.LSCModel(nL, nC)

    # Define simulation box
    system = readdy.ReactionDiffusionSystem(model.boxsize, unit_system=None)
    system.periodic_boundary_conditions = [True, True,
                                           True]  # non-periodic in z-direction

    # Define species types for simulation
    system.add_species("C",
                       model.D_C)  # Crowding agent with diffusion constant D_C
    system.add_species("L", model.D_L)  # Ligand
    system.add_species("S", model.D_S)  # Ligand-receptor complex

    # Define pairwise potentials
    set_cutshifted_lj = lambda type1, type2, sigma: system.potentials.add_lennard_jones(
        type1,
Esempio n. 4
0
    if args.nSteps:
        n_steps = int(args.nSteps)
    else:
        n_steps = 1000000

    if args.nThreads:
        n_threads = int(args.nThreads)
    else:
        n_threads = 1

    #-------------------------------------------------------------------------------------------------------
    #### Set up a reaction-diffusion system and simulate ####
    #-------------------------------------------------------------------------------------------------------
    # Create LSCModel object to get parameters
    model = LSCmodel.LSCModel(n_Ltotal, n_C)

    # Define simulation box
    system = readdy.ReactionDiffusionSystem(model.boxsize, unit_system=None)
    system.periodic_boundary_conditions = [True, True,
                                           True]  # non-periodic in z-direction

    # Define species types for simulation
    system.add_species("C",
                       model.D_C)  # Crowding agent with diffusion constant D_C
    system.add_species("L", model.D_L)  # Ligand
    system.add_species("SL", model.D_SL)  # Ligand-receptor complex

    # Define pairwise potentials
    set_cutshifted_lj = lambda type1, type2, sigma: system.potentials.add_lennard_jones(
        type1,
            int(box_size[0]), int(box_size[1]), int(box_size[2]), nLtag, nC)

    if args.trajfile:
        trajfile = args.trajfile
        print("TRAJFILE={}".format(trajfile))
    else:
        trajfile = None

    if args.savefile:
        savefile = args.savefile
        print("SAVEFILE={}".format(savefile))
    else:
        savefile = "unbound_reaction_event_density_nL_{}".format(nLtag)

    if args.ncores:
        n_cores = int(args.ncores)
    else:
        n_cores = 1

    #----------------------------------------------------------------------------------------
    # Create LSCmodel object
    #----------------------------------------------------------------------------------------
    model = LSCmodel.LSCModel(nLtag, nC)

    tstart = time.time()
    react_probs = model.calc_reaction_probs(rundir, trajfile, savefile,
                                            n_cores)

    print("Reaction Probability Computation Time = {}".format(time.time() -
                                                              tstart))