Skip to content

[FIX] display layout #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ jobs:
-DCMAKE_CXX_FLAGS="-Werror ${{ matrix.cxx_flags }}"
make -j3 gtest_main

- name: Debug
if: failure()
run: cat /Users/runner/work/chopper/chopper/build/CMakeFiles/CMakeError.log

- name: Build tests
run: |
ccache -z
Expand Down
3 changes: 3 additions & 0 deletions src/util/display_layout/general.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ int execute(config const & cfg)
// How many user bins are stored in the current technical bin? Always 1 for split bins.
size_t const ub_count{chunk.size()};
bool const is_merged{ub_count > 1u};
bool const has_lower_level = hibf_layout.user_bins[chunk[0]].previous_TB_indices.size() != 0;
if (is_merged ^ has_lower_level)
throw std::logic_error{"Invalid Layout: There is a merged bin that only consists of a single user bin."};

for (size_t const ub_index : chunk)
{
Expand Down
44 changes: 44 additions & 0 deletions test/cli/util_display_layout_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,50 @@ TEST_F(cli_test, display_layout_general)
EXPECT_EQ(expected_general_file, actual_file);
}

TEST_F(cli_test, display_layout_general_throw_invalid_layout)
{
std::string const seq1_filename = data("seq1.fa");
std::string const seq2_filename = data("seq2.fa");
std::string const seq3_filename = data("seq3.fa");
std::string const small_filename = data("small.fa");
seqan3::test::tmp_directory tmp_dir{};
std::filesystem::path const layout_filename{tmp_dir.path() / "small.layout"};
std::filesystem::path const general_filename{tmp_dir.path() / "small.layout.general"};

{
std::ofstream fout{layout_filename};
std::string content = get_layout_with_correct_filenames(seq1_filename,
seq2_filename,
seq3_filename,
small_filename,
layout_filename.string());
size_t const last_header_line_start = content.rfind('#');
size_t const last_header_line_end = content.find('\n', last_header_line_start);
ASSERT_GT(content.size(), last_header_line_end);
content.erase(last_header_line_end + 1u);
content += "0\t0\t1\n"
"1\t1;0\t1;64\n"
"2\t2\t1\n"
"3\t3\t2\n";
fout << content;
}

ASSERT_TRUE(std::filesystem::exists(layout_filename));

cli_test_result result = execute_app("display_layout",
"general",
"--input",
layout_filename.c_str(),
"--output",
general_filename.c_str());

ASSERT_NE(result.exit_code, 0) << "PWD: " << result.pwd << "\nCMD: " << result.command;
EXPECT_EQ(result.out, std::string{});
EXPECT_TRUE(result.err.find("Invalid Layout: There is a merged bin that only consists of a single user bin.")
!= std::string::npos)
<< result.err;
}

TEST_F(cli_test, display_layout_general_with_shared_kmers)
{
std::string const seq1_filename = data("seq1.fa");
Expand Down
Loading