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