• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.counts函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.counts函数的典型用法代码示例。如果您正苦于以下问题:Python counts函数的具体用法?Python counts怎么用?Python counts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了counts函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_scale

    def test_scale(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        filename_left = self.empty()
        filename_right = self.empty()

        with utils.open_profile(self.profile(counts_left, 8)) as handle_left:
            with utils.open_profile(self.profile(counts_right, 8)) as handle_right:
                with utils.open_profile(filename_left, 'w') as out_left:
                    with utils.open_profile(filename_right, 'w') as out_right:
                        kmer.scale(handle_left, handle_right, out_left, out_right)

        if sum(counts_left.values()) < sum(counts_right.values()):
            scale_left = sum(counts_right.values()) / sum(counts_left.values())
            scale_right = 1.0
        else:
            scale_left = 1.0
            scale_right = sum(counts_left.values()) / sum(counts_right.values())

        for s in counts_left:
            counts_left[s] *= scale_left
        for s in counts_right:
            counts_right[s] *= scale_right

        utils.test_profile_file(filename_left, counts_left, 8)
        utils.test_profile_file(filename_right, counts_right, 8)
开发者ID:Biomarino,项目名称:kPAL,代码行数:26,代码来源:test_kmer.py


示例2: test_ProfileDistance_distance_k8

    def test_ProfileDistance_distance_k8(self):
        counts_a = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_b = utils.counts(utils.SEQUENCES_RIGHT, 8)

        profile_a = klib.Profile(utils.as_array(counts_a, 8))
        profile_b = klib.Profile(utils.as_array(counts_b, 8))

        k_dist = kdistlib.ProfileDistance()
        np.testing.assert_almost_equal(k_dist.distance(profile_a, profile_b), 0.4626209322)
开发者ID:LUMC,项目名称:kPAL,代码行数:9,代码来源:test_kdistlib.py


示例3: test_profile_merge

    def test_profile_merge(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)

        profile_left = klib.Profile(utils.as_array(counts_left, 8))
        profile_right = klib.Profile(utils.as_array(counts_right, 8))

        profile_left.merge(profile_right)
        utils.test_profile(profile_left, counts_left + counts_right, 8)
开发者ID:LUMC,项目名称:kPAL,代码行数:9,代码来源:test_klib.py


示例4: test_distance

    def test_distance(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        out = StringIO()

        with utils.open_profile(self.profile(counts_left, 8, 'left')) as handle_left:
            with utils.open_profile(self.profile(counts_right, 8, 'right')) as handle_right:
                kmer.distance(handle_left, handle_right, out)

        assert out.getvalue() == 'left right %.10f\n' % 0.4626209323
开发者ID:Biomarino,项目名称:kPAL,代码行数:10,代码来源:test_kmer.py


示例5: test_count_multi

 def test_count_multi(self):
     counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
     counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
     filename = self.empty()
     with open(self.fasta(utils.SEQUENCES_LEFT)) as handle_left:
         with open(self.fasta(utils.SEQUENCES_RIGHT)) as handle_right:
             with utils.open_profile(filename, 'w') as profile_handle:
                 kmer.count([handle_left, handle_right], profile_handle, 8, names=['a', 'b'])
     utils.test_profile_file(filename, counts_left, 8, name='a')
     utils.test_profile_file(filename, counts_right, 8, name='b')
开发者ID:LUMC,项目名称:kPAL,代码行数:10,代码来源:test_kmer.py


示例6: test_merge

    def test_merge(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        filename = self.empty()

        with utils.open_profile(self.profile(counts_left, 8)) as handle_left:
            with utils.open_profile(self.profile(counts_right, 8)) as handle_right:
                with utils.open_profile(filename, 'w') as profile_handle:
                    kmer.merge(handle_left, handle_right, profile_handle)
        utils.test_profile_file(filename, counts_left + counts_right, 8)
开发者ID:Biomarino,项目名称:kPAL,代码行数:10,代码来源:test_kmer.py


示例7: test_distance_smooth

    def test_distance_smooth(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        out = StringIO()

        with utils.open_profile(self.profile(counts_left, 8, 'left')) as handle_left:
            with utils.open_profile(self.profile(counts_right, 8, 'right')) as handle_right:
                kmer.distance(handle_left, handle_right, out, do_smooth=True, precision=3)

        assert out.getvalue() == 'left right 0.077\n'
开发者ID:Biomarino,项目名称:kPAL,代码行数:10,代码来源:test_kmer.py


示例8: test_distance_pairwise_expr

    def test_distance_pairwise_expr(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        out = StringIO()

        with utils.open_profile(self.profile(counts_left, 8, 'left')) as handle_left:
            with utils.open_profile(self.profile(counts_right, 8, 'right')) as handle_right:
                kmer.distance(handle_left, handle_right, out, precision=3,
                              custom_pairwise='abs(left - right) / (left + right + 1000)')

        assert out.getvalue() == 'left right 0.001\n'
开发者ID:Biomarino,项目名称:kPAL,代码行数:11,代码来源:test_kmer.py


示例9: test_distance_pairwise_name

    def test_distance_pairwise_name(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        out = StringIO()

        with utils.open_profile(self.profile(counts_left, 8, 'left')) as handle_left:
            with utils.open_profile(self.profile(counts_right, 8, 'right')) as handle_right:
                kmer.distance(handle_left, handle_right, out, precision=3,
                              custom_pairwise='numpy.multiply')

        assert out.getvalue() == 'left right 0.084\n'
开发者ID:Biomarino,项目名称:kPAL,代码行数:11,代码来源:test_kmer.py


示例10: test_cat_prefixes

    def test_cat_prefixes(self):
        counts_a = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_b = utils.counts(utils.SEQUENCES_RIGHT, 8)
        filename = self.empty()

        with utils.open_profile(self.profile(counts_a, 8, name='X')) as handle_a:
            with utils.open_profile(self.profile(counts_b, 8, name='X')) as handle_b:
                with utils.open_profile(filename, 'w') as profile_handle:
                    kmer.cat([handle_a, handle_b], profile_handle, prefixes=['a_', 'b_'])
        utils.test_profile_file(filename, counts_a, 8, name='a_X')
        utils.test_profile_file(filename, counts_b, 8, name='b_X')
开发者ID:Biomarino,项目名称:kPAL,代码行数:11,代码来源:test_kmer.py


示例11: test_distance_smooth_expr

    def test_distance_smooth_expr(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        out = StringIO()

        with utils.open_profile(self.profile(counts_left, 8, 'left')) as handle_left:
            with utils.open_profile(self.profile(counts_right, 8, 'right')) as handle_right:
                kmer.distance(handle_left, handle_right, out, do_smooth=True,
                              precision=3, custom_summary='np.max(values)')

        assert out.getvalue() == 'left right 0.474\n'
开发者ID:Biomarino,项目名称:kPAL,代码行数:11,代码来源:test_kmer.py


示例12: test_distance_matrix_two

    def test_distance_matrix_two(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)

        profiles = [klib.Profile(utils.as_array(counts_left, 8), 'a'),
                    klib.Profile(utils.as_array(counts_right, 8), 'b')]

        k_dist = kdistlib.ProfileDistance()
        out = StringIO()
        kdistlib.distance_matrix(profiles, out, 2, k_dist)

        assert out.getvalue().strip().split('\n') == ['2', 'a', 'b', '0.46']
开发者ID:LUMC,项目名称:kPAL,代码行数:12,代码来源:test_kdistlib.py


示例13: test_ProfileDistance_distance_unmodified

    def test_ProfileDistance_distance_unmodified(self):
        counts_a = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_b = utils.counts(utils.SEQUENCES_RIGHT, 8)

        profile_a = klib.Profile(utils.as_array(counts_a, 8))
        profile_b = klib.Profile(utils.as_array(counts_b, 8))

        k_dist = kdistlib.ProfileDistance(do_balance=True)
        k_dist.distance(profile_a, profile_b)

        utils.test_profile(profile_a, counts_a, 8)
        utils.test_profile(profile_b, counts_b, 8)
开发者ID:LUMC,项目名称:kPAL,代码行数:12,代码来源:test_kdistlib.py


示例14: test_distance_matrix_smooth

    def test_distance_matrix_smooth(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        out = StringIO()

        with utils.open_profile(self.multi_profile(8,
                                                   [counts_left,
                                                    counts_right,
                                                    counts_left],
                                                   ['a', 'b', 'c'])) as handle:
                    kmer.distance_matrix(handle, out, do_smooth=True, precision=3)

        assert out.getvalue().strip().split('\n') == ['3', 'a', 'b', 'c', '0.077', '0.000 0.077']
开发者ID:Biomarino,项目名称:kPAL,代码行数:13,代码来源:test_kmer.py


示例15: test_count_multi_by_record

 def test_count_multi_by_record(self):
     counts_by_record_left = [utils.counts(record, 8) for record in utils.SEQUENCES_LEFT]
     counts_by_record_right = [utils.counts(record, 8) for record in utils.SEQUENCES_RIGHT]
     names_left = [str(i) for i, _ in enumerate(counts_by_record_left)]
     names_right = [str(i) for i, _ in enumerate(counts_by_record_right)]
     filename = self.empty()
     with open(self.fasta(utils.SEQUENCES_LEFT, names=names_left)) as handle_left:
         with open(self.fasta(utils.SEQUENCES_RIGHT, names=names_right)) as handle_right:
             with utils.open_profile(filename, 'w') as profile_handle:
                 kmer.count([handle_left, handle_right], profile_handle, 8, names=['a', 'b'], by_record=True)
     for name, counts in zip(names_left, counts_by_record_left):
         utils.test_profile_file(filename, counts, 8, name='a_' + name)
     for name, counts in zip(names_right, counts_by_record_right):
         utils.test_profile_file(filename, counts, 8, name='b_' + name)
开发者ID:LUMC,项目名称:kPAL,代码行数:14,代码来源:test_kmer.py


示例16: test_merge_custom_name

    def test_merge_custom_name(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        filename = self.empty()

        with utils.open_profile(self.profile(counts_left, 8)) as handle_left:
            with utils.open_profile(self.profile(counts_right, 8)) as handle_right:
                with utils.open_profile(filename, 'w') as profile_handle:
                    kmer.merge(handle_left, handle_right, profile_handle, custom_merger='numpy.multiply')

        counts_mult = Counter(dict((s, counts_left[s] * counts_right[s])
                                   for s in set(counts_left) & set(counts_right)))

        utils.test_profile_file(filename, counts_mult, 8)
开发者ID:Biomarino,项目名称:kPAL,代码行数:14,代码来源:test_kmer.py


示例17: test_distance_matrix_pairwise_name

    def test_distance_matrix_pairwise_name(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        out = StringIO()

        with utils.open_profile(self.multi_profile(8,
                                                   [counts_left,
                                                    counts_right,
                                                    counts_left],
                                                   ['a', 'b', 'c'])) as handle:
                    kmer.distance_matrix(handle, out, precision=3,
                                         custom_pairwise='numpy.multiply')

        assert out.getvalue().strip().split('\n') == ['3', 'a', 'b', 'c', '0.084', '1.206 0.084']
开发者ID:Biomarino,项目名称:kPAL,代码行数:14,代码来源:test_kmer.py


示例18: test_distance_matrix_pairwise_expr

    def test_distance_matrix_pairwise_expr(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        out = StringIO()

        with utils.open_profile(self.multi_profile(8,
                                                   [counts_left,
                                                    counts_right,
                                                    counts_left],
                                                   ['a', 'b', 'c'])) as handle:
                    kmer.distance_matrix(handle, out, precision=3,
                                         custom_pairwise='abs(left - right) / (left + right + 1000)')

        assert out.getvalue().strip().split('\n') == ['3', 'a', 'b', 'c', '0.001', '0.000 0.001']
开发者ID:Biomarino,项目名称:kPAL,代码行数:14,代码来源:test_kmer.py


示例19: test_merge_custom_expr

    def test_merge_custom_expr(self):
        counts_left = utils.counts(utils.SEQUENCES_LEFT, 8)
        counts_right = utils.counts(utils.SEQUENCES_RIGHT, 8)
        filename = self.empty()

        with utils.open_profile(self.profile(counts_left, 8)) as handle_left:
            with utils.open_profile(self.profile(counts_right, 8)) as handle_right:
                with utils.open_profile(filename, 'w') as profile_handle:
                    kmer.merge(handle_left, handle_right, profile_handle, custom_merger='(left + right) * np.logical_xor(left, right)')

        counts_xor = counts_left + counts_right
        for s in set(counts_left) & set(counts_right):
            del counts_xor[s]

        utils.test_profile_file(filename, counts_xor, 8)
开发者ID:Biomarino,项目名称:kPAL,代码行数:15,代码来源:test_kmer.py


示例20: test_convert

 def test_convert(self):
     counts = utils.counts(utils.SEQUENCES, 8)
     filename = self.empty()
     with open(self.profile_old_format(counts, 8)) as handle:
         with utils.open_profile(filename, 'w') as profile_handle:
             kmer.convert([handle], profile_handle)
     utils.test_profile_file(filename, counts, 8)
开发者ID:Biomarino,项目名称:kPAL,代码行数:7,代码来源:test_kmer.py



注:本文中的utils.counts函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.create_ansible_mock函数代码示例发布时间:2022-05-26
下一篇:
Python utils.copyfile函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap