Skip to content
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

Merged
merged 10 commits into from
Jun 23, 2020

Conversation

rrahn
Copy link
Contributor

@rrahn rrahn commented Jun 4, 2020

Adds banded alignment implementation.

Blocked by #1873

@rrahn rrahn requested a review from marehr June 4, 2020 21:58
@rrahn rrahn force-pushed the alignment/banded_implementation branch from abc9c67 to 2acfcdc Compare June 5, 2020 07:11
Copy link
Member

@marehr marehr left a 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.

@marehr
Copy link
Member

marehr commented Jun 7, 2020

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]
 };
  ^

@rrahn
Copy link
Contributor Author

rrahn commented Jun 8, 2020

This was not so fun to review. Way to many things in one PR.

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?

@rrahn
Copy link
Contributor Author

rrahn commented Jun 8, 2020

header build failed:

I know. I wanted to fix it when I am working on it again.

@rrahn rrahn requested a review from marehr June 8, 2020 15:51
@rrahn rrahn force-pushed the alignment/banded_implementation branch 2 times, most recently from 5eb2f6d to 9ec6399 Compare June 11, 2020 23:07
@rrahn
Copy link
Contributor Author

rrahn commented Jun 11, 2020

@marehr can you give it another round?

Copy link
Member

@marehr marehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marehr can you give it another round?

Of course :)

Only things left :) 🎉

Comment on lines +276 to +284
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>
Copy link
Member

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/range/views/drop.hpp Show resolved Hide resolved
@rrahn rrahn requested a review from marehr June 12, 2020 13:57
Copy link
Member

@marehr marehr left a 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 :)

@marehr marehr requested a review from smehringer June 12, 2020 16:46
@rrahn rrahn force-pushed the alignment/banded_implementation branch 2 times, most recently from e89c177 to 743cb49 Compare June 13, 2020 23:52
@codecov
Copy link

codecov bot commented Jun 14, 2020

Codecov Report

Merging #1874 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
...t/pairwise/detail/pairwise_alignment_algorithm.hpp 100.00% <ø> (ø)
...nment/matrix/detail/score_matrix_single_column.hpp 100.00% <100.00%> (ø)
...qan3/alignment/pairwise/alignment_configurator.hpp 100.00% <100.00%> (ø)
...ise/detail/pairwise_alignment_algorithm_banded.hpp 100.00% <100.00%> (ø)
...nt/pairwise/detail/policy_affine_gap_recursion.hpp 100.00% <100.00%> (ø)
...wise/detail/policy_affine_gap_recursion_banded.hpp 100.00% <100.00%> (ø)
include/seqan3/range/views/drop.hpp 100.00% <100.00%> (ø)
.../seqan3/alignment/pairwise/alignment_algorithm.hpp 98.50% <0.00%> (-1.50%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f799c0...b404eaa. Read the comment docs.

Copy link
Member

@smehringer smehringer left a 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);
Copy link
Member

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?

Copy link
Contributor Author

@rrahn rrahn Jun 19, 2020

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);
Copy link
Member

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.)?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.
Copy link
Member

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?

Copy link
Contributor Author

@rrahn rrahn Jun 19, 2020

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.

//!\}

protected:
/*!\brief Checks whether the band given the sequence sizes is valid.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/*!\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))
Copy link
Member

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)?

Copy link
Contributor Author

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 ;)

Copy link
Member

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 :)

@rrahn rrahn requested a review from smehringer June 19, 2020 15:01
Copy link
Member

@smehringer smehringer left a 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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants