예제 #1
0
random.shuffle(haplotypes)
haplotypes = haplotypes[0:numSample]

newHap = []
for i in range(0,numSample): 
    newHap.append([])

# print "numMut\t" + str(len(mutations))

for i in range(0,len(mutations)): 
    bla = map(lambda x : x[i], haplotypes)
    occ = reduce(lambda x,y: int(x) + int(y) , bla )
    if not (occ == 0 or occ == numSample): 
        for j in range(0,len(haplotypes)) : 
            newHap[j].append(bla[j])

haplotypes = []
for h in newHap: 
    haplotypes.append( "".join(h)  )     

print "#snp\t%d"  %  len(haplotypes[0])
print "#h\t%d"  % len(set(map(lambda x : "".join(x), haplotypes))) 

pi = sumStatLib.nucDiv(haplotypes, seqLen ) # :TRICKY: 
print "pi\t%f" % pi 

print "sfs"
sfsDict =  sumStatLib.sfs(haplotypes)
for key in sfsDict.keys():
    print "%d\t%d" % (key, sfsDict[key])
예제 #2
0
           ' ', ETA()] 
pbar = ProgressBar(widgets=widgets, maxval=numRep-1)
pbar.start()

numSnp = []
numHap = []
pies = []
sfsDict = {}

for i in range(0,numRep-1): 
    pbar.update(i)
    haplotypes = oneSample(numSamp)
    
    numSnp.append(len(haplotypes[0]) ) 
    numHap.append(len(set(haplotypes)))
    pies.append(sumStatLib.nucDiv(haplotypes, seqLen)) # :TRICKY:
    
    tmpDict = sumStatLib.sfs(haplotypes)
    ctr += 1 

    for key in tmpDict: 
        if sfsDict.has_key(key): 
            sfsDict[key] += float(tmpDict[key])
        else : 
            sfsDict[key] = float(tmpDict[key])
pbar.finish()

    
for key in sfsDict.keys():
    sfsDict[key] /= float(numRep)