From 61907ec0efe00f6e3d4dc630b618e584c4a99289 Mon Sep 17 00:00:00 2001 From: smehringer Date: Tue, 20 Aug 2024 12:17:52 +0200 Subject: [PATCH] delte read_hll file test. --- test/api/sketch/read_hll_files_into_test.cpp | 118 ------------------- 1 file changed, 118 deletions(-) delete mode 100644 test/api/sketch/read_hll_files_into_test.cpp diff --git a/test/api/sketch/read_hll_files_into_test.cpp b/test/api/sketch/read_hll_files_into_test.cpp deleted file mode 100644 index 74c73601..00000000 --- a/test/api/sketch/read_hll_files_into_test.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// --------------------------------------------------------------------------------------------------- -// Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin -// Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik -// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License -// shipped with this file and also available at: https://github.com/seqan/chopper/blob/main/LICENSE.md -// --------------------------------------------------------------------------------------------------- - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "../api_test.hpp" - -struct input_traits : public seqan3::sequence_file_input_default_traits_dna -{ - using sequence_alphabet = seqan3::dna4; -}; -using sequence_file_type = seqan3::sequence_file_input>; - -// inherits from toolbox to test private members -struct read_hll_files_into_test : public ::testing::Test -{ - std::vector test_filenames{"small.fa", "small.fa", "small2.fa", "small2.fa"}; - std::vector test_kmer_counts{500, 600, 700, 800}; - std::vector test_positions{0, 1, 2, 3}; - std::vector test_sketches = [this]() - { - std::vector result; - chopper::sketch::read_hll_files_into(data(""), test_filenames, result); - return result; - }(); -}; - -TEST_F(read_hll_files_into_test, basic) -{ - size_t const kmer_size{16}; - size_t const b{5}; - seqan::hibf::sketch::hyperloglog expected{b}; - - std::vector target{}; - - std::string const input_file{data("small.fa")}; - sequence_file_type seq_file{input_file}; - - auto minimizer_view = seqan3::views::minimiser_hash(seqan3::ungapped{kmer_size}, - seqan3::window_size{kmer_size}, - seqan3::seed{chopper::adjust_seed(kmer_size)}); - - // put every sequence in this file into the sketch - for (auto && [seq] : seq_file) - { - for (auto hash : seq | minimizer_view) - expected.add(hash); - } - - chopper::sketch::read_hll_files_into(data(""), test_filenames, target); - - EXPECT_EQ(target.size(), 4u); - for (auto const & sketch : target) - EXPECT_EQ(sketch.estimate(), expected.estimate()); -} - -TEST_F(read_hll_files_into_test, empty_dir) -{ - seqan3::test::tmp_directory empty_dir{}; - ASSERT_TRUE(std::filesystem::exists(empty_dir.path())); - ASSERT_TRUE(std::filesystem::is_empty(empty_dir.path())); - - std::vector target{}; - // Will throw in Release, but assert in Debug -#ifdef NDEBUG - EXPECT_THROW(chopper::sketch::read_hll_files_into(empty_dir.path(), test_filenames, target), std::runtime_error); -#else - EXPECT_DEATH(chopper::sketch::read_hll_files_into(empty_dir.path(), test_filenames, target), ""); -#endif -} - -TEST_F(read_hll_files_into_test, file_is_missing) -{ - seqan3::test::tmp_directory tmp_dir{}; - std::filesystem::path const tmp_file{tmp_dir.path() / "other.hll"}; - { - std::ofstream os{tmp_file}; - os << "Doesn't matter I just need to exist\n"; - } - - std::vector target{}; - - EXPECT_THROW(chopper::sketch::read_hll_files_into(tmp_file.parent_path(), test_filenames, target), - std::runtime_error); -} - -TEST_F(read_hll_files_into_test, read_hll_files_into_faulty_file) -{ - seqan3::test::tmp_directory tmp_dir{}; - std::filesystem::path const tmp_file{tmp_dir.path() / "small.hll"}; - { - std::ofstream os{tmp_file}; - os << "I am not what an hll file looks like\n"; - } - - std::vector target{}; - - EXPECT_THROW(chopper::sketch::read_hll_files_into(tmp_file.parent_path(), test_filenames, target), - std::runtime_error); -}