Пример #1
0
def countsOnAlignment(qXa):
    countsTotal = np.zeros((5,5))
    countsTotalEmm = np.zeros((4,4))
    transTotal = np.zeros((3,3))
    gammaTotal = np.zeros((3))
    alnQ,alnT = qXa[1],qXa[0] 
    nq = len(alnQ)
    q = np.arange(nq,dtype=np.int_)
    tempQ = map(ord,alnQ)
    q = np.asarray(tempQ)
    nt = len(alnT)
    t = np.arange(nt,dtype=np.int_)
    tempT = map(ord,alnT)
    t = np.asarray(tempT)
    countsLocal,transLocal,countsLocalEmm,gammaLocal = cS.getCountsFromAln(q,nq,t,nt)
    countsTotal = np.add(countsLocal,countsTotal)
    countsTotalEmm = np.add(countsLocalEmm,countsTotalEmm)
    transTotal = np.add(transLocal,transTotal)
    gammaTotal = np.add(gammaLocal,gammaTotal)

    print "countsTotal:\n",countsTotal
    tProb = cS.getTransProb(transTotal)
    print "tProb:\n",tProb
    ProbInit = cS.getInitProb(gammaTotal)
    print "InitProb:\n", ProbInit
    eProbM = cS.new_eProb(countsTotal)
    print "eProb in match state:\n",eProbM
    eProbX = cS.new_eProb(countsTotalEmm)
    print "eProb in ins state:\n",eProbX
Пример #2
0
def countsOnList(SqPq):
    countsTotal = np.zeros((5,5))
    countsTotalEmm = np.zeros((4,4))
    transTotal = np.zeros((3,3))
    gammaTotal = np.zeros((3))
    for hit in SqPq:
        if hit != '':
           alnQ,alnT = hit[1],hit[0]
           nq = len(alnQ)
           q = np.arange(nq,dtype=np.int_)
           tempQ = map(ord,alnQ)
           q = np.asarray(tempQ)
           nt = len(alnT)
           t = np.arange(nt,dtype=np.int_)
           tempT = map(ord,alnT)
           t = np.asarray(tempT)
           countsLocal,transLocal,countsLocalEmm,gammaLocal = cS.getCountsFromAln(q,nq,t,nt)
           countsTotal = np.add(countsLocal,countsTotal)
           countsTotalEmm = np.add(countsLocalEmm,countsTotalEmm)
           transTotal = np.add(transLocal,transTotal)
           gammaTotal = np.add(gammaLocal,gammaTotal)
#    print "countsTotal:\n",countsTotal
           #print "countsTotalEmm:\n",countsTotalEmm

    tProb = cS.getTransProb(transTotal)
#    print "tProb:\n",tProb
    tProb = balancetProb(tProb) 
#    print "tProbB:\n",tProb
    ProbInit = cS.getInitProb(gammaTotal)
#    print "ProbInit:\n",ProbInit
    ProbInit = balanceProbInit(ProbInit) 
#    print "ProbInitB:\n",ProbInit
    temp = np.vstack((tProb,ProbInit))
    colOfZero = np.zeros((4,1))
    temp2 = np.hstack((temp,colOfZero))
    tau = np.array([[0.0],[0.0],[0.0],[0.0]])
    temp3 = np.hstack((temp2,tau))
    rowOfZero = np.zeros((1,5))
    tProbHmm = np.vstack((temp3,rowOfZero))
#    print "Transition Prob.:\n",tProbHmm

    eProbM = cS.new_eProb(countsTotal)
#    print "eProb in match state:\n",eProbM

    eProbX = cS.new_eProb(countsTotalEmm)
#    print "eProb in ins state:\n",eProbX
    return tProbHmm, eProbM, eProbX