示例#1
0
    def test_VOR_mc_threshold(self):
        """VOR: should apply monte carlo when # of pseudo seqs > mc_threshold
        """
        err = 9e-2
        aln2_exp = {'seq1': .259, 'seq2': .315, 'seq3': .167, 'seq4': .259}

        # the following assertSimilarMeans statement was added to replace
        # stochastic assertFloatEqualAbs call below
        self.assertSimilarMeans(
            VOR(self.aln2, mc_threshold=15).values(), aln2_exp.values())
        #self.assertFloatEqual(VOR(self.aln2,mc_threshold=15).values(),\
        #    aln2_exp.values(),err)

        #make sure monte carlo is used
        results = []
        for x in range(5):
            results.append(VOR(self.aln2, mc_threshold=15))
            if x > 0:
                self.assertNotEqual(results[x], results[x - 1])
示例#2
0
    def test_VOR_force_mc(self):
        """VOR: should result in good approximation when using monte carlo"""
        err = 9e-2
        aln2_exp = {'seq1': .259, 'seq2': .315, 'seq3': .167, 'seq4': .259}
        aln3_exp = {'seq1': .29167, 'seq2': .29167, 'seq3': .4167}
        aln4_exp = {'seq1':.1851, 'seq2':.1851,'seq3':.1851,'seq4':.1851,\
            'seq5':.259}
        aln6_exp = dict(list(zip(list(map(str,[1,2,3,4,5,6,7,8,9,10])),\
            [0.0840,0.0763,0.1155,0.1019,0.0932,0.0980,0.0864,\
            0.0999,0.1121,0.1328])))

        # the following assertSimilarMeans statements were added to replace
        # stochastic assertFloatEqualAbs calls below
        self.assertSimilarMeans(
            list(VOR(self.aln2, force_monte_carlo=True).values()),
            list(aln2_exp.values()))
        self.assertSimilarMeans(
            list(VOR(self.aln3, force_monte_carlo=True).values()),
            list(aln3_exp.values()))
        self.assertSimilarMeans(
            list(VOR(self.aln4, force_monte_carlo=True).values()),
            list(aln4_exp.values()))
        self.assertSimilarMeans(list(VOR(self.aln6, n=1000).values()),
                                list(aln6_exp.values()))

        #self.assertFloatEqualAbs(VOR(self.aln2,force_monte_carlo=True)\
        #    .values(), aln2_exp.values(),eps=err)
        #self.assertFloatEqualAbs(VOR(self.aln3,force_monte_carlo=True)\
        #    .values(), aln3_exp.values(),eps=err)
        #self.assertFloatEqualAbs(VOR(self.aln4,force_monte_carlo=True)\
        #    .values(), aln4_exp.values(),eps=err)
        #self.assertFloatEqualAbs(VOR(self.aln6,n=1000)\
        #    .values(), aln6_exp.values(),eps=err)

        #make sure monte carlo is used
        results = []
        for x in range(5):
            results.append(VOR(self.aln2, force_monte_carlo=True))
            if x > 0:
                self.assertNotEqual(results[x], results[x - 1])
示例#3
0
    def test_VOR_exact(self):
        """VOR: should give exact results when using pseudo_seqs_exact"""
        err=1e-3
        aln2_exp = {'seq1':.259, 'seq2':.315,'seq3':.167,'seq4':.259}
        aln3_exp = {'seq1':.29167, 'seq2':.29167, 'seq3':.4167}
        aln4_exp = {'seq1':.1851, 'seq2':.1851,'seq3':.1851,'seq4':.1851,\
            'seq5':.259}
        
        self.assertFloatEqualAbs(VOR(self.aln2).values(),aln2_exp.values(),
            eps=err)
        self.assertFloatEqualAbs(VOR(self.aln3).values(),aln3_exp.values(),\
            eps=err)
        self.assertFloatEqualAbs(VOR(self.aln4).values(),aln4_exp.values(),\
            eps=err)

        #this is the exact method, so the answer should be exactly the same
        #every time (on the same alignment)
        results = []
        for x in range(5):
            results.append(VOR(self.aln2))
            if x > 0:
                self.assertEqual(results[x], results[x-1])