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

[FEATURE] search result struct #1706

Merged
merged 11 commits into from
May 29, 2020

Conversation

smehringer
Copy link
Member

@smehringer smehringer commented Apr 1, 2020

supersedes #1441
blocked by #1799

For the reviewer:
I split the changes into for logical commits because I think it makes it easier to review. Since the commits do not compiler without each other though, I would squash them in the end again.

To commit 1 (Unify cursor.locate() return value): In order to easily adapt the make_result function in the policy_result_builder, it was convenient to change the return value of cursor.locate() and I had in mind that we want to unify them both anyway. I only noticed the tail of tests I needed to adapt after everything was done. I'm sorry that this made the commit unnecessary heavy but we need this anyway.

Fixes #1434
Part of seqan/product_backlog#28

@smehringer smehringer force-pushed the eseiler_search_result branch 4 times, most recently from 3fff532 to c8e891b Compare May 19, 2020 19:50
include/seqan3/search/fm_index/bi_fm_index_cursor.hpp Outdated Show resolved Hide resolved
include/seqan3/search/fm_index/fm_index_cursor.hpp Outdated Show resolved Hide resolved
@@ -15,7 +15,7 @@ int main()
cur.extend_left("AA"_dna4); // search the pattern "AAGG"
seqan3::debug_stream << "Number of hits: " << cur.count() << '\n'; // outputs: 2
seqan3::debug_stream << "Positions in the genome: ";
for (auto const & pos : cur.locate()) // outputs: 8, 22
for (auto const & pos : cur.locate()) // outputs: (0, 8), (0, 22)
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to promote const & or && in such a case?

Copy link
Member Author

Choose a reason for hiding this comment

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

hm.. I'm not sure 🤷‍♀️

Copy link
Contributor

Choose a reason for hiding this comment

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

In general, in a generic context we need to promote auto && since this encapsualtes true type deduction. In non-generic cases const & would be preferred since this is more explicit on what I can do on the type. Later it would be something like std::integral auto && pos. So since this is a generic case, we should promote the auto && version.

Copy link
Contributor

Choose a reason for hiding this comment

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

and in the other places below

include/seqan3/search/search_result.hpp Show resolved Hide resolved
include/seqan3/search/search_result.hpp Outdated Show resolved Hide resolved
test/snippet/search/search.cpp Outdated Show resolved Hide resolved
doc/tutorial/read_mapper/read_mapper_step4.cpp Outdated Show resolved Hide resolved
doc/tutorial/search/index.md Outdated Show resolved Hide resolved
doc/tutorial/search/index.md Outdated Show resolved Hide resolved
doc/tutorial/search/index.md Outdated Show resolved Hide resolved
smehringer and others added 2 commits May 20, 2020 14:14
Co-authored-by: Enrico Seiler <eseiler@users.noreply.github.com>
@smehringer smehringer requested a review from eseiler May 20, 2020 12:24
@smehringer
Copy link
Member Author

note to myself: changelog entry!

@smehringer smehringer requested a review from rrahn May 20, 2020 14:24
doc/tutorial/read_mapper/read_mapper_step2.cpp Outdated Show resolved Hide resolved
doc/tutorial/read_mapper/read_mapper_step2.cpp Outdated Show resolved Hide resolved
doc/tutorial/read_mapper/read_mapper_step3.cpp Outdated Show resolved Hide resolved
doc/tutorial/read_mapper/read_mapper_step4.cpp Outdated Show resolved Hide resolved
doc/tutorial/search/index.md Outdated Show resolved Hide resolved
include/seqan3/search/search_result.hpp Show resolved Hide resolved
@@ -15,7 +15,7 @@ int main()
cur.extend_left("AA"_dna4); // search the pattern "AAGG"
seqan3::debug_stream << "Number of hits: " << cur.count() << '\n'; // outputs: 2
seqan3::debug_stream << "Positions in the genome: ";
for (auto const & pos : cur.locate()) // outputs: 8, 22
for (auto const & pos : cur.locate()) // outputs: (0, 8), (0, 22)
Copy link
Contributor

Choose a reason for hiding this comment

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

In general, in a generic context we need to promote auto && since this encapsualtes true type deduction. In non-generic cases const & would be preferred since this is more explicit on what I can do on the type. Later it would be something like std::integral auto && pos. So since this is a generic case, we should promote the auto && version.

@@ -15,7 +15,7 @@ int main()
cur.extend_left("AA"_dna4); // search the pattern "AAGG"
seqan3::debug_stream << "Number of hits: " << cur.count() << '\n'; // outputs: 2
seqan3::debug_stream << "Positions in the genome: ";
for (auto const & pos : cur.locate()) // outputs: 8, 22
for (auto const & pos : cur.locate()) // outputs: (0, 8), (0, 22)
Copy link
Contributor

Choose a reason for hiding this comment

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

and in the other places below

test/unit/search/search_collection_test.cpp Outdated Show resolved Hide resolved
test/unit/search/search_result_range_test.cpp Outdated Show resolved Hide resolved
@smehringer smehringer requested a review from rrahn May 26, 2020 11:17
@codecov
Copy link

codecov bot commented May 26, 2020

Codecov Report

Merging #1706 into master will increase coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1706      +/-   ##
==========================================
+ Coverage   97.52%   97.63%   +0.11%     
==========================================
  Files         248      249       +1     
  Lines        9439     9477      +38     
==========================================
+ Hits         9205     9253      +48     
+ Misses        234      224      -10     
Impacted Files Coverage Δ
include/seqan3/search/search.hpp 88.63% <ø> (ø)
...ude/seqan3/search/detail/policy_result_builder.hpp 100.00% <100.00%> (ø)
...lude/seqan3/search/fm_index/bi_fm_index_cursor.hpp 100.00% <100.00%> (ø)
include/seqan3/search/fm_index/fm_index_cursor.hpp 100.00% <100.00%> (ø)
include/seqan3/search/search_result.hpp 100.00% <100.00%> (ø)
include/seqan3/search/search_result_range.hpp 100.00% <100.00%> (ø)
include/seqan3/range/views/minimiser.hpp 100.00% <0.00%> (ø)
include/seqan3/core/algorithm/configuration.hpp 100.00% <0.00%> (ø)
...clude/seqan3/alignment/pairwise/align_pairwise.hpp 100.00% <0.00%> (ø)
...lude/seqan3/alignment/pairwise/alignment_range.hpp 100.00% <0.00%> (ø)
... and 13 more

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 f54cb5e...d29c234. Read the comment docs.

Copy link
Contributor

@rrahn rrahn left a comment

Choose a reason for hiding this comment

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

looks in general fine to me. Only some minor questions left

*/
template <typename query_id_type, typename cursor_type, typename reference_id_type, typename reference_begin_pos_type>
class search_result
{
static_assert(std::integral<query_id_type> || std::same_as<query_id_type, detail::empty_type>,
"The query_id_type must either model std::integral or be detail::empty_type.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't this be simply template constraints above? What is the added value of these static asserts. It just writes out what it tests. I don't see this as a justification for making them static assert rather than class constraints?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm pretty sure agreed that we will use static asserts if the requires do not participate in overload resolution but I cannot find it in the core meeting notes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I really don't see any benefit in these static asserts. Once we have support for the types in doxygen we can have a proper documentation. I really think that a static assert helps to identify hard to catch invariants. But I am in srong favour of constraining the primary templates for class templates, function templates and variable templates. Who knows when and who will overload it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it

@@ -60,6 +60,10 @@
* | \ref search_configuration_subsection_hit_strategy "3. Hit" | ✅ | ✅ | ✅ | ❌ | ✅ |
* | \ref seqan3::search_cfg::parallel "4: Parallel" | ✅ | ✅ | ✅ | ✅ | ❌ |
*
* \subsection search_configuration_search_result Search result type
*
* \copydetails seqan3::search_result
Copy link
Contributor

Choose a reason for hiding this comment

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

is this not misplaced here? Should this not be part of the search/all.hpp?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought it will help once the output configuration is also included but I can add it then.

Copy link
Contributor

Choose a reason for hiding this comment

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

Mhmm I see. I just wondering if there was another documentation of the seach module.

Copy link
Member Author

Choose a reason for hiding this comment

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

the search/all.hpp is very sparse and should proably be worked over anyway.

@smehringer smehringer requested a review from rrahn May 28, 2020 12:45
Copy link
Contributor

@rrahn rrahn left a comment

Choose a reason for hiding this comment

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

great work. Thanks a lot.

@rrahn
Copy link
Contributor

rrahn commented May 29, 2020

You can merge after rebaseing the commits.

@smehringer
Copy link
Member Author

smehringer commented May 29, 2020

I will squash merge because the commits were not independent of each other (CI would not run though) and I think we should try to avoid this. Also all the changes would we really hard to include in clean commits.

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.

[Search] search() should always return a range of search_result
4 participants