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

Misc/refactor aligned sequence builder #1237

Merged
merged 6 commits into from
Oct 8, 2019

Conversation

rrahn
Copy link
Contributor

@rrahn rrahn commented Sep 3, 2019

NOTE This PR is for discussing the current situation with the begin_ra/end_ra and the to_random_access view concept.

In General I am not very happy with doing all this additional random access semantics stuff.
Some of my general concerns:

1. The view only wraps the original type and forwards its begin_ra/end_ra members as begin/end. But the type is lost and thus it is not directly usable for using it as the original data structure. But often this is what you want. For example, the gap_decorator fulfills the aligned sequence concept and the bidirectional range concept. You can raise it to random access range as proposed originally but then you loose the aligned sequence concept. However, in case of the gap_decorator you want to be able to use the interface also with the random access iterator (which is also fixed in this PR). Then you can use iterator from a different type as regular iterators to a different interface.
2. I don't see many other places except our decorators where you would model random access even if it might not be constant time access. Thus, we are effectively preventing the efficient use case in the default version (it was fixable in the gap_decorator, but not sure if I can generalize this), which is worse then expecting that access should be constant even if it is not. I think if documented it should be ok to only stick to one begin/end and always give the weak_random_access_iterator in this case. It would be in general less confusing to use (see first point).

The view random access range is moved out into another PR together with some changes related to the gap_decorator. This PR is now rebased on this.

Blocked by #1283

@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch 3 times, most recently from c630f20 to 8457f9f Compare September 3, 2019 21:29
@codecov
Copy link

codecov bot commented Sep 3, 2019

Codecov Report

Merging #1237 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1237      +/-   ##
==========================================
+ Coverage   97.58%   97.61%   +0.02%     
==========================================
  Files         221      222       +1     
  Lines        8975     8999      +24     
==========================================
+ Hits         8758     8784      +26     
+ Misses        217      215       -2
Impacted Files Coverage Δ
.../seqan3/alignment/matrix/detail/trace_iterator.hpp 100% <ø> (ø) ⬆️
.../alignment/matrix/detail/trace_iterator_banded.hpp 100% <100%> (ø) ⬆️
...nclude/seqan3/range/views/pseudo_random_access.hpp 100% <100%> (ø)
...qan3/alignment/matrix/detail/matrix_coordinate.hpp 100% <100%> (ø) ⬆️
...trix/detail/alignment_trace_matrix_full_banded.hpp 100% <100%> (ø) ⬆️
...ignment/matrix/detail/aligned_sequence_builder.hpp 100% <100%> (+4.44%) ⬆️
...ment/aligned_sequence/aligned_sequence_concept.hpp 100% <100%> (ø) ⬆️
...n3/alignment/matrix/detail/trace_iterator_base.hpp 100% <100%> (ø) ⬆️

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 ebd0790...5205342. Read the comment docs.

@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch 2 times, most recently from 9da3eef to a6c4a57 Compare September 10, 2019 15:33
@rrahn rrahn requested a review from smehringer September 10, 2019 15:33
@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from a6c4a57 to c4cfc33 Compare September 10, 2019 16:25
@rrahn rrahn requested review from eseiler and removed request for smehringer September 10, 2019 16:51
@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from c4cfc33 to 69a9e04 Compare September 11, 2019 05:28
include/seqan3/range/views/pseudo_random_access.hpp Outdated Show resolved Hide resolved
include/seqan3/range/views/pseudo_random_access.hpp Outdated Show resolved Hide resolved
include/seqan3/range/views/pseudo_random_access.hpp Outdated Show resolved Hide resolved
include/seqan3/range/views/pseudo_random_access.hpp Outdated Show resolved Hide resolved
include/seqan3/range/views/pseudo_random_access.hpp Outdated Show resolved Hide resolved
include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from 69a9e04 to d3a3dba Compare September 11, 2019 11:00
@rrahn rrahn requested a review from eseiler September 11, 2019 11:00
Copy link
Member

@eseiler eseiler left a comment

Choose a reason for hiding this comment

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

One thing, otherwise LGTM

@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from d3a3dba to 28d784b Compare September 11, 2019 11:14
@rrahn rrahn requested a review from smehringer September 11, 2019 11:14
include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
include/seqan3/range/views/pseudo_random_access.hpp Outdated Show resolved Hide resolved
include/seqan3/range/views/pseudo_random_access.hpp Outdated Show resolved Hide resolved
@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from 28d784b to 0ea2159 Compare September 11, 2019 13:39
@rrahn rrahn requested a review from smehringer September 11, 2019 13:39
@rrahn
Copy link
Contributor Author

rrahn commented Sep 12, 2019

@smehringer ping

@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from 0ea2159 to c999d7d Compare September 12, 2019 19:32
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.

some tiny stuff left

@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from c999d7d to 2beed90 Compare September 17, 2019 10:32
@rrahn rrahn requested a review from smehringer September 17, 2019 10:33
@smehringer
Copy link
Member

I think it also to improve it's usage. I will make this before this PR and rebase it then onto this, so this one is blocked for the time being.

Is this not blocked anymore?

@rrahn
Copy link
Contributor Author

rrahn commented Sep 17, 2019

Is this not blocked anymore?

No it is not anymore. I applied the changes on top of this PR. some thing I messed up. don't wanna talk about it :rage4:

include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
test/snippet/range/views/test_back_inserter_zip.cpp Outdated Show resolved Hide resolved
include/seqan3/core/type_traits/lazy.hpp Outdated Show resolved Hide resolved
test/snippet/core/type_traits/is_instantiable_with.cpp Outdated Show resolved Hide resolved
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.

sorry for revisiting some stuff 🙇‍♂️

include/seqan3/range/views/pseudo_random_access.hpp Outdated Show resolved Hide resolved
include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
include/seqan3/range/decorator/gap_decorator.hpp Outdated Show resolved Hide resolved
@marehr
Copy link
Member

marehr commented Sep 18, 2019

@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch 6 times, most recently from fa70d6f to a3a4ca4 Compare October 2, 2019 13:04
@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from a3a4ca4 to dd089fd Compare October 2, 2019 21:43
@rrahn
Copy link
Contributor Author

rrahn commented Oct 4, 2019

@marehr I have moved the random_access things out of this PR into another PR. So this is now about the changes to the aligned sequence builder only. Everything starting at commit
569bb10 is relevant for this PR. The other changes are from #1283.

@rrahn rrahn requested a review from marehr October 4, 2019 11:41
@marehr
Copy link
Member

marehr commented Oct 4, 2019

Okay, thank you I have a look at it. Just to make sure:

[FEATURE] Add is_instantiable_with unary type trait.

is the first commit that I should look at.

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.

We are getting close :) Thank you for removing that band option, you forgot to remove some left-overs. As always some naming things.

The only thing that is currently concerning to me is the is_instantiable_with, because it does not do what it describes. But that should not be a blocker for this PR.

include/seqan3/core/type_traits/lazy.hpp Show resolved Hide resolved
test/snippet/core/type_traits/is_instantiable_with.cpp Outdated Show resolved Hide resolved
*/
constexpr trace_iterator_banded(matrix_iter_t const matrix_iter) noexcept : base_t{matrix_iter}
template <typename index_t>
constexpr trace_iterator_banded(matrix_iter_t const matrix_iter, column_index_type<index_t> const & pivot_column)
Copy link
Member

Choose a reason for hiding this comment

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

Okay so you now moved the offset into the trace-iterator, but why is the pivot in here? I thought the matrix provides the positions as in a full matrix. So that the trace_iterator is the same for all trace matrices. That's at least what I remembered from the design sketch that we did. I would like to discuss this in person again and review the pictures of the board that we took back then. Maybe my memory is faulty.

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 need to rethink it but mainly because it avoids some additional book keeping.

void fill_aligned_sequence(reverse_traces_t && rev_traces,
fst_aligned_t & fst_aligned,
sec_aligned_t & sec_aligned) const
template <typename reverse_traces_t, typename fst_t, typename sec_t>
Copy link
Member

Choose a reason for hiding this comment

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

why adding here an extra template for fst_t? What difference does it make? I think fst_aligned_t & fst_aligned was completely fine, because you know your passed types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's true

}
}

all_view<fst_rng_t> fst_rng; //!< A view over the first range.
all_view<sec_rng_t> sec_rng; //!< A view over the second range.
std::optional<size_t> band_col_offset; //!< The offset of the column where an optional band starts.
Copy link
Member

Choose a reason for hiding this comment

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

This is now obsolete.

Suggested change
std::optional<size_t> band_col_offset; //!< The offset of the column where an optional band starts.

@@ -12,13 +12,16 @@

#pragma once

#include <optional>
Copy link
Member

Choose a reason for hiding this comment

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

This now obsolete

Suggested change
#include <optional>

//!\brief Deduces the type from the passed constructor arguments.
template <std::ranges::viewable_range fst_rng_t, std::ranges::viewable_range sec_rng_t>
aligned_sequence_builder(fst_rng_t, sec_rng_t, std::optional<static_band>)
-> aligned_sequence_builder<fst_rng_t, sec_rng_t>;
Copy link
Member

Choose a reason for hiding this comment

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

remove me please, thank you!

@@ -95,155 +97,131 @@ TYPED_TEST(aligned_sequence_builder_fixture, construction)
TYPED_TEST(aligned_sequence_builder_fixture, build_from_2_3)
{
auto p = this->path(matrix_offset{row_index_type{2}, column_index_type{3}});
auto [begin, end, alignment] = this->builder(p);
auto [cut_interval_first, cut_interval_second, alignment] = this->builder(p);
Copy link
Member

Choose a reason for hiding this comment

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

Even when seeing the tests, cut_interval does not seem to be the right name.

sequence1_subrange
sequence2_subrange

would be nicer

(Oh I forgot that you can structural bind data members, thank you for reminding me :) )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above subrange would indicate that it is in fact a subrange. But it is not. It is just the interval of the slice/subrange. I also kept the naming with the first/second. At least this matches the pair member notation in the stl.

@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from dd089fd to e9e797f Compare October 7, 2019 16:48
@rrahn rrahn requested a review from marehr October 7, 2019 16:48
rrahn added 4 commits October 7, 2019 19:08
The banded trace iterator should return the actual coordinates within the global alignment matrix and not the coordiantes of the underlying storage. This corresponding mapping is only known by the banded trace matrix.
@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from e9e797f to 9599551 Compare October 7, 2019 17:08
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.

:)

matrix_coordinate begin; //!< The coordinate where the trimmed first and second sequence begin.
matrix_coordinate end; //!< The coordinate where the trimmed first and second sequence end.
std::pair<fst_aligned_t, sec_aligned_t> alignment; //!< The alignment over the trimmed sequences.
std::pair<size_t, size_t> slice_interval_first{}; //!< The slice positions of the first sequence.
Copy link
Member

Choose a reason for hiding this comment

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

:)

@@ -95,155 +97,131 @@ TYPED_TEST(aligned_sequence_builder_fixture, construction)
TYPED_TEST(aligned_sequence_builder_fixture, build_from_2_3)
{
auto p = this->path(matrix_offset{row_index_type{2}, column_index_type{3}});
auto [begin, end, alignment] = this->builder(p);
auto [slice_interval_first, slice_interval_second, alignment] = this->builder(p);
Copy link
Member

Choose a reason for hiding this comment

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

:)

@rrahn rrahn force-pushed the misc/refactor_aligned_sequence_builder branch from 9599551 to 5205342 Compare October 8, 2019 14:22
@rrahn rrahn merged commit f11bd64 into seqan:master Oct 8, 2019
@marehr
Copy link
Member

marehr commented Oct 9, 2019

@rrahn You messed your rebases up and introduced new files that should have been deleted:

test/unit/range/views/view_pseudo_random_access_test.cpp
include/seqan3/range/views/pseudo_random_access.hpp
test/snippet/range/views/pseudo_random_access.cpp

@rrahn rrahn deleted the misc/refactor_aligned_sequence_builder branch October 11, 2019 17:46
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.

4 participants