Skip to content

Commit

Permalink
apply suggestions second review, 1st run
Browse files Browse the repository at this point in the history
  • Loading branch information
wvdtoorn committed Sep 3, 2020
1 parent 4afc90b commit 9bffe4f
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ Note that 3.1.0 will be the first API stable release and interfaces in this rele
The default behaviour when not specifying any output configuration has changed from computing only the score to
computing everything. Please read the linked documentation above carefully to understand all implied changes
([\#2024](https://github.com/seqan/seqan3/pull/2024)).
* The `seqan3::align_cfg::gap` configuration has been replaced by `seqan3::align_cfg::gap_cost_affine`.
* The `seqan3::align_cfg::gap` configuration has been replaced by `seqan3::align_cfg::gap_cost_affine`
([\#2037](https://github.com/seqan/seqan3/pull/2037)).

### Core

Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/pairwise_alignment/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ enumeration class.
\note You can also provide your own scoring scheme implementation if it models seqan3::scoring_scheme.

Similarly to the scoring scheme, you can use the seqan3::align_cfg::gap_cost_affine to set the gap penalties used for
the alignment computation. The default constructed seqan3::align_cfg::gap_cost_affine sets the score for a gap to `-1`
the alignment computation. The default initialised seqan3::align_cfg::gap_cost_affine sets the score for a gap to `-1`
and for a gap opening to `0`. Note that the gap open score is added to the gap score when a gap is opened within the
alignment computation. Therefore setting the gap open score to `0` disables affine gaps.
You can pass a seqan3::align_cfg::extension_score and a seqan3::align_cfg::open_score object to initialise the scheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ int main()

// Configure the alignment kernel.
auto config = seqan3::align_cfg::method_global{} |
seqan3::align_cfg::scoring_scheme{seqan3::aminoacid_scoring_scheme{
seqan3::aminoacid_similarity_matrix::BLOSUM62}} |
seqan3::align_cfg::scoring_scheme{
seqan3::aminoacid_scoring_scheme{seqan3::aminoacid_similarity_matrix::BLOSUM62}} |
seqan3::align_cfg::gap_cost_affine{seqan3::align_cfg::open_score{-9},
seqan3::align_cfg::extension_score{-2}};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ namespace seqan3::align_cfg
* first sequence.
*/
inline constexpr configuration edit_scheme = scoring_scheme{nucleotide_scoring_scheme{}} |
gap_cost_affine{open_score{0}, extension_score{-1}};
gap_cost_affine{open_score{0}, extension_score{-1}};

} // namespace seqan3
7 changes: 3 additions & 4 deletions include/seqan3/alignment/pairwise/alignment_configurator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,16 +323,15 @@ struct alignment_configurator
// ----------------------------------------------------------------------------

// Use default edit distance if gaps are not set.
auto const & gaps =
config_with_result_type.get_or(align_cfg::gap_cost_affine{align_cfg::open_score{0},
align_cfg::extension_score{-1}});
align_cfg::gap_cost_affine edit_gap_cost{};
auto const & gap_cost = config_with_result_type.get_or(edit_gap_cost);
auto const & scoring_scheme = get<align_cfg::scoring_scheme>(cfg).value;
auto align_ends_cfg = config_with_result_type.get_or(align_cfg::aligned_ends{free_ends_none}).value;

if constexpr (config_t::template exists<seqan3::align_cfg::method_global>())
{
// Only use edit distance if ...
if (gaps.open_score.get() == 0 && // gap open score is not set,
if (gap_cost.open_score.get() == 0 && // gap open score is not set,
!(align_ends_cfg[2] || align_ends_cfg[3]) && // none of the free end gaps are set for second seq,
align_ends_cfg[0] == align_ends_cfg[1]) // free ends for leading and trailing gaps are equal in first seq.
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ int main()
// Configuration with affine gap costs. Score for opening a gap during the alignment algorithm will be -11.
seqan3::align_cfg::gap_cost_affine affine_cfg{seqan3::align_cfg::open_score{-1},
seqan3::align_cfg::extension_score{-10}};

// Accessing the members of the gap scheme
int open = affine_cfg.open_score.get(); // open == -1
int extension = affine_cfg.extension_score.get(); // extension == -10
}
4 changes: 2 additions & 2 deletions test/snippet/core/algorithm/configuration_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main()
seqan3::align_cfg::upper_diagonal{4}};
// my_cfg is now of type configuration<gap_cost_affine, band_fixed_size>

seqan3::debug_stream << get<1>(my_cfg).lower_diagonal << '\n'; // prints -4
seqan3::debug_stream << get<seqan3::align_cfg::band_fixed_size>(my_cfg).upper_diagonal << '\n'; // prints 4
seqan3::debug_stream << get<1>(my_cfg).lower_diagonal << '\n'; // prints -4
seqan3::debug_stream << get<seqan3::align_cfg::band_fixed_size>(my_cfg).upper_diagonal << '\n'; // prints 4
seqan3::debug_stream << get<seqan3::align_cfg::gap_cost_affine>(my_cfg).extension_score.get() << '\n'; // prints -1
}
4 changes: 2 additions & 2 deletions test/unit/alignment/configuration/align_config_edit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include <seqan3/alignment/configuration/align_config_edit.hpp>
#include <seqan3/alignment/configuration/align_config_method.hpp>

using seqan3::get;

TEST(align_cfg_edit, is_hamming)
{
auto scheme = seqan3::get<seqan3::align_cfg::scoring_scheme>(seqan3::align_cfg::edit_scheme).value;
Expand All @@ -32,6 +30,8 @@ TEST(align_cfg_edit, is_hamming)

TEST(align_cfg_edit, is_simple_gap)
{
using seqan3::get;

auto gap_cost_scheme = get<seqan3::align_cfg::gap_cost_affine>(seqan3::align_cfg::edit_scheme);
EXPECT_EQ(gap_cost_scheme.extension_score.get(), -1);
EXPECT_EQ(gap_cost_scheme.open_score.get(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
#include <seqan3/core/algorithm/configuration.hpp>
#include <seqan3/std/concepts>

using seqan3::get;

TEST(align_config_gap, config_element_specialisation)
{
EXPECT_TRUE((seqan3::detail::config_element_specialisation<seqan3::align_cfg::gap_cost_affine>));
}

TEST(align_config_gap, configuration)
{
using seqan3::get;
{
seqan3::align_cfg::gap_cost_affine elem{}; // default construction
seqan3::configuration cfg{elem};
Expand Down

0 comments on commit 9bffe4f

Please sign in to comment.