Beispiel #1
0
        def helper(y1,y2):
            alphabet = ('A','B','')
            toy_alphabet = OrderedDict([('A',0),('B',1)])
            profile1= profile(y1,alphabet)
            profile2=profile(y2,alphabet)
            joint_prof = joint_profile(profile1, profile2)

            gamma = decoding.pair_gamma(y1,y2)
            self.assertTrue(np.isclose(gamma[0,0], joint_prof.prob_agree))
Beispiel #2
0
        def helper(y1,y2):
            alphabet = ('A','B','')
            toy_alphabet = OrderedDict([('A',0),('B',1)])
            profile1= profile(y1,alphabet)
            profile2=profile(y2,alphabet)
            joint_prof = joint_profile(profile1, profile2)

            gamma = decoding.decoding_cy.pair_gamma_log(np.log(y1).astype(np.float64),np.log(y2).astype(np.float64))
            print('log(Z):',gamma[0,0],np.log(joint_prof.prob_agree))
            self.assertTrue(np.isclose(gamma[0,0], np.log(joint_prof.prob_agree)))
Beispiel #3
0
        def helper(y1,y2):
            alphabet = ('A','B','')
            toy_alphabet = OrderedDict([('A',0),('B',1)])

            profile1= profile(y1,alphabet)
            profile2=profile(y2,alphabet)
            joint_prof = joint_profile(profile1, profile2)

            top_label = joint_prof.top_label()
            search_top_label = decoding.pair_prefix_search(y1,y2,alphabet=toy_alphabet)
            return((top_label[0] == search_top_label[0]) and np.isclose(top_label[1] / joint_prof.prob_agree, search_top_label[1]))
Beispiel #4
0
 def helper(y):
     alphabet = ('A','B','')
     toy_alphabet = OrderedDict([('A',0),('B',1)])
     prof = profile(y,alphabet)
     top_label = prof.top_label()
     search_top_label = decoding.prefix_search(y,alphabet=toy_alphabet)
     return((top_label[0] == search_top_label[0]) and np.isclose(top_label[1], search_top_label[1]))
Beispiel #5
0
 def helper(y,l):
     label_int = [alphabet_dict[i] for i in label]
     prof = profile(y,alphabet)
     alpha  = np.log(decoding.forward(label_int, y))
     prefix_prob = logsumexp(decoding.forward_vec_no_gap_log(label_int,np.log(y),alpha[-2]))
     print(prefix_prob, prof.prefix_prob(label))
     self.assertTrue(np.isclose(prefix_prob, np.log(prof.prefix_prob(label))))
Beispiel #6
0
    def test_label_prob_log(self):
        alphabet = ('A','B','')
        alphabet_dict = {'A':0,'B':1,'':2}

        y = np.array([[0.8,0.1,0.1],[0.1,0.3,0.6],[0.7,0.2,0.1],[0.1,0.1,0.8]])
        examples = ['AAAA','ABBA','ABA','AA','BB','A','B']
        prof=profile(y,alphabet)

        for label in examples:
            label_int = [alphabet_dict[i] for i in label]
            alpha  = decoding.forward(label_int, np.log(y), decoding.forward_vec_log)
            self.assertTrue(np.isclose(alpha[-1,-1], np.log(prof.label_prob(label))))
Beispiel #7
0
 def helper(y,l):
     label_int = [alphabet_dict[i] for i in label]
     prof = profile(y,alphabet)
     alpha  = decoding.forward(label_int, y)
     prefix_prob = np.sum(decoding.forward_vec_no_gap(label_int,y,alpha[-2]))
     self.assertTrue(np.isclose(prefix_prob, prof.prefix_prob(label)))