Skip to content

Commit

Permalink
[MISC] Also set disable_rearrangement if max_rearrangement_ratio is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Sep 7, 2023
1 parent 93f5e67 commit 99e248d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void config::validate_and_set_defaults()
if (max_rearrangement_ratio < 0.0 || max_rearrangement_ratio > 1.0)
throw std::invalid_argument{"[HIBF CONFIG ERROR] config::max_rearrangement_ratio must be in [0.0,1.0]."};

if (disable_estimate_union)
if (disable_estimate_union || max_rearrangement_ratio == 0.0)
disable_rearrangement = true;
}

Expand Down
17 changes: 17 additions & 0 deletions test/unit/hibf/config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,21 @@ TEST(config_test, validate_and_set_defaults)
EXPECT_TRUE(configuration.disable_rearrangement);
EXPECT_EQ((testing::internal::GetCapturedStderr()), "");
}

// Set disable_rearrangement if max_rearrangement_ratio is 0.0
{
seqan::hibf::config configuration{.input_fn = dummy_input_fn,
.number_of_user_bins = 1u,
.max_rearrangement_ratio = 0.0};
EXPECT_EQ(configuration.max_rearrangement_ratio, 0.0);
EXPECT_FALSE(configuration.disable_estimate_union);
EXPECT_FALSE(configuration.disable_rearrangement);

testing::internal::CaptureStderr();
configuration.validate_and_set_defaults();
EXPECT_EQ(configuration.max_rearrangement_ratio, 0.0);
EXPECT_FALSE(configuration.disable_estimate_union);
EXPECT_TRUE(configuration.disable_rearrangement);
EXPECT_EQ((testing::internal::GetCapturedStderr()), "");
}
}

0 comments on commit 99e248d

Please sign in to comment.