当前位置: 首页>>代码示例>>Python>>正文


Python utils.open_profile函数代码示例

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


在下文中一共展示了open_profile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_balance

    def test_balance(self):
        counts = utils.counts(utils.SEQUENCES, 8)
        filename = self.empty()

        with utils.open_profile(self.profile(counts, 8)) as input_handle:
            with utils.open_profile(filename, 'w') as output_handle:
                kmer.balance(input_handle, output_handle)
        counts.update(dict((utils.reverse_complement(s), c) for s, c in counts.items()))
        utils.test_profile_file(filename, counts, 8)
开发者ID:Biomarino,项目名称:kPAL,代码行数:9,代码来源:test_kmer.py

示例3: test_profile_from_file_save

    def test_profile_from_file_save(self):
        counts = utils.counts(utils.SEQUENCES, 4)
        with utils.open_profile(self.profile(counts, 4), 'r') as profile_handle:
            profile = klib.Profile.from_file(profile_handle)

        filename = self.empty()
        with utils.open_profile(filename, 'w') as profile_handle:
            profile.save(profile_handle)

        utils.test_profile_file(filename, counts, 4)
开发者ID:LUMC,项目名称:kPAL,代码行数:10,代码来源: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_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

示例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_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

示例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_shrink

    def test_shrink(self):
        counts = utils.counts(utils.SEQUENCES, 8)
        filename = self.empty()

        with utils.open_profile(self.profile(counts, 8)) as input_handle:
            with utils.open_profile(filename, 'w') as output_handle:
                kmer.shrink(input_handle, output_handle, 1)

        counts = Counter(dict((t, sum(counts[u] for u in counts
                                            if u.startswith(t)))
                                    for t in set(s[:-1] for s in counts)))
        utils.test_profile_file(filename, counts, 7)
开发者ID:Biomarino,项目名称:kPAL,代码行数:12,代码来源:test_kmer.py

示例12: test_smooth_custom_name

    def test_smooth_custom_name(self):
        # See test_kdistlib.test_ProfileDistance_dynamic_smooth
        counts_left = Counter(['AC', 'AG', 'AT', 'CA', 'CC', 'CG', 'CT', 'GA', 'GC', 'GG', 'GT', 'TA', 'TG', 'TT'])
        counts_right = Counter(['AC', 'AT', 'CA', 'CC', 'CG', 'CT', 'GA', 'GC', 'GG', 'GT', 'TA', 'TC', 'TG', 'TT'])
        filename_left = self.empty()
        filename_right = self.empty()

        with utils.open_profile(self.profile(counts_left, 2)) as handle_left:
            with utils.open_profile(self.profile(counts_right, 2)) as handle_right:
                with utils.open_profile(filename_left, 'w') as out_left:
                    with utils.open_profile(filename_right, 'w') as out_right:
                        kmer.smooth(handle_left, handle_right, out_left, out_right, custom_summary='numpy.max')
开发者ID:Biomarino,项目名称:kPAL,代码行数:12,代码来源:test_kmer.py

示例13: test_shuffle

    def test_shuffle(self):
        # See test_klib.profile_shuffle
        counts = utils.counts(utils.SEQUENCES, 2)
        filename = self.empty()

        with utils.open_profile(self.profile(counts, 2)) as input_handle:
            with utils.open_profile(filename, 'w') as output_handle:
                np.random.seed(100)
                kmer.shuffle(input_handle, output_handle)

        counts = dict(zip([''.join(s) for s in itertools.product('ACGT', repeat=2)],
                          [13,  7,  6, 18, 12,  1, 13, 17, 16, 12, 23, 27, 24, 17, 18, 12]))
        utils.test_profile_file(filename, counts, 2)
开发者ID:Biomarino,项目名称:kPAL,代码行数:13,代码来源:test_kmer.py

示例14: 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

示例15: 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


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