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] Allow to pass pairs to pairwise alignment #1913

Merged
merged 4 commits into from
Jul 1, 2020

Conversation

Irallia
Copy link
Contributor

@Irallia Irallia commented Jun 15, 2020

Resolves #1516

@Irallia Irallia added this to the Sprint 6 milestone Jun 15, 2020
@Irallia Irallia force-pushed the FEATURE/alignment/allow_to_pass_pairs branch from a1d5603 to 1b4f438 Compare June 15, 2020 15:48
@Irallia Irallia requested review from a team and joergi-w and removed request for a team June 15, 2020 15:49
@codecov
Copy link

codecov bot commented Jun 15, 2020

Codecov Report

Merging #1913 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1913   +/-   ##
=======================================
  Coverage   97.77%   97.77%           
=======================================
  Files         258      258           
  Lines        9687     9688    +1     
=======================================
+ Hits         9471     9472    +1     
  Misses        216      216           
Impacted Files Coverage Δ
...clude/seqan3/alignment/pairwise/align_pairwise.hpp 100.00% <100.00%> (ø)

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 d426227...6ba8815. Read the comment docs.

include/seqan3/alignment/pairwise/align_pairwise.hpp Outdated Show resolved Hide resolved
include/seqan3/alignment/pairwise/align_pairwise.hpp Outdated Show resolved Hide resolved
include/seqan3/alignment/pairwise/align_pairwise.hpp Outdated Show resolved Hide resolved
include/seqan3/alignment/pairwise/align_pairwise.hpp Outdated Show resolved Hide resolved
test/unit/alignment/pairwise/align_pairwise_test.cpp Outdated Show resolved Hide resolved
@Irallia Irallia force-pushed the FEATURE/alignment/allow_to_pass_pairs branch 2 times, most recently from a15e248 to bac80f3 Compare June 17, 2020 11:42
@Irallia Irallia requested a review from joergi-w June 17, 2020 11:42
Copy link
Member

@joergi-w joergi-w 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, looks good!

test/unit/alignment/pairwise/align_pairwise_test.cpp Outdated Show resolved Hide resolved
@joergi-w joergi-w requested review from a team and rrahn and removed request for a team June 17, 2020 12:46
@Irallia Irallia force-pushed the FEATURE/alignment/allow_to_pass_pairs branch from bac80f3 to b886649 Compare June 17, 2020 13:13
//!\cond
requires tuple_like<sequence_t> && !detail::align_pairwise_single_input<std::remove_reference_t<sequence_t>>
//!\endcond
constexpr auto align_pairwise(sequence_t && seq, alignment_config_t const & config)
Copy link
Contributor

@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.

Ok, I thought about it, and this is how I'd like to tackle this.
Replace this definition:

SEQAN3_CONCEPT align_pairwise_single_input =

with the following code:

SEQAN3_CONCEPT align_pairwise_single_input =
    sequence_pair<std::remove_reference_t<t>> &&
    std::is_lvalue_reference_v<t> ||
    (std::ranges::viewable_range<std::tuple_element_t<0, std::remove_reference_t<t>>> &&
     std::ranges::viewable_range<std::tuple_element_t<1, std::remove_reference_t<t>>>);

Then replace this line:

requires detail::align_pairwise_single_input<std::remove_reference_t<sequence_t>> &&

with this:

    requires detail::align_pairwise_single_input<sequence_t> &&

And then you can rewrite the body above as:

    using std::get;

    if constexpr (std::is_lvalue_reference_v<sequence_t>)  // Forward tuple elements as references.
        return align_pairwise(std::tie(get<0>(seq), get<1>(seq)), config);

    static_assert(std::tuple_size_v<std::remove_reference_t<sequence_t>> == 2,
                  "Alignment configuration error: Expects exactly two sequences for pairwise alignments.");

    static_assert(std::ranges::viewable_range<std::tuple_element_t<0, std::remove_reference_t<sequence_t>>> &&
                  std::ranges::viewable_range<std::tuple_element_t<1, std::remove_reference_t<sequence_t>>>,
                  "Alignment configuration error: The tuple elements must model std::ranges::viewable_range.");

    return align_pairwise(std::views::single(std::forward<sequence_t>(seq)), config);

Copy link
Contributor

Choose a reason for hiding this comment

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

Then we don't need the this additional interface.

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.

Many thanks for tackling this 👍 . I would approach the thing a little differently, though 😁 .

}

// use make_pair

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

}

// use std::pair

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@@ -58,15 +58,73 @@ auto call_alignment(seq_t && seq, cfg_t && cfg)

TYPED_TEST(align_pairwise_test, single_pair)
{
// use std::tie

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@Irallia Irallia force-pushed the FEATURE/alignment/allow_to_pass_pairs branch from f8edcc8 to b5c98a9 Compare June 23, 2020 14:50
@Irallia Irallia requested a review from rrahn June 24, 2020 08:54
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 good so far. Please rebase onto current master to resolve the merge conflict.

@Irallia Irallia force-pushed the FEATURE/alignment/allow_to_pass_pairs branch from b5c98a9 to 2b8a8c8 Compare July 1, 2020 08:25
smehringer and others added 4 commits July 1, 2020 12:40
Signed-off-by: Lydia Buntrock <lydia.buntrock@fu-berlin.de>
Signed-off-by: Lydia Buntrock <lydia.buntrock@fu-berlin.de>
@Irallia Irallia force-pushed the FEATURE/alignment/allow_to_pass_pairs branch from 2b8a8c8 to 6ba8815 Compare July 1, 2020 10:40
@Irallia Irallia requested a review from rrahn July 1, 2020 12:17
@rrahn rrahn merged commit 8c2d524 into seqan:master Jul 1, 2020
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.

alignment code not working on pairs
4 participants