Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
smehringer committed Aug 20, 2024
1 parent 61907ec commit 2917b40
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/chopper/sketch/sketch_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct sketch_file
chopper::configuration chopper_config{};
std::vector<std::vector<std::string>> filenames{};
std::vector<seqan::hibf::sketch::hyperloglog> hll_sketches{};
std::vector<seqan::hibf::sketch::minhashes> minHash_sketches;
std::vector<seqan::hibf::sketch::minhashes> minHash_sketches{};

private:
friend class cereal::access;
Expand Down
1 change: 0 additions & 1 deletion test/api/layout/execute_with_estimation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#include <chopper/configuration.hpp>
#include <chopper/layout/execute.hpp>
#include <chopper/sketch/read_hll_files_into.hpp>

#include <hibf/sketch/compute_sketches.hpp>
#include <hibf/sketch/hyperloglog.hpp>
Expand Down
37 changes: 29 additions & 8 deletions test/cli/cli_output_sketches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@

#include <seqan3/test/tmp_directory.hpp>

#include <chopper/sketch/sketch_file.hpp>

#include "cli_test.hpp"

TEST_F(cli_test, chopper_layout)
{
seqan3::test::tmp_directory tmp_dir{};
std::filesystem::path const input_filename{tmp_dir.path() / "data.filenames"};
std::filesystem::path const layout_filename{tmp_dir.path() / "output.binning"};
std::filesystem::path const sketches_dir{tmp_dir.path() / "sketches"};
std::filesystem::path const sketches_filename{tmp_dir.path() / "out.sketches"};

{
std::ofstream fout{input_filename};
Expand All @@ -29,15 +31,18 @@ TEST_F(cli_test, chopper_layout)
<< data("seq3.fa").string() << '\n';
}

size_t kmer_size{15};
size_t tmax{64};

cli_test_result result = execute_app("chopper",
"--kmer",
"15",
std::to_string(kmer_size).c_str(),
"--input",
input_filename.c_str(),
"--tmax",
"64",
std::to_string(tmax).c_str(),
"--output-sketches-to",
sketches_dir.c_str(),
sketches_filename.c_str(),
"--output",
layout_filename.c_str());

Expand All @@ -48,8 +53,24 @@ TEST_F(cli_test, chopper_layout)
// Layout file should exist. Content is checked in other test.
EXPECT_TRUE(std::filesystem::exists(layout_filename));

EXPECT_TRUE(std::filesystem::exists(sketches_dir)); // directory exists
EXPECT_TRUE(std::filesystem::exists(sketches_dir / "seq1.hll"));
EXPECT_TRUE(std::filesystem::exists(sketches_dir / "seq2.hll"));
EXPECT_TRUE(std::filesystem::exists(sketches_dir / "seq3.hll"));
ASSERT_TRUE(std::filesystem::exists(sketches_filename));

sketch_file sin{};

std::ifstream is{sketches_filename};
cereal::BinaryInputArchive iarchive{is};
iarchive(sin);

EXPECT_EQ(sin.chopper_config.k, kmer_size);
EXPECT_EQ(sin.chopper_config.data_file, input_filename);
EXPECT_EQ(sin.chopper_config.output_filename, layout_filename);
EXPECT_EQ(sin.chopper_config.hibf_config.tmax, tmax);

EXPECT_EQ(sin.filenames.size(), 3);
EXPECT_EQ(sin.hll_sketches.size(), 3);
EXPECT_EQ(sin.minHash_sketches.size(), 0); // currently, no minhash sketches are needed in chopper layout

EXPECT_EQ(sin.filenames[0][0], data("seq1.fa").string());
EXPECT_EQ(sin.filenames[1][0], data("seq2.fa").string());
EXPECT_EQ(sin.filenames[2][0], data("seq3.fa").string());
}

0 comments on commit 2917b40

Please sign in to comment.