From 6accbea8924fdf414a786b56fab5ec49d0b6c6c9 Mon Sep 17 00:00:00 2001 From: Simon Gene Gottlieb Date: Mon, 16 May 2022 11:15:55 +0200 Subject: [PATCH 1/3] [DOC] clarification how shapes are applied in kmer-hash --- include/seqan3/search/views/kmer_hash.hpp | 3 +++ test/snippet/search/views/kmer_hash.cpp | 9 +++++++++ test/snippet/search/views/kmer_hash.err | 2 ++ 3 files changed, 14 insertions(+) diff --git a/include/seqan3/search/views/kmer_hash.hpp b/include/seqan3/search/views/kmer_hash.hpp index cf20dc0080..f47bcc0648 100644 --- a/include/seqan3/search/views/kmer_hash.hpp +++ b/include/seqan3/search/views/kmer_hash.hpp @@ -774,6 +774,9 @@ namespace seqan3::views * * See the \link views views submodule documentation \endlink for detailed descriptions of the view properties. * + * \attention The Shape is defined is from right to left. The mask 0b1101 applied to ACGT will return + * the sequence AGT. + * * ### Example * * \include test/snippet/search/views/kmer_hash.cpp diff --git a/test/snippet/search/views/kmer_hash.cpp b/test/snippet/search/views/kmer_hash.cpp index cfa7c8369a..d08a795ccb 100644 --- a/test/snippet/search/views/kmer_hash.cpp +++ b/test/snippet/search/views/kmer_hash.cpp @@ -14,4 +14,13 @@ int main() seqan3::debug_stream << (text | seqan3::views::kmer_hash(seqan3::ungapped{3})) << '\n'; // [6,27,44,50,9] seqan3::debug_stream << (text | seqan3::views::kmer_hash(0b101_shape)) << '\n'; // [2,7,8,14,1] + + // Note: the Shape is defined is from right to left. The mask 0b1101 applied to ACGT will give + // the same result as mask 0b111 applied to AGT. + { + auto text1 = "ACGT"_dna4; + auto text2 = "AGT"_dna4; + seqan3::debug_stream << (text1 | seqan3::views::kmer_hash(0b1101_shape)) << '\n'; // [11] + seqan3::debug_stream << (text2 | seqan3::views::kmer_hash(0b111_shape)) << '\n'; // [11] + } } diff --git a/test/snippet/search/views/kmer_hash.err b/test/snippet/search/views/kmer_hash.err index fcde4abd79..d2f3e13684 100644 --- a/test/snippet/search/views/kmer_hash.err +++ b/test/snippet/search/views/kmer_hash.err @@ -1,3 +1,5 @@ [6,27,44,50,9] [6,27,44,50,9] [2,7,8,14,1] +[11] +[11] From 34d4eb6d0520395bdaab77decb58a755e470108f Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Mon, 16 May 2022 11:41:55 +0200 Subject: [PATCH 2/3] Apply suggestions from code review --- include/seqan3/search/views/kmer_hash.hpp | 2 +- test/snippet/search/views/kmer_hash.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/seqan3/search/views/kmer_hash.hpp b/include/seqan3/search/views/kmer_hash.hpp index f47bcc0648..09ae64311b 100644 --- a/include/seqan3/search/views/kmer_hash.hpp +++ b/include/seqan3/search/views/kmer_hash.hpp @@ -774,7 +774,7 @@ namespace seqan3::views * * See the \link views views submodule documentation \endlink for detailed descriptions of the view properties. * - * \attention The Shape is defined is from right to left. The mask 0b1101 applied to ACGT will return + * \attention The Shape is defined from right to left. The mask 0b1101 applied to ACGT will return * the sequence AGT. * * ### Example diff --git a/test/snippet/search/views/kmer_hash.cpp b/test/snippet/search/views/kmer_hash.cpp index d08a795ccb..749d9c742a 100644 --- a/test/snippet/search/views/kmer_hash.cpp +++ b/test/snippet/search/views/kmer_hash.cpp @@ -15,7 +15,7 @@ int main() seqan3::debug_stream << (text | seqan3::views::kmer_hash(0b101_shape)) << '\n'; // [2,7,8,14,1] - // Note: the Shape is defined is from right to left. The mask 0b1101 applied to ACGT will give + // Note: the Shape is defined from right to left. The mask 0b1101 applied to ACGT will yield // the same result as mask 0b111 applied to AGT. { auto text1 = "ACGT"_dna4; From 17b2d0791b525b7946f186c8b250123a60374a44 Mon Sep 17 00:00:00 2001 From: Simon Gene Gottlieb Date: Tue, 17 May 2022 09:36:29 +0200 Subject: [PATCH 3/3] [misc] improved doc and snippet for kmer_hash Update test/snippet/search/views/kmer_hash.cpp Update include/seqan3/search/views/kmer_hash.hpp Co-authored-by: Svenja Mehringer --- include/seqan3/search/views/kmer_hash.hpp | 4 ++-- test/snippet/search/views/kmer_hash.cpp | 13 +++++++------ test/snippet/search/views/kmer_hash.err | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/seqan3/search/views/kmer_hash.hpp b/include/seqan3/search/views/kmer_hash.hpp index 09ae64311b..8fdc63eba7 100644 --- a/include/seqan3/search/views/kmer_hash.hpp +++ b/include/seqan3/search/views/kmer_hash.hpp @@ -774,8 +774,8 @@ namespace seqan3::views * * See the \link views views submodule documentation \endlink for detailed descriptions of the view properties. * - * \attention The Shape is defined from right to left. The mask 0b1101 applied to ACGT will return - * the sequence AGT. + * \attention The Shape is defined from right to left! The mask 0b11111101 applied to "AGAAAATA" is + * interpreted as "A.AAAATA" (and not "AGAAAA.A") and will return the hash value for "AAAAATA". * * ### Example * diff --git a/test/snippet/search/views/kmer_hash.cpp b/test/snippet/search/views/kmer_hash.cpp index 749d9c742a..ff7f36fc0d 100644 --- a/test/snippet/search/views/kmer_hash.cpp +++ b/test/snippet/search/views/kmer_hash.cpp @@ -15,12 +15,13 @@ int main() seqan3::debug_stream << (text | seqan3::views::kmer_hash(0b101_shape)) << '\n'; // [2,7,8,14,1] - // Note: the Shape is defined from right to left. The mask 0b1101 applied to ACGT will yield - // the same result as mask 0b111 applied to AGT. + // Attention: the Shape is defined from right to left! + // The mask 0b11111101 applied to "AGAAAATA" ("A.AAAATA") will yield + // the same hash value as mask 0b1111111 applied to "AAAAATA". { - auto text1 = "ACGT"_dna4; - auto text2 = "AGT"_dna4; - seqan3::debug_stream << (text1 | seqan3::views::kmer_hash(0b1101_shape)) << '\n'; // [11] - seqan3::debug_stream << (text2 | seqan3::views::kmer_hash(0b111_shape)) << '\n'; // [11] + auto text1 = "AGAAAATA"_dna4; + auto text2 = "AAAAATA"_dna4; + seqan3::debug_stream << (text1 | seqan3::views::kmer_hash(0b11111101_shape)) << '\n'; // [12] + seqan3::debug_stream << (text2 | seqan3::views::kmer_hash(0b1111111_shape)) << '\n'; // [12] } } diff --git a/test/snippet/search/views/kmer_hash.err b/test/snippet/search/views/kmer_hash.err index d2f3e13684..18c85e7662 100644 --- a/test/snippet/search/views/kmer_hash.err +++ b/test/snippet/search/views/kmer_hash.err @@ -1,5 +1,5 @@ [6,27,44,50,9] [6,27,44,50,9] [2,7,8,14,1] -[11] -[11] +[12] +[12]