From a69a69be8139971fb3a12583333588114278ee83 Mon Sep 17 00:00:00 2001 From: Svenja Mehringer Date: Fri, 15 Dec 2023 09:41:16 +0100 Subject: [PATCH] [TEST] Reactivate rearrange_user_bins test. --- test/unit/hibf/sketch/toolbox_test.cpp | 43 +++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/test/unit/hibf/sketch/toolbox_test.cpp b/test/unit/hibf/sketch/toolbox_test.cpp index 9f629cba..0b5f8847 100644 --- a/test/unit/hibf/sketch/toolbox_test.cpp +++ b/test/unit/hibf/sketch/toolbox_test.cpp @@ -268,9 +268,42 @@ TEST_F(toolbox_test, cluster_bins) } } -// TEST_F(toolbox_test, rearrange_bins) -// { -// seqan::hibf::sketch::toolbox::rearrange_bins(test_sketches, test_kmer_counts, test_positions, 0.9, 1); +TEST_F(toolbox_test, rearrange_bins) +{ + { + // with the test data, from the fixture, the distance are all 0 and there is no rearrangement + seqan::hibf::sketch::toolbox::rearrange_bins(test_sketches, test_kmer_counts, test_positions, 0.9, 1); + EXPECT_RANGE_EQ(test_positions, (std::vector{0, 1, 2, 3})); + } -// EXPECT_RANGE_EQ(test_positions, (std::vector{3, 2, 0, 1})); -// } + { + std::vector kmer_counts{5000, 5000, 5000, 5000, 5000, 5000, 5000}; + std::vector positions{0, 1, 2, 3, 4, 5, 6}; + std::vector sketches = [&]() + { + std::vector result(kmer_counts.size(), seqan::hibf::sketch::hyperloglog(10)); + + for (size_t i = 0; i < 5000; ++i) + { + // 0 and 3 are the same + result[0].add(i); + result[3].add(i); + + // 1 and 6 are the same and each shares 1000 kmers with 0 and 3 + result[1].add(i + 4000); + result[6].add(i + 4000); + + // 2 and 4 are the same and share no kmers with any other bin + result[2].add(i + 20000); + result[4].add(i + 20000); + + result[5].add(i + 8000); // 5 shares 1000 kmers with 1 and 6 + } + + return result; + }(); + + seqan::hibf::sketch::toolbox::rearrange_bins(sketches, kmer_counts, positions, 0.9, 1); + EXPECT_RANGE_EQ(positions, (std::vector{5, 1, 6, 0, 3, 2, 4})); + } +}