diff --git a/include/valik/split/metadata.hpp b/include/valik/split/metadata.hpp index 00549873..1c56b6fd 100644 --- a/include/valik/split/metadata.hpp +++ b/include/valik/split/metadata.hpp @@ -160,7 +160,7 @@ struct metadata } }; - uint64_t total_len; + uint64_t total_len{0}; size_t seq_count; size_t seg_count; @@ -179,7 +179,6 @@ struct metadata { using traits_type = seqan3::sequence_file_input_default_traits_dna; seqan3::sequence_file_input<traits_type> fin{bin_path[0][0]}; // single input file - total_len = 0; size_t fasta_ind = sequences.size(); for (auto & record : fin) { diff --git a/test/cli/valik_test.cpp b/test/cli/valik_test.cpp index 7db67eb2..07418c64 100644 --- a/test/cli/valik_test.cpp +++ b/test/cli/valik_test.cpp @@ -14,16 +14,17 @@ struct valik_split_clusters : public valik_base {}; TEST_F(valik_split_clusters, split_metagenome_clusters) { + size_t genome_count{8}; { std::ofstream one_per_bin{"single_seq_bin_paths.txt"}; - for (size_t i{0}; i < 8; i++) + for (size_t i{0}; i < genome_count; i++) { std::string file_path = cli_test::data("bin_" + std::to_string(i) + ".fasta"); one_per_bin << file_path << '\n'; } std::ofstream two_per_bin{"multi_seq_bin_paths.txt"}; - for (size_t i{0}; i < 8; i=i+2) + for (size_t i{0}; i < genome_count; i = i + 2) { std::string file_path = cli_test::data("bin_" + std::to_string(i) + ".fasta"); two_per_bin << file_path << '\t'; @@ -42,8 +43,8 @@ TEST_F(valik_split_clusters, split_metagenome_clusters) EXPECT_EQ(result_one_per_bin.err, std::string{}); auto one_per_bin_meta = valik::metadata("single_seq_meta.bin"); - EXPECT_EQ(one_per_bin_meta.seq_count, 16); - EXPECT_EQ(one_per_bin_meta.seg_count, 8); + EXPECT_EQ(one_per_bin_meta.seq_count, genome_count * 2); + EXPECT_EQ(one_per_bin_meta.seg_count, genome_count); cli_test_result const result_two_per_bin = execute_app("valik", "split", "--metagenome", @@ -55,10 +56,11 @@ TEST_F(valik_split_clusters, split_metagenome_clusters) EXPECT_EQ(result_two_per_bin.err, std::string{}); auto two_per_bin_meta = valik::metadata("multi_seq_meta.bin"); - EXPECT_EQ(two_per_bin_meta.seq_count, 16); - EXPECT_EQ(two_per_bin_meta.seg_count, 4); + EXPECT_EQ(two_per_bin_meta.seq_count, genome_count * 2); + EXPECT_EQ(two_per_bin_meta.seg_count, genome_count / 2u); - EXPECT_EQ(one_per_bin_meta.total_len, two_per_bin_meta.total_len) + EXPECT_EQ(one_per_bin_meta.total_len, two_per_bin_meta.total_len); + EXPECT_EQ(one_per_bin_meta.total_len, 8192*2); // hard coded value from test/data/build/cli_test_input.sh } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////