Skip to content

Commit

Permalink
[TEST] do not allow shared mem metagenome search
Browse files Browse the repository at this point in the history
  • Loading branch information
eaasna committed Oct 6, 2023
1 parent 55caac7 commit fa3e939
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
6 changes: 2 additions & 4 deletions include/valik/search/search_local.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,16 @@ bool search_local(search_arguments const & arguments, search_time_statistics & t
}
}

std::cout << "Launching stellar search on a shared memory machine...\n";
stellar::stellar_runtime input_databases_time{};

auto bin_paths = index.bin_path();
if (bin_paths.size() > 1 || bin_paths[0].size() > 1)
throw std::runtime_error("Multiple reference files can not be searched in shared memory mode. "
"Add --distribute argument to launch multiple distributed instances of DREAM-Stellar search.");

stellar::stellar_runtime input_databases_time{};
bool const databasesSuccess = input_databases_time.measure_time([&]()
{
std::cout << "Launching stellar search on a shared memory machine...\n";
return stellar::_importAllSequences(bin_paths[0].c_str(), "database", databases, databaseIDs, refLen, std::cout, std::cerr);
return stellar::_importAllSequences(bin_paths[0][0].c_str(), "database", databases, databaseIDs, refLen, std::cout, std::cerr);
});
if (!databasesSuccess)
return false;
Expand Down
1 change: 1 addition & 0 deletions test/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ target_use_datasources (valik_options_test FILES bin_2.fasta)
target_use_datasources (valik_options_test FILES bin_3.fasta)
target_use_datasources (valik_options_test FILES query.fq)
target_use_datasources (valik_options_test FILES various_chromosome_lengths.fasta)
target_use_datasources (valik_options_test FILES 150overlap4bins.txt)

add_cli_test (valik_test.cpp)
target_use_datasources (valik_test FILES bin_0.fasta)
Expand Down
26 changes: 26 additions & 0 deletions test/cli/valik_options_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,29 @@ TEST_F(argparse_search, pattern_window)
EXPECT_EQ(result.out, std::string{});
EXPECT_EQ(result.err, std::string{"[Error] The minimiser window cannot be bigger than the pattern.\n"});
}

TEST_F(argparse_search, not_dist_no_meta)
{
cli_test_result const result = execute_app("valik", "search",
"--query ", data("query.fq"),
"--index ", data("8bins19window.ibf"),
"--output search.gff",
"--pattern 100");
EXPECT_NE(result.exit_code, 0);
EXPECT_EQ(result.out, std::string{});
EXPECT_EQ(result.err, std::string{"[Error] Provide --ref-meta to search a single genome or launch a --distribute run to search multiple reference files instead.\n"});
}

TEST_F(argparse_search, shared_mem_metagenome)
{
cli_test_result const result = execute_app("valik", "search",
"--query ", data("query.fq"),
"--index ", data("8bins19window.ibf"),
"--output search.gff",
"--ref-meta ", data("150overlap4bins.txt"),
"--pattern 100");
EXPECT_NE(result.exit_code, 0);
EXPECT_EQ(result.out, std::string{});
EXPECT_EQ(result.err, std::string{"[Error] Multiple reference files can not be searched in shared memory mode. "
"Add --distribute argument to launch multiple distributed instances of DREAM-Stellar search.\n"});
}

0 comments on commit fa3e939

Please sign in to comment.