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

Align config/output configuration #2024

Merged
merged 13 commits into from
Aug 19, 2020

Conversation

rrahn
Copy link
Contributor

@rrahn rrahn commented Aug 12, 2020

fixes seqan/product_backlog#180

Replaces the align_cfg::result with the align_cfg::output.
The align_cfg::result is still needed in order to set the score type which will be fixed by another issue and is not part of this PR. So removing the result option will be done later when the score type is also changed to the new configuration.

@rrahn rrahn requested review from a team and Irallia and removed request for a team August 12, 2020 09:08
@codecov
Copy link

codecov bot commented Aug 12, 2020

Codecov Report

Merging #2024 into release-3.0.2 will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@                Coverage Diff                @@
##           release-3.0.2    #2024      +/-   ##
=================================================
+ Coverage          97.89%   97.91%   +0.02%     
=================================================
  Files                263      263              
  Lines               9879     9887       +8     
=================================================
+ Hits                9671     9681      +10     
+ Misses               208      206       -2     
Impacted Files Coverage Δ
.../seqan3/alignment/pairwise/alignment_algorithm.hpp 100.00% <ø> (+1.49%) ⬆️
...e/seqan3/alignment/pairwise/detail/type_traits.hpp 100.00% <ø> (ø)
...de/seqan3/alignment/pairwise/edit_distance_fwd.hpp 100.00% <ø> (ø)
...qan3/alignment/pairwise/alignment_configurator.hpp 100.00% <100.00%> (ø)
...qan3/alignment/pairwise/edit_distance_unbanded.hpp 99.25% <100.00%> (+<0.01%) ⬆️

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 096c27e...08fcc66. Read the comment docs.

Copy link
Contributor

@Irallia Irallia left a comment

Choose a reason for hiding this comment

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

As far as I can survey it looks very good. Above all, I have a couple of formulation suggestions.

Comment on lines 55 to +56
// NOTE(rrahn): You must update this test if you add a new value to seqan3::align_cfg::id
EXPECT_EQ(static_cast<uint8_t>(seqan3::detail::align_config_id::SIZE), 13);
EXPECT_EQ(static_cast<uint8_t>(seqan3::detail::align_config_id::SIZE), 19);
Copy link
Contributor

Choose a reason for hiding this comment

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

When does this happen? Is this part of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This happens in the first 5 commits. Each output option is a separate commit and updates this value.

@rrahn rrahn requested a review from Irallia August 13, 2020 14:16
Copy link
Contributor

@Irallia Irallia left a comment

Choose a reason for hiding this comment

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

We overlooked an 'options', but I already approve.
Thanks for the PR!

@Irallia Irallia requested review from a team and smehringer and removed request for a team August 14, 2020 09:07
@rrahn
Copy link
Contributor Author

rrahn commented Aug 14, 2020

Great, thanks. @smehringer I will first rebase and then ping you again once the commits are clean again.

@rrahn rrahn force-pushed the align_config/output_configuration branch from 20a9b26 to e8fae4e Compare August 14, 2020 10:51
@rrahn
Copy link
Contributor Author

rrahn commented Aug 14, 2020

@smehringer this is now ready for second review. Thanks a lot.

@rrahn rrahn requested review from smehringer and removed request for smehringer August 14, 2020 10:52
@rrahn rrahn force-pushed the align_config/output_configuration branch from e8fae4e to b2bee49 Compare August 17, 2020 08:18
@rrahn
Copy link
Contributor Author

rrahn commented Aug 18, 2020

@smehringer ping pong

/*!\brief Tag representing score output for the alignment algorithms.
* \ingroup alignment_configuration
*/
struct output_score_tag : public pipeable_config_element<output_score_tag>
Copy link
Member

Choose a reason for hiding this comment

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

We usually had the tag in seqan3::detail to hide it from the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. In case we have a simple configuration we decided to call the class _tag and the instance of it without the tag suffix. This has nothing to do with detail or non-detail code.

Copy link
Member

Choose a reason for hiding this comment

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

In case we have a simple configuration we decided to call the class _tag and the instance of it without the tag suffix

Yes absolutely

This has nothing to do with detail or non-detail code.

I still think so, at least it is that way in all the other condifurations:
seqan3::detail::method_local_tag for seqan3::align_cfg::method_local
seqan3::detail::vectorised_tag for seqan3::align_cfg::vectorised
seqan3::detail::output_query_id_tag for seqan3::search_cfg::output_query_id
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No 😱 they should not be in detail. Otherwise, how is the user supposed to call get on it. seqan3::get<seqan3::align_cfg::method_local> is not working and if the tag is in detail namespace, then he can't see the user documentation.

Copy link
Member

Choose a reason for hiding this comment

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

Haha well somewhere this went wrong then. I always thought that all the special configuration functionality except the | was rather for us internally anyway. Will you open an issue for this? I guess it should be in the current release then.

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 fix it right away in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha well somewhere this went wrong then.

Yes, by neither reading the user story nor the config design document. 😒

Comment on lines +178 to +186
static constexpr bool has_output_configuration = compute_score ||
compute_end_positions ||
compute_begin_positions ||
compute_sequence_alignment;
Copy link
Member

Choose a reason for hiding this comment

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

Did you leave out align_cfg::output_sequence1_id and align_cfg::output_sequence2_id on purpose?

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 a separate issue that I will work on afterwards.

else
res_vt.begin_positions = this->invalid_coordinate();
}
cached_begin_positions = alignment_begin_positions(this->trace_matrix(), cached_end_positions);
Copy link
Member

Choose a reason for hiding this comment

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

What if if constexpr (compute_end_positions) before evaluated to false and the end positions have not been properly initialised?

Copy link
Contributor Author

@rrahn rrahn Aug 18, 2020

Choose a reason for hiding this comment

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

Then, someone configured the edit distance wrong. This is an internal dependency. I will add a static_assert to make sure that this is safe at compile time.

Edit:

What I mean is that the edit distance algorithm internally has to choose these values. These dependencies are not part of any public interface so it would be an ill-formed program by the developer and not the user. But I added the static assert to make this clear.

Comment on lines 1072 to 1082
{ // Only compute begin and end position if not cached already.
using alignment_t = decltype(res_vt.alignment);
res_vt.alignment = alignment_trace<alignment_t>(database,
query,
this->trace_matrix(),
res_vt.end_positions,
res_vt.begin_positions);
cached_end_positions,
cached_begin_positions);
}
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 understand the comment in this context. Where do you compute the begin and end position "if not cashed already"? It seems you are just using the cashed_[..] variables without checking?

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 an old comment. I'll remove it

seqan3::align_cfg::result{seqan3::with_alignment, seqan3::using_score_type<double>};
seqan3::align_cfg::output_score |
seqan3::align_cfg::output_alignment |
seqan3::align_cfg::result{seqan3::with_score, seqan3::using_score_type<double>};
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

like above

@@ -68,7 +78,10 @@ TEST(alignment_selector, align_result_selector_using_score_type)

auto cfg = seqan3::align_cfg::method_global{} |
seqan3::align_cfg::edit_scheme |
seqan3::align_cfg::result{seqan3::with_end_positions, seqan3::using_score_type<double>};
seqan3::align_cfg::result{seqan3::with_score, seqan3::using_score_type<double>} |
Copy link
Member

Choose a reason for hiding this comment

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

here

Comment on lines 127 to 128
* aligned. For example in the global alignment the begin and end positions are identical to the positions of the
* original sequences since the alignment has to encompass the entire sequences, but in case of a local alignment the
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
* aligned. For example in the global alignment the begin and end positions are identical to the positions of the
* original sequences since the alignment has to encompass the entire sequences, but in case of a local alignment the
* aligned. For example, the begin and end positions of a global alignment encompass the entire sequences,
* but in case of a local alignment the

The sentence before was a little confusing and I think didn't bring in extra information.

Comment on lines 131 to 133
* To obtain the actual alignment the option seqan3::align_cfg::output_alignment has to be specified.
* The options can be combiend with each other in order to customise the alignment and the respective output of the
* alignment.
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
* To obtain the actual alignment the option seqan3::align_cfg::output_alignment has to be specified.
* The options can be combiend with each other in order to customise the alignment and the respective output of the
* alignment.
* To obtain the actual alignment the option seqan3::align_cfg::output_alignment has to be specified.
* The options can be combiend with each other in order to customise the alignment algorithm and the respective output of the

How does the output customise the alignment? It can only customise the alignment algorithm, no?
I think you use "alignment" as in "the deed of aligning", but also for the resulting trace. That's a little confusing.

Comment on lines 138 to 139
* If none of the above configuration was set by the user, then all output options will be enabled by default.
* But be aware that trying to access one of the outputs, if it has not been configured, will raise a static assertion
Copy link
Member

Choose a reason for hiding this comment

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

Hm isn't that intuitive? We compute everything but then wouldn't let people access those information?
Or did I understand this sentence wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe a sentence is missing

@rrahn rrahn force-pushed the align_config/output_configuration branch from 8ea4bdf to 6941831 Compare August 18, 2020 15:07
@rrahn rrahn requested a review from smehringer August 18, 2020 15:14
@rrahn rrahn force-pushed the align_config/output_configuration branch from 6941831 to c170478 Compare August 18, 2020 16:55
/*!\brief Tag representing score output for the alignment algorithms.
* \ingroup alignment_configuration
*/
struct output_score_tag : public pipeable_config_element<output_score_tag>
Copy link
Member

Choose a reason for hiding this comment

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

In case we have a simple configuration we decided to call the class _tag and the instance of it without the tag suffix

Yes absolutely

This has nothing to do with detail or non-detail code.

I still think so, at least it is that way in all the other condifurations:
seqan3::detail::method_local_tag for seqan3::align_cfg::method_local
seqan3::detail::vectorised_tag for seqan3::align_cfg::vectorised
seqan3::detail::output_query_id_tag for seqan3::search_cfg::output_query_id
...

seqan3::configuration cfg = seqan3::align_cfg::method_global{} |
seqan3::align_cfg::edit_scheme |
seqan3::align_cfg::result{seqan3::with_alignment,
seqan3::using_score_type<double>};
seqan3::align_cfg::result{seqan3::with_score, seqan3::using_score_type<double>};
Copy link
Member

Choose a reason for hiding this comment

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

😄 well thats true. You have many TODO comments in this PR though, so I thought you deliberately did this..

With the new align_cfg::output configuration the different features that are computed are not dependent anymore.
However, some computations of the edit distance algorithm are necessary in order to compute a specific feature. For example, when the alignment is requested the edit distance algorithm must also compute the begin and end positions.
This commit separates the edit distance configuration from the user configurations,
i.e. if the user requested an alignment but not the begin/end positions,
the algorithm still executes correctly, while at the end only the alignemnt will be stored.
This changes the alignment traits and result seclector to use the new align_cfg::output option.
It changes the interface of all tests and benchmarks and snippets to use the new configuration option.
@rrahn rrahn force-pushed the align_config/output_configuration branch from 47ee83e to 08fcc66 Compare August 19, 2020 09:38
@smehringer
Copy link
Member

See comment in Gitter before you merge

@rrahn rrahn merged commit fc20e33 into seqan:release-3.0.2 Aug 19, 2020
@rrahn rrahn deleted the align_config/output_configuration branch October 8, 2020 13:19
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.

3 participants