Exemple #1
0
def hapinitial(allele):
    
    #Edge counts are used. Count of edge/Total count for all edges.
    for i in G.out_edges(1, data=True):        
        if i[2]['allele'] == allele:
            return sum(G.node[i[1]]['frequency'])/sum(G.node[1]['frequency'])
Exemple #2
0
        else:
            x = sum(G.node[e[1]]['frequency'])
            
        #Edge count/parent node count is returned
        return x/sum(G.node[e[0]]['frequency']) 
    else:
        return 0.0


#Diploid transition probabilities
def diptrans(a,b):
    return haptrans(a)*haptrans(b)


#Initiation. Iterate through pairs of outgoing edges from node 1.
for a, b  in itertools.product([(i, j) for i, j in enumerate(G.out_edges(1, keys=True, data=True))], repeat=2):
    
    #If emmsion probability does not equal 0
    if emission(GT[0],(a[1][3]['allele'],b[1][3]['allele'])) != 0:        
        
        if a[1] == b[1]:
            t = hapinitial(a[1][3]['allele'])
            var = t*t            
        else:
            var = dipinitial(a[1][3]['allele'], b[1][3]['allele'])

        #Matrix element is set to calculated diploid initial probability
        m[0][a[0]][b[0]] = var

#Induction. Iterate through each level
for i in range(1,ll):