sfs = plt.subplot2grid((3, 2), (2, 0), rowspan=1, colspan=2) #hdf5 files to save the output for further plotting... popstats_output = pd.HDFStore('popstats_vary_mu_VMconstant.h5', 'w', complevel=6, complib='zlib') sfs_output = pd.HDFStore('sfs_vary_mu_VMconstant.h5', 'w', complevel=6, complib='zlib') for rmu in relative_mu: mu = rmu * reference_mu sigma = math.sqrt(reference_vm / (2.0 * mu)) sregions = [fp.GaussianS(0, 1, 1, sigma)] vs = 1.0 #Generate 1e3 replicates with these params replabel = 0 DFS = [] sfs_at_opt = pd.Series([0.0] * (2 * N)) for batch in range(25): pops = fp.popvec(40, N) stats = qt.evolve_qtrait_popstats( rng, pops, Nlist[0:], 0, mu, recrate, nregions,
def main(): try: opts, args = getopt.getopt(sys.argv[1:], "m:e:H:S:O:N:t:s:r:F:n:") except getopt.GetoptError as err: # print help information and exit: print(err) # will print something like "option -a not recognized" usage() sys.exit(2) N = 1000 # pop size e = 0.25 # s.d. of effect sizes S = 1 # V(S) H = None # desired b-sense H^2 mu_del_ttl = None # Mutation rate (per gamete, per generation) to alleles affecting trait value r = 0.5 # rec. rate b/w loci (per diploid, per gen) Opt = 0.0 # Value of optimum after 10N gens ofile = None seed = 0 t = None nsam = 100 for o, a in opts: if o == '-m': mu_del_ttl = float(a) elif o == '-e': e = float(a) elif o == '-H': H = float(a) elif o == '-S': S = float(a) elif o == '-O': Opt = float(a) elif o == '-N': N = int(a) elif o == '-s': seed = int(a) elif o == '-r': r = float(a) elif o == '-F': ofile = a elif o == '-t': t = int(a) elif o == '-n': nsam = int(a) if H is None: usage() sys.exit(2) if mu_del_ttl is None: usage() sys.exit(2) if ofile is None: usage() sys.exit(2) if t is None: t = 0.1 * float(N) #Constants: NLOCI = 10 NREPS = 64 ##The next 2 are the 'sizes' of each locus in scaled params. Roughly 100kb in 'humans' in terms of pi. theta = 100.0 rho = 100.0 #Can start working now: REP = 0 out = pd.HDFStore(ofile, "w", complevel=6, complib='zlib') little_r_per_locus = rho / (4.0 * float(N)) mu_n_region = theta / (4.0 * float(N)) rnge = fp.GSLrng(seed) rngs = fp.GSLrng(seed) nlist = np.array([N] * (10 * N), dtype=np.uint32) fitness = qtm.MlocusAdditiveTrait() sregions = [fp.GaussianS(0, 1, 1, e, 1.0)] * NLOCI for BATCH in range(16): #16*64=1024 x = fp.MlocusPopVec(NREPS, N, NLOCI) sampler = fp.PopSampler(len(x), nsam, rngs) qtm.evolve_qtraits_mloc_sample_fitness( rnge, x, sampler, fitness, nlist, [mu_n_region] * NLOCI, [mu_del_ttl / float(NLOCI)] * NLOCI, sregions, [little_r_per_locus] * NLOCI, [0.5] * (NLOCI - 1), #loci unlinked sample=t, VS=S) samples = sampler.get() get_summstats_parallel(samples, REP, out) sampler = fp.PopSampler(nsam, rngs) qtm.evolve_qtraits_mloc_sample_fitnes( rnge, x, sampler, fitness, nlist, [mu_n_region] * NLOCI, [mu_del_ttl / float(NLOCI)] * NLOCI, sregions, [little_r_per_locus] * NLOCI, [0.5] * (NLOCI - 1), #loci unlinked sample=t, VS=S, optimum=Opt) samples = sampler.get() get_summstats_parallel(samples, REP, out) REP += NREPS out.close()
def main(): try: opts, args = getopt.getopt(sys.argv[1:],"m:e:H:S:O:N:s:r:",["fixed=","ages=","traj="]) except getopt.GetoptError as err: # print help information and exit: print(err) # will print something like "option -a not recognized" usage() sys.exit(2) #set up default params N=1000 # pop size e = 0.25 # s.d. of effect sizes S = 1 # V(S) H = None # desired b-sense H^2 m = None # Mutation rate (per gamete, per generation) to alleles affecting trait value r = 0.5 # rec. rate (per diploid, per gen) Opt = 0.0 # Value of optimum after 10N gens fixationsFile=None lostFile=None trajFile=None seed = 0 for o,a in opts: if o == '-m': m = float(a) elif o == '-e': e = float(a) elif o == '-H': H = float(a) elif o == '-S': S = float(a) elif o == '-O': Opt = float(a) elif o == '-N': N=int(a) elif o == '-s': seed = int(a) elif o == '-r': r = float(a) elif o == '--fixed': fixationsFile=a elif o == '--ages': lostFile=a elif o == '--traj': trajFile=a if H is None: usage() sys.exit(2) if m is None: usage() sys.exit(2) if fixationsFile is None or lostFile is None or trajFile is None: usage() sys.exit(2) rng = fp.GSLrng(seed) hdf_fixed = pd.HDFStore(fixationsFile,'w',complevel=6,complib='zlib') hdf_fixed.open() hdf_lost = pd.HDFStore(lostFile,'w',complevel=6,complib='zlib') hdf_lost.open() hdf_traj = pd.HDFStore(trajFile,'w',complevel=6,complib='zlib') hdf_traj.open() sigE = get_sigE_additive(m,S,H) nregions = [] recregions = [fp.Region(0,1,1)] sregions = [fp.GaussianS(0,1,1,e)] #population size over time -- constant & we re-use this over and over nlist = np.array([N]*(10*N),dtype=np.uint32) REPLICATE=0 #16 batches of 64 runs = 1024 replicates for i in range(16): #set up populations pops=fp.SpopVec(64,N) #Evolve to equilibrium sampler = fp.FreqSampler(len(pops)) qt.evolve_regions_qtrait_sampler(rng, pops, sampler, nlist[0:], 0, m, r, nregions,sregions,recregions, sigmaE=sigE, sample=1, VS=S) ##Do not track popstats during "burn-in" traj1=sampler.get() sampler = fp.FreqSampler(len(pops)) #evolve for another 10N generations at new optimum qt.evolve_regions_qtrait_sampler(rng,pops,sampler, nlist[0:], 0, m, r, nregions,sregions,recregions, sigmaE=sigE, VS=S,optimum=Opt,sample=1) traj2=sampler.get() AGES=[] FIXATIONS=[] #merge trajectories and get allele ages (parallelized via open MP) traj1=fp.merge_trajectories(traj1,traj2) ages = fp.allele_ages(traj1) REPTEMP=REPLICATE for ai in range(len(ages)): dfi=pd.DataFrame(ages[ai]) dfi['rep']=[REPTEMP]*len(dfi.index) FIXATIONS.append(dfi[dfi['max_freq']==1.0]) AGES.append(dfi[dfi['max_freq']<1.0]) REPTEMP+=1 # for j in range(len(pops)): # #Merge all trajectories for this replicate # df = pd.concat([pd.DataFrame(traj1[j]), # pd.DataFrame(traj2[j])]) # for name,group in df.groupby(['pos','esize']): # if group.freq.max() < 1: #mutation did not reach fixation... # if group.generation.max()-group.generation.min()>1: #... and it lived > 1 generation ... # AGES.append({'rep':REPLICATE, # 'esize':name[1], # 'origin':group.generation.min(), # 'final_g':group.generation.max(), # 'max_q':group.freq.max(), # 'last_q':group.freq.iloc[-1]}) # else: #mutation did reach fixation! # FIXATIONS.append({'rep':REPLICATE, # 'esize':name[1], # 'origin':group.generation.min(), # 'final_g':group.generation.max()}) # REPLICATE+=1 ##Add more info into the trajectories for t in traj1: LD=[] for i in t: I=int(0) for j in i[1]: x=copy.deepcopy(i[0]) x['freq']=j x['generation']=i[0]['origin']+I I+=1 LD.append(x) d=pd.DataFrame(LD) d['rep']=[REPLICATE]*len(d.index) REPLICATE+=1 hdf_traj.append('trajectories',d) hdf_fixed.append('fixations',pd.concat(FIXATIONS)) hdf_lost.append('allele_ages',pd.concat(AGES)) hdf_fixed.close() hdf_lost.close() hdf_traj.close()
def main(): try: opts, args = getopt.getopt(sys.argv[1:],"m:e:H:S:O:N:s:r:",["traj="]) except getopt.GetoptError as err: # print help information and exit: print(err) # will print something like "option -a not recognized" usage() sys.exit(2) N=1000 # pop size e = 0.25 # s.d. of effect sizes S = 1 # V(S) H = None # desired b-sense H^2 mu_del_ttl = None # Mutation rate (per gamete, per generation) to alleles affecting trait value r = 0.5 # rec. rate b/w loci (per diploid, per gen) Opt = 0.0 # Value of optimum after 10N gens trajFile=None seed = 0 for o,a in opts: if o == '-m': mu_del_ttl = float(a) elif o == '-e': e = float(a) elif o == '-H': H = float(a) elif o == '-S': S = float(a) elif o == '-O': Opt = float(a) elif o == '-N': N=int(a) elif o == '-s': seed = int(a) elif o == '-r': r = float(a) elif o == '--traj': trajFile=a if H is None: usage() sys.exit(2) if mu_del_ttl is None: usage() sys.exit(2) if trajFile is None: usage() sys.exit(2) #Constants: NLOCI=10 NREPS=64 ##The next 2 are the 'sizes' of each locus in scaled params. Roughly 100kb in 'humans' in terms of pi. theta=100.0 rho=100.0 #Can start working now: REP=0 out=pd.HDFStore(trajFile,"w",complevel=6,complib='zlib') little_r_per_locus = rho/(4.0*float(N)) mu_n_region=theta/(4.0*float(N)) rnge=fp.GSLrng(seed) nlist=np.array([N]*(10*N),dtype=np.uint32) fitness = qtm.MlocusAdditiveTrait() sregions=[fp.GaussianS(0,1,1,e,1.0)]*NLOCI for BATCH in range(16): #16*64=1024 x = fp.MlocusPopVec(NREPS,N,NLOCI) sampler=fp.FreqSampler(len(x)) qtm.evolve_qtraits_mloc_sample_fitness(rnge,x,sampler,fitness,nlist, [mu_n_region]*NLOCI, [mu_del_ttl/float(NLOCI)]*NLOCI, sregions, [little_r_per_locus]*NLOCI, [0.5]*(NLOCI-1),#loci unlinked sample=1,VS=S) traj1=sampler.get() sampler=fp.FreqSampler(len(x)) qtm.evolve_qtraits_mloc_sample_fitness(rnge,x,sampler,fitness,nlist, [mu_n_region]*NLOCI, [mu_del_ttl/float(NLOCI)]*NLOCI, sregions, [little_r_per_locus]*NLOCI, [0.5]*(NLOCI-1),#loci unlinked sample=1,VS=S,optimum=Opt) traj2=sampler.get() m=fp.tidy_trajectories(fp.merge_trajectories(traj1,traj2)) for i in m: temp=pd.DataFrame(i) temp['rep']=[REP]*len(temp.index) out.append('traj',temp) REP+=1 out.close()
def main(): try: opts, args = getopt.getopt(sys.argv[1:], "m:e:H:S:O:N:t:s:F:r:n:d:", [ "theta=", "rho=", "trait=", "sampler=", "nsam=", "cores=", "batches=", "nstub=", "sstub=", "nloci=", "fixations=", "t2=", "g2=" ]) #,"neutral="]) except getopt.GetoptError as err: # print help information and exit: print(err) # will print something like "option -a not recognized" usage() sys.exit(2) #set up default params N = 1000 # pop size t = None # 0.1N t2 = None e = 0.25 # s.d. of effect sizes S = 1 # V(S) H = 1.0 # desired b-sense H^2 m = None # Mutation rate (per gamete, per generation) to alleles affecting trait value r = 0.5 #Recombination rate between locis Opt = 0.0 # Value of optimum after 10N gens ofile = None seed = 0 NLOCI = 10 #The total number of loci to simulate #NeutralLocus = 5 #The index of the locus where no causal mutations will occur theta = 100 # mutational size of region where neutral mutations occur rho = 100 # recombination size of region where neutral mutations occur traitString = "additive" samplerString = None ncores = 64 nbatches = 16 dominance = 1.0 ssize = None fixationsFileName = None G2 = None nstub = None sstub = None for o, a in opts: if o == '-m': m = float(a) elif o == '-e': e = float(a) elif o == '-H': H = float(a) elif o == '-S': S = float(a) elif o == '-O': Opt = float(a) elif o == '-N': N = int(a) elif o == '-t': t = int(a) t2 = t elif o == '-s': seed = int(a) elif o == '-F': ofile = a elif o == '-r': r = float(a) elif o == '--nsam': ssize = int(a) elif o == '--theta': theta = float(a) elif o == '--rho': rho = float(a) elif o == '--trait': traitString = a if a not in valid_trait_models: print("Error: invalid trait model") usage() sys.exit(0) elif o == '--sampler': samplerString = a if a not in valid_sampler_names: print("Error: invalid sampler name") usage() sys.exit(0) elif o == '--cores': ncores = int(a) if ncores < 1: print("--ncores must be > 0") usage() sys.exit(0) elif o == '--batches': nbatches = int(a) if nbatches < 1: print("--nbatches myst be > 0") usage() sys.exit(0) elif o == '--nloci': NLOCI = int(a) if NLOCI < 2: rpint("--nloci must be > 1") usage() sys.exit(0) elif o == "--fixations": fixationsFileName = a elif o == "--t2": t2 = int(a) elif o == "--g2": G2 = int(a) elif o == "--nstub": nstub = a elif o == '--sstub': sstub = a #elif o == "--neutral": # if a != "None": # NeutralLocus=int(a) # else: # NeutralLocus=a if samplerString is None: print("Error: sampler must be defined") usage() sys.exit(0) if t is None: print("Error: sampling interval must be defined") usage() sys.exit(0) if t2 is None: t2 = t if m is None: usage() sys.exit(2) if ofile is None: usage() sys.exit(2) if G2 is None: G2 = 10 * N #Can start working now: REP = 0 out = pd.HDFStore(ofile, "w", complevel=6, complib='zlib') if fixationsFileName is not None: if os.path.exists(fixationsFileName): os.remove(fixationsFileName) little_r_per_locus = rho / (4.0 * float(N)) mu_n_region = theta / (4.0 * float(N)) rnge = fp.GSLrng(seed) rngs = fp.GSLrng(seed) nlist = np.array([N] * (10 * N), dtype=np.uint32) fitness = get_trait_model(traitString) sregions = [fp.GaussianS(0, 1, 1, e, dominance)] * NLOCI neutral_mut_rates = [mu_n_region] * NLOCI causal_mut_rates = [m / float(NLOCI)] * NLOCI #if NeutralLocus is not None: # causal_mut_rates[NeutralLocus]=0.0 for BATCH in range(nbatches): x = fp.MlocusPopVec(ncores, N, NLOCI) nstub_t = None sstub_t = None if nstub is not None: nstub_t = nstub + b'.pre_shift.batch' + str(BATCH) if sstub is not None: sstub_t = sstub + b'.pre_shift.batch' + str(BATCH) sampler = get_sampler(samplerString, len(x), Opt, ssize, rngs, nstub_t, sstub_t) qtm.evolve_qtraits_mloc_sample_fitness( rnge, x, sampler, fitness, nlist, neutral_mut_rates, causal_mut_rates, sregions, [little_r_per_locus] * NLOCI, [r] * (NLOCI - 1), #loci unlinked sample=t, VS=S) write_output(sampler, out, NLOCI, REP) if nstub is not None: nstub_t = nstub + b'.post_shift.batch' + str(BATCH) if sstub is not None: sstub_t = sstub + b'.post_shift.batch' + str(BATCH) sampler = get_sampler(samplerString, len(x), Opt, ssize, rngs, nstub_t, sstub_t) qtm.evolve_qtraits_mloc_sample_fitness( rnge, x, sampler, fitness, nlist[:G2], neutral_mut_rates, causal_mut_rates, sregions, [little_r_per_locus] * NLOCI, [r] * (NLOCI - 1), #loci unlinked sample=t2, VS=S, optimum=Opt) write_output(sampler, out, NLOCI, REP) if fixationsFileName is not None: write_fixations(x, fixationsFileName, REP) REP += len(x) if fixationsFileName is not None: con = sqlite3.connect(fixationsFileName) con.execute("create index gen on fixations (generation)") con.execute("create index gen_rep on fixations (generation,rep)") con.close() out.close()
def make_Gaussian_sregion(beg=0,end=1,weight=1,sigma = None): if sigma is None: raise RuntimeError("sigma cannot be None") return [fp.GaussianS(beg,end,weight,sigma)]
rnge=fp.GSLrng(100) nlist=np.array([N]*(15*N),dtype=np.uint32) theta_neutral_per_locus=0.0 rho_per_locus=100.0 little_r_per_locus=rho_per_locus/(4.0*float(N)) mu_n_region=theta_neutral_per_locus/(4.0*float(N)) mu_del_ttl=1e-3 #sigmas=[0.1]*NLOCI hdf=pd.HDFStore("cumVA.h5",'w') fmodel = fpw.MlocusAdditive() sregions = [] for i in range(NLOCI): sregions.append(fp.GaussianS(i,i+1,1,0.1)) REPLICATE=0 for batch in range(1): #4,000 reps... pops = fp.MlocusPopVec(NREPS,N,NLOCI) sampler = fp.NothingSampler(len(pops)) x = qtm.evolve_qtraits_mloc_sample_fitness(rnge,pops,sampler,fmodel, nlist[:(10*N)], [mu_n_region]*NLOCI, [mu_del_ttl/float(NLOCI)]*NLOCI, sregions, [little_r_per_locus]*NLOCI, [0.5]*(NLOCI-1),#loci unlinked sample=1) sampler = fp.VASampler(len(pops)) qtm.evolve_qtraits_mloc_sample_fitness(rnge,pops,sampler,fmodel,
f = gzip.open(PIK, "wb") N = 1000 scaled_sigmaMU = 250.0 sigMU = scaled_sigmaMU / N theta_n = 100.0 rho_n = 100.0 mun = 0.0 #theta_n/(4*N) littler = rho_n / (4 * N) rest = r - littler ratio = rest / r sample_interval = 0.01 #In units of N generations print sigMU, " ", mun, " ", int(sample_interval * N) neutmutregions = [fp.Region(0, 0.1, 1)] #selmutregions=[fp.GaussianS(-ratio,1+ratio,1,sigMU)] #recregions= [fp.Region(-ratio,1+ratio,1)] selmutregions = [fp.GaussianS(0, 0.1, 1, sigMU)] recregions = [fp.Region(0, 0.1, 1)] pickle.dump(NPIK, f) REP = 0 for i in range(NB): nlist = np.array([N] * (10 * N), dtype=np.uint32) #Evolve to equilibrium pops = fp.popvec(NCORES, N) samples = qt.evolve_qtrait_track(rng, pops, nlist[0:], mun, mu, r, neutmutregions,
def main(): try: opts, args = getopt.getopt(sys.argv[1:], "m:e:H:S:O:N:t:s:F:r:", ["cores=", "batches="]) except getopt.GetoptError as err: # print help information and exit: print(err) # will print something like "option -a not recognized" usage() sys.exit(2) #set up default params N = 1000 # pop size t = None # 0.1N e = 0.25 # s.d. of effect sizes S = 1 # V(S) H = None # desired b-sense H^2 m = None # Mutation rate (per gamete, per generation) to alleles affecting trait value r = 0.5 # rec. rate (per diploid, per gen) Opt = 0.0 # Value of optimum after 10N gens ofile = None seed = 0 ncores = 64 nbatches = 16 for o, a in opts: if o == '-m': m = float(a) elif o == '-e': e = float(a) elif o == '-H': H = float(a) elif o == '-S': S = float(a) elif o == '-O': Opt = float(a) elif o == '-N': N = int(a) elif o == '-t': t = int(a) elif o == '-s': seed = int(a) elif o == '-F': ofile = a elif o == '-r': r = float(a) elif o == '--cores': ncores = int(a) elif o == '--batches': nbatches = int(a) if t is None: t = int(0.1 * float(N)) if H is None: usage() sys.exit(2) if m is None: usage() sys.exit(2) if ofile is None: usage() sys.exit(2) rng = fp.GSLrng(seed) hdf = pd.HDFStore(ofile, 'w', complevel=6, complib='zlib') hdf.open() sigE = get_sigE_additive(m, S, H) nregions = [] recregions = [fp.Region(0, 1, 1)] sregions = [fp.GaussianS(0, 1, 1, e)] #population size over time -- constant & we re-use this over and over nlist = np.array([N] * (10 * N), dtype=np.uint32) #16 batches of 64 runs = 1024 replicates fitness = qt.SpopAdditiveTrait() REPLICATE = 0 for i in range(nbatches): pops = fp.SpopVec(ncores, N) sampler = fp.QtraitStatsSampler(len(pops), 0.0) #Evolve to equilibrium, tracking along the way qt.evolve_regions_qtrait_sampler_fitness(rng, pops, sampler, fitness, nlist[0:], 0, m, r, nregions, sregions, recregions, sigmaE=sigE, sample=t, VS=S, optimum=0) stats = sampler.get() RTEMP = REPLICATE for si in stats: ti = pd.DataFrame(si) ti['rep'] = [RTEMP] * len(ti.index) RTEMP += 1 hdf.append('popstats', ti) #simulate another 10*N generations, sampling stats every 't' generations sampler = fp.QtraitStatsSampler(len(pops), Opt) qt.evolve_regions_qtrait_sampler_fitness(rng, pops, sampler, fitness, nlist[0:], 0, m, r, nregions, sregions, recregions, sigmaE=sigE, sample=t, VS=S, optimum=Opt) stats = sampler.get() for si in stats: ti = pd.DataFrame(si) ti['rep'] = [REPLICATE] * len(ti.index) hdf.append('popstats', ti) REPLICATE += 1 hdf.close()
def main(): parser=make_parser() args=parser.parse_args(sys.argv[1:]) if args.verbose: print (args) ##Figure out sigma_E from params sigE = get_sigE_additive(args.mutrate,args.VS,args.H2) trait = get_trait_model(args.trait) nlist = np.array([args.popsize]*(10*args.popsize),dtype=np.uint32) rng=fp.GSLrng(args.seed) mu_neutral = 0.0 nregions=[] sregions=[fp.GaussianS(0,1,1,args.sigmu,args.dominance)] recregions=[fp.Region(0,1,1)] if args.sampler == 'stats': output=pd.HDFStore(args.outfile,'w',complevel=6,complib='zlib') output.close() REPID=0 for BATCH in range(args.nbatches): pops=fp.SpopVec(args.ncores,args.popsize) sampler=get_sampler_type(args.sampler,args.trait,len(pops),0.0) qt.evolve_regions_qtrait_sampler_fitness(rng,pops,sampler,trait, nlist, 0.0, args.mutrate, args.recrate, nregions, sregions, recregions, args.tsample, sigE, optimum=0.0, VS=args.VS) if args.sampler != 'freq': if args.sampler == 'freq': dummy=write_output(sampler,args,REPID,BATCH,'w') elif args.sampler == 'stats': dummy=write_output(sampler,args,REPID,BATCH,'a') else: dummy=write_output(sampler,args,REPID,BATCH,'a') sampler=get_sampler_type(args.sampler,args.trait,len(pops),args.optimum) qt.evolve_regions_qtrait_sampler_fitness(rng,pops,sampler,trait, nlist, 0.0, args.mutrate, args.recrate, nregions, sregions, recregions, args.tsample, sigE, optimum=args.optimum, VS=args.VS) if args.sampler == 'freq': #Append this time! REPID=write_output(sampler,args,REPID,BATCH,'w') elif args.sampler == 'stats': REPID=write_output(sampler,args,REPID,BATCH,'a') else: REPID=write_output(sampler,args,REPID,BATCH,'a')
def run_batch(argtuple): args, repid, batch = argtuple print("seed for batch = ", args.seed) nstub = "neutral.mu" + str(args.mu) + ".opt" + str(args.opt) sstub = "selected.mu" + str(args.mu) + ".opt" + str(args.opt) rnge = fp.GSLrng(args.seed) NANC = 7310 locus_boundaries = [(float(i + i * 11), float(i + i * 11 + 11)) for i in range(args.nloci)] nregions = [ fp.Region(j[0], j[1], args.theta / (4. * float(NANC)), coupled=True) for i, j in zip(range(args.nloci), locus_boundaries) ] recregions = [ fp.Region(j[0], j[1], args.rho / (4. * float(NANC)), coupled=True) for i, j in zip(range(args.nloci), locus_boundaries) ] sregions = [ fp.GaussianS(j[0] + 5., j[0] + 6., args.mu, args.sigmu, coupled=False) for i, j in zip(range(args.nloci), locus_boundaries) ] f = qtm.MlocusAdditiveTrait() nlist = np.array(get_nlist1(), dtype=np.uint32) pops = fp.MlocusPopVec(args.ncores, nlist[0], args.nloci) sampler = fp.NothingSampler(len(pops)) d = datetime.datetime.now() print("starting batch, ", batch, "at ", d.now()) qtm.evolve_qtraits_mloc_regions_sample_fitness(rnge, pops, sampler, f, nlist[0:], nregions, sregions, recregions, [0.5] * (args.nloci - 1), 0, 0, 0.) d = datetime.datetime.now() print(d.now()) nlist = np.array(get_nlist2(), dtype=np.uint32) qtm.evolve_qtraits_mloc_regions_sample_fitness(rnge, pops, sampler, f, nlist[0:], nregions, sregions, recregions, [0.5] * (args.nloci - 1), 0, args.opt) d = datetime.datetime.now() print(d.now()) if args.statfile is not None: sched = lsp.scheduler_init(args.TBB) for pi in pops: #Apply the sampler 1 population at a time. #This saves a fair bit of RAM. neutralFile = nstub + '.rep' + str(repid) + '.gz' selectedFile = sstub + '.rep' + str(repid) + '.gz' BIGsampler = fp.PopSampler(1, 6000, rnge, False, neutralFile, selectedFile, recordSamples=True, boundaries=locus_boundaries) fp.apply_sampler_single(pi, BIGsampler) if args.statfile is not None: for di in BIGsampler: process_samples((di, args.statfile, locus_boundaries, repid)) repid += 1 pops.clear() pops = None