Skip to content

Commit

Permalink
[MISC] Use method_global free_end gap config in policies.
Browse files Browse the repository at this point in the history
  • Loading branch information
smehringer committed Aug 20, 2020
1 parent c7c101c commit f5a6d1b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ class policy_affine_gap_recursion
gap_open_score = static_cast<score_type>(selected_gap_scheme.get_gap_open_score()) + gap_extension_score;
}

auto align_ends_config = config.get_or(align_cfg::aligned_ends{free_ends_none}).value;
first_row_is_free = align_ends_config[0];
first_column_is_free = align_ends_config[2];
auto method_global_config = config.get_or(align_cfg::method_global{});
first_row_is_free = method_global_config.free_end_gaps_sequence1_leading;
first_column_is_free = method_global_config.free_end_gaps_sequence2_leading;
}
//!\}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,20 @@ class policy_alignment_matrix

bool invalid_band = upper_diagonal < lower_diagonal;
std::string error_cause = (invalid_band) ? " The upper diagonal is smaller than the lower diagonal." : "";
if constexpr (traits_t::with_free_end_gaps)

if constexpr (traits_t::is_global)
{
auto aligned_ends_config = seqan3::get<align_cfg::aligned_ends>(config).value;
bool first_row_is_free = aligned_ends_config[0];
bool first_column_is_free = aligned_ends_config[2];
auto method_global_config = get<seqan3::align_cfg::method_global>(config);

bool first_row_is_free = method_global_config.free_end_gaps_sequence1_leading;
bool first_column_is_free = method_global_config.free_end_gaps_sequence2_leading;

last_row_is_free = aligned_ends_config[1];
last_column_is_free = aligned_ends_config[3];
last_row_is_free = method_global_config.free_end_gaps_sequence1_trailing;
last_column_is_free = method_global_config.free_end_gaps_sequence2_trailing;
// band starts in first column without free gaps or band starts in first row without free gaps.
invalid_band |= (upper_diagonal < 0 && !first_column_is_free) || (lower_diagonal > 0 && !first_row_is_free);
error_cause += " The band starts in a region without free gaps.";
}
else if constexpr (traits_t::is_global)
{
invalid_band |= (upper_diagonal < 0 || lower_diagonal > 0);
error_cause += " The first cell of the matrix is not enclosed by the band.";
}

if (invalid_band)
throw invalid_alignment_configuration{"The selected band [" + std::to_string(lower_diagonal) + ":" +
Expand Down Expand Up @@ -193,18 +190,14 @@ class policy_alignment_matrix

bool invalid_band = false;
std::string error_cause{};
if constexpr (traits_t::with_free_end_gaps)

if constexpr (traits_t::is_global)
{
// band ends in last column without free gaps or band ends in last row without free gaps.
invalid_band |= (lower_diagonal_ends_behind_last_cell && !last_column_is_free) ||
(upper_diagonal_ends_before_last_cell && !last_row_is_free);
error_cause = "The band ends in a region without free gaps.";
}
else if constexpr (traits_t::is_global)
{
invalid_band |= (upper_diagonal_ends_before_last_cell || lower_diagonal_ends_behind_last_cell);
error_cause = "The last cell of the matrix is not enclosed by the band.";
}

if (invalid_band)
throw invalid_alignment_configuration{"The selected band [" + std::to_string(lower_diagonal) + ":" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ class policy_optimum_tracker
*
* \details
*
* Reads the state of seqan3::align_cfg::aligned_ends and enables the tracking of the last row or column if
* Reads the state of seqan3::align_cfg::method_global and enables the tracking of the last row or column if
* requested. Otherwise, only the last cell will be tracked.
*/
policy_optimum_tracker(alignment_configuration_t const & config)
{
auto align_ends_config = config.get_or(align_cfg::aligned_ends{free_ends_none}).value;
test_last_row_cell = align_ends_config[1];
test_last_column_cell = align_ends_config[3];
auto method_global_config = config.get_or(align_cfg::method_global{});
test_last_row_cell = method_global_config.free_end_gaps_sequence1_trailing;
test_last_column_cell = method_global_config.free_end_gaps_sequence2_trailing;
}
//!\}

Expand Down

0 comments on commit f5a6d1b

Please sign in to comment.