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']
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']
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']