forked from seqan/seqan3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MISC] introduce new concepts seqan3::detail::(writable_)pairwise_ali…
…gnment This PR finishes task seqan/product_backlog#60 by implementing seqan3::detail::(writable_)pairwise_alignment.
- Loading branch information
Showing
6 changed files
with
182 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
include/seqan3/alignment/detail/pairwise_alignment_concept.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// ----------------------------------------------------------------------------------------------------- | ||
// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin | ||
// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik | ||
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License | ||
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md | ||
// ----------------------------------------------------------------------------------------------------- | ||
|
||
/*!\file | ||
* \brief Provides seqan3::detail::pairwise_alignment and seqan3::detail::writable_pairwise_alignment. | ||
* \author Marcel Ehrhardt <marcel.ehrhardt AT fu-berlin.de> | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <seqan3/alignment/aligned_sequence/aligned_sequence_concept.hpp> | ||
|
||
namespace seqan3::detail | ||
{ | ||
|
||
/*!\interface seqan3::detail::pairwise_alignment < > | ||
* \extends seqan3::pair_like | ||
* \ingroup alignment | ||
* \brief A concept that models a pairwise alignment type. | ||
* | ||
* \details | ||
* | ||
* A pairwise alignment is a seqan3::pair_like of two seqan3::aligned_sequence's. | ||
*/ | ||
//!\cond | ||
template <typename pairwise_alignment_t> | ||
SEQAN3_CONCEPT pairwise_alignment = | ||
pair_like<pairwise_alignment_t> && | ||
aligned_sequence<std::tuple_element_t<0, std::remove_reference_t<pairwise_alignment_t>>> && | ||
aligned_sequence<std::tuple_element_t<1, std::remove_reference_t<pairwise_alignment_t>>>; | ||
//!\endcond | ||
|
||
/*!\interface seqan3::detail::writable_pairwise_alignment < > | ||
* \extends seqan3::detail::pairwise_alignment | ||
* \ingroup alignment | ||
* \brief A concept that models a writable pairwise alignment type. | ||
* | ||
* \details | ||
* | ||
* A writable pairwise alignment is a seqan3::pair_like of two seqan3::writable_aligned_sequence's. | ||
*/ | ||
//!\cond | ||
template <typename pairwise_alignment_t> | ||
SEQAN3_CONCEPT writable_pairwise_alignment = | ||
pairwise_alignment<pairwise_alignment_t> && | ||
writable_aligned_sequence<std::tuple_element_t<0, std::remove_reference_t<pairwise_alignment_t>>> && | ||
writable_aligned_sequence<std::tuple_element_t<1, std::remove_reference_t<pairwise_alignment_t>>>; | ||
//!\endcond | ||
|
||
} // namespace seqan3::detail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
seqan3_test(pairwise_alignment_concept_test.cpp) |
109 changes: 109 additions & 0 deletions
109
test/unit/alignment/detail/pairwise_alignment_concept_test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// ----------------------------------------------------------------------------------------------------- | ||
// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin | ||
// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik | ||
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License | ||
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md | ||
// ----------------------------------------------------------------------------------------------------- | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <seqan3/alignment/detail/pairwise_alignment_concept.hpp> | ||
#include <seqan3/alphabet/gap/gapped.hpp> | ||
#include <seqan3/alphabet/nucleotide/dna4.hpp> | ||
#include <seqan3/alphabet/nucleotide/dna5.hpp> | ||
|
||
TEST(pairwise_alignment_concept, std_pair_gapped_sequences) | ||
{ | ||
using gapped_sequence1_t = std::vector<seqan3::gapped<seqan3::dna4>>; | ||
using gapped_sequence2_t = std::vector<seqan3::gapped<seqan3::dna4>>; | ||
using alignment_t = std::pair<gapped_sequence1_t, gapped_sequence2_t>; | ||
|
||
EXPECT_FALSE((seqan3::detail::pairwise_alignment<gapped_sequence1_t>)); | ||
EXPECT_FALSE((seqan3::detail::pairwise_alignment<gapped_sequence2_t>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t const>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t &>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t const &>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t &&>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t const &&>)); | ||
} | ||
|
||
TEST(pairwise_alignment_concept, std_tuple_gapped_sequences) | ||
{ | ||
using gapped_sequence1_t = std::vector<seqan3::gapped<seqan3::dna4>> const; | ||
using gapped_sequence2_t = std::vector<seqan3::gapped<seqan3::dna5>>; | ||
using alignment_t = std::tuple<gapped_sequence1_t, gapped_sequence2_t>; | ||
|
||
EXPECT_FALSE((seqan3::detail::pairwise_alignment<gapped_sequence1_t>)); | ||
EXPECT_FALSE((seqan3::detail::pairwise_alignment<gapped_sequence2_t>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t const>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t &>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t const &>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t &&>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t const &&>)); | ||
} | ||
|
||
TEST(pairwise_alignment_concept, std_tuple_gap_sequence) | ||
{ | ||
using gap_sequence1_t = std::vector<seqan3::gap> const; | ||
using gap_sequence2_t = std::vector<seqan3::gap>; | ||
using alignment_t = std::tuple<gap_sequence1_t, gap_sequence2_t>; | ||
|
||
EXPECT_FALSE((seqan3::detail::pairwise_alignment<gap_sequence1_t>)); | ||
EXPECT_FALSE((seqan3::detail::pairwise_alignment<gap_sequence2_t>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t const>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t &>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t const &>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t &&>)); | ||
EXPECT_TRUE((seqan3::detail::pairwise_alignment<alignment_t const &&>)); | ||
} | ||
|
||
TEST(writable_pairwise_alignment_concept, std_pair_gapped_sequences) | ||
{ | ||
using gapped_sequence1_t = std::vector<seqan3::gapped<seqan3::dna4>>; | ||
using gapped_sequence2_t = std::vector<seqan3::gapped<seqan3::dna4>>; | ||
using alignment_t = std::pair<gapped_sequence1_t, gapped_sequence2_t>; | ||
|
||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<gapped_sequence1_t>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<gapped_sequence2_t>)); | ||
EXPECT_TRUE((seqan3::detail::writable_pairwise_alignment<alignment_t>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t const>)); | ||
EXPECT_TRUE((seqan3::detail::writable_pairwise_alignment<alignment_t &>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t const &>)); | ||
EXPECT_TRUE((seqan3::detail::writable_pairwise_alignment<alignment_t &&>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t const &&>)); | ||
} | ||
|
||
TEST(writable_pairwise_alignment_concept, std_tuple_gapped_sequences) | ||
{ | ||
using gapped_sequence1_t = std::vector<seqan3::gapped<seqan3::dna4>>; | ||
using gapped_sequence2_t = std::vector<seqan3::gapped<seqan3::dna5>> const; | ||
using alignment_t = std::tuple<gapped_sequence1_t, gapped_sequence2_t>; | ||
|
||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<gapped_sequence1_t>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<gapped_sequence2_t>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t const>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t &>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t const &>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t &&>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t const &&>)); | ||
} | ||
|
||
TEST(writable_pairwise_alignment_concept, std_tuple_gap_sequence) | ||
{ | ||
using gap_sequence1_t = std::vector<seqan3::gap>; | ||
using gap_sequence2_t = std::vector<seqan3::gap> const; | ||
using alignment_t = std::tuple<gap_sequence1_t, gap_sequence2_t>; | ||
|
||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<gap_sequence1_t>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<gap_sequence2_t>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t const>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t &>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t const &>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t &&>)); | ||
EXPECT_FALSE((seqan3::detail::writable_pairwise_alignment<alignment_t const &&>)); | ||
} |