def evolve_some_pops(w): print ("starting!") N=1000 rng = fp.GSLrng(101) pops = fp.SpopVec(10,N) nlist = np.array([N]*(10*N),dtype=np.uint32) sampler = fp.NothingSampler(len(pops)) fp.evolve_regions_sampler_fitness(rng,pops,sampler,w,nlist,0.,0.0025,0.01,n,s,r,0) dips1 = fp.view_diploids(pops,[0,1,2,3,4,5]) for i in dips1[0]: print (i['w'])
for i in smuts: if len(i) > 0: smutsdf = pd.concat([smutsdf, pd.DataFrame(i, index=[ind] * len(i))]) ind += 1 # In[11]: smutsdf.head() # That's much better. We can use the index to figure out which individual has which mutations, and their effect sizes, etc. # # Finally, we can also take views of diploids. Let's get the first two diploids in each population: # In[12]: dips = [fp.view_diploids(i, [0, 1]) for i in pops] # Again, the format here is ugly. Each diploid view is a dictionary: # In[13]: for key in dips[0][0]: print(key) # The values are: # # * chrom0, chrom1 are gamete views, just like what we dealt with above # * g = genetic component of phenotype # * e = random component of phenotype # * w = fitness # * n0 and n1 are the number of selected variants on chrom0 and chrom1, respectively.
smutsdf = pd.concat([smutsdf,pd.DataFrame(i,index=[ind]*len(i))]) ind += 1 # In[11]: smutsdf.head() # That's much better. We can use the index to figure out which individual has which mutations, and their effect sizes, etc. # # Finally, we can also take views of diploids. Let's get the first two diploids in each population: # In[12]: dips = [fp.view_diploids(i,[0,1]) for i in pops] # Again, the format here is ugly. Each diploid view is a dictionary: # In[13]: for key in dips[0][0]: print(key) # The values are: # # * chrom0, chrom1 are gamete views, just like what we dealt with above # * g = genetic component of phenotype # * e = random component of phenotype
def testException1(self): with self.assertRaises(IndexError): fwdpy.view_diploids(pops[0],[pops[0].popsize()])
def testBigDips(self): temp = fwdpy.view_diploids(pops[0],list(range(pops[0].popsize()))) self.assertEqual(len(temp),pops[0].popsize())
def testDipsize(self): dips_single = fwdpy.view_diploids(pops[0],[0,1,2]) self.assertEqual(len(dips_single),3)
def testException1(self): with self.assertRaises(IndexError): fwdpy.view_diploids(pops[0], [pops[0].popsize()])
def testBigDips(self): temp = fwdpy.view_diploids(pops[0], list(range(pops[0].popsize()))) self.assertEqual(len(temp), pops[0].popsize())
def testDipsize(self): dips_single = fwdpy.view_diploids(pops[0], [0, 1, 2]) self.assertEqual(len(dips_single), 3)