-
Notifications
You must be signed in to change notification settings - Fork 81
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
banded alignment implementation in optimised implementation #1874
Conversation
abc9c67
to
2acfcdc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not so fun to review. Way to many things in one PR.
include/seqan3/alignment/pairwise/detail/policy_affine_gap_recursion.hpp
Outdated
Show resolved
Hide resolved
include/seqan3/alignment/matrix/detail/score_matrix_single_column.hpp
Outdated
Show resolved
Hide resolved
include/seqan3/alignment/pairwise/detail/policy_affine_gap_recursion_banded.hpp
Outdated
Show resolved
Hide resolved
include/seqan3/alignment/pairwise/detail/pairwise_alignment_algorithm_banded.hpp
Outdated
Show resolved
Hide resolved
header build failed: [ 34%] Building CXX object CMakeFiles/seqan3_header_test--seqan3-alignment-pairwise-detail-policy_affine_gap_recursion-2.dir/seqan3_header_test_files/seqan3/alignment/pairwise/detail/policy_affine_gap_recursion-2.cpp.o
In file included from /home/travis/build/seqan/seqan3-build/seqan3_header_test_files/seqan3/alignment/pairwise/detail/policy_affine_gap_recursion_banded-2.cpp:2:0:
/home/travis/build/seqan/seqan3/include/seqan3/alignment/pairwise/detail/policy_affine_gap_recursion_banded.hpp:31:81: error: expected template-name before ‘<’ token
class policy_affine_gap_recursion_banded : protected policy_affine_gap_recursion<alignment_configuration_t>
^
/home/travis/build/seqan/seqan3/include/seqan3/alignment/pairwise/detail/policy_affine_gap_recursion_banded.hpp:31:81: error: expected ‘{’ before ‘<’ token
/home/travis/build/seqan/seqan3/include/seqan3/alignment/pairwise/detail/policy_affine_gap_recursion_banded.hpp:102:2: error: extra ‘;’ [-Werror=pedantic]
};
^ |
Well I fogot to mention that this is rebased on the other PR. But it is marked as dependent. Since you reviewed both, I assume you just skipped the replicated commits? |
I know. I wanted to fix it when I am working on it again. |
include/seqan3/alignment/pairwise/detail/pairwise_alignment_algorithm_banded.hpp
Outdated
Show resolved
Hide resolved
5eb2f6d
to
9ec6399
Compare
@marehr can you give it another round? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include/seqan3/alignment/pairwise/detail/policy_affine_gap_recursion.hpp
Outdated
Show resolved
Hide resolved
include/seqan3/alignment/pairwise/detail/pairwise_alignment_algorithm_banded.hpp
Show resolved
Hide resolved
include/seqan3/alignment/pairwise/detail/pairwise_alignment_algorithm_banded.hpp
Show resolved
Hide resolved
include/seqan3/alignment/pairwise/detail/pairwise_alignment_algorithm_banded.hpp
Outdated
Show resolved
Hide resolved
include/seqan3/alignment/pairwise/detail/pairwise_alignment_algorithm_banded.hpp
Outdated
Show resolved
Hide resolved
include/seqan3/alignment/pairwise/detail/pairwise_alignment_algorithm_banded.hpp
Outdated
Show resolved
Hide resolved
include/seqan3/alignment/pairwise/detail/pairwise_alignment_algorithm_banded.hpp
Show resolved
Hide resolved
template <std::ranges::input_range alignment_column_t, | ||
std::ranges::input_range cell_index_column_t, | ||
semialphabet sequence1_value_t, | ||
std::ranges::input_range sequence2_t> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smehringer These are examples of seqan3::sequence, since you asked me :)
include/seqan3/alignment/pairwise/detail/policy_affine_gap_recursion_banded.hpp
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much :)
e89c177
to
743cb49
Compare
Codecov Report
@@ Coverage Diff @@
## master #1874 +/- ##
==========================================
- Coverage 97.76% 97.76% -0.01%
==========================================
Files 253 255 +2
Lines 9560 9643 +83
==========================================
+ Hits 9346 9427 +81
- Misses 214 216 +2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor things, otherwise LGTM
score_type lowest_viable_score() const noexcept | ||
{ | ||
assert(m_gap_open_score <= 0 && m_gap_extension_score <= 0); | ||
return std::numeric_limits<score_type>::lowest() - (m_gap_open_score + m_gap_extension_score); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a dumb question, but doesn't this only protect against an underflow once? Can it not happen that I try to subtract the gap penalty multiple times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That can only happen if the score would overflow/underflow in general because the score range is too small. But in this case we simply say that there is undefined behaviour. What we can say is, however, what would be the minimal viable score such that we do not underflow when subtracting a value from this. This has two effects: In the banded case I spare one additional case to consider when computing the score of the last cell of the banded column. Later in the local vectorised score I can choose this score as the new 0
, such that I can use as much of the signed score range as possible without using saturated integer arithmetic which is not supported on all vector extensions. Since we use a maximisation objective, we will never propagate the small value to a new cell. Unless of course, the score range is not sufficiently large (see first point).
@@ -214,8 +214,8 @@ class policy_affine_gap_recursion | |||
*/ | |||
score_type lowest_viable_score() const noexcept | |||
{ | |||
assert(m_gap_open_score <= 0 && m_gap_extension_score <= 0); | |||
return std::numeric_limits<score_type>::lowest() - (m_gap_open_score + m_gap_extension_score); | |||
assert(gap_open_score <= 0 && gap_extension_score <= 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the name change in the actual member variable in this commit ([MISC] Remove m_ prefix from affine internal variables.)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, because of some rebasing issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will resolve the commit once I do the final rebase.
{} | ||
//!\} | ||
|
||
/*!\brief Initialises the first cell of a banded column that does not start in the first row of the matrix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it says here ... not start in the first row
but the function is called initialise_band_first_row...
. Maybe a copy and paste error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an error but maybe I rename the function to make it more clear.
include/seqan3/alignment/pairwise/detail/pairwise_alignment_algorithm_banded.hpp
Show resolved
Hide resolved
//!\} | ||
|
||
protected: | ||
/*!\brief Checks whether the band given the sequence sizes is valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/*!\brief Checks whether the band given the sequence sizes is valid. | |
/*!\brief Checks whether the band, given the sequence sizes, is valid. |
|
||
this->track_last_column_cell(*alignment_column_it, *cell_index_column_it); | ||
|
||
for ([[maybe_unused]] auto && unused : sequence2 | views::slice(first_row_index, row_size)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has no performance regression compared to a simple for (size_t i = first_row_index; i < first_row_index + row_size; ++i)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not about performance. It is about beautiful code ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beauty lies in the eye of the beholder :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are merge conflicts..
* Makes the affine gap policy class protected.
b82b352
to
b404eaa
Compare
Adds banded alignment implementation.
Blocked by #1873