Exemple #1
0
    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
Exemple #2
0
    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'
Exemple #3
0
    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'
Exemple #4
0
    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
Exemple #5
0
    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'
Exemple #6
0
    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'
Exemple #7
0
    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'
Exemple #8
0
    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'
Exemple #9
0
    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'
Exemple #10
0
    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'