diff --git a/include/seqan3/index/all.hpp b/include/seqan3/index/all.hpp index 1ee7cf1a72b..d4dde685ef8 100644 --- a/include/seqan3/index/all.hpp +++ b/include/seqan3/index/all.hpp @@ -1,4 +1,41 @@ +// ============================================================================ +// SeqAn - The Library for Sequence Analysis +// ============================================================================ +// +// Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin +// Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of Knut Reinert or the FU Berlin nor the names of +// its contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +// DAMAGE. +// + +/*!\file + * \author Christopher Pockrandt + * \brief Meta-header for the index module. + */ + #pragma once #include -// #include diff --git a/include/seqan3/index/concept.hpp b/include/seqan3/index/concept.hpp index f76bab898e4..16b39dbf7ad 100644 --- a/include/seqan3/index/concept.hpp +++ b/include/seqan3/index/concept.hpp @@ -2,8 +2,8 @@ // SeqAn - The Library for Sequence Analysis // ============================================================================ // -// Copyright (c) 2006-2017, Knut Reinert & Freie Universitaet Berlin -// Copyright (c) 2016-2017, Knut Reinert & MPI Molekulare Genetik +// Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin +// Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -31,14 +31,17 @@ // DAMAGE. // // ============================================================================ -// Author: Christopher Pockrandt -// ============================================================================ + +/*!\file + * \author Christopher Pockrandt + * \brief Contains the concepts for the seqan3::fm_index and its traits and iterators. + */ #pragma once #include #include -#include +#include #include diff --git a/include/seqan3/index/detail/fm_index_iterator.hpp b/include/seqan3/index/detail/fm_index_iterator.hpp index 5d18773c4d6..73db11a5c75 100644 --- a/include/seqan3/index/detail/fm_index_iterator.hpp +++ b/include/seqan3/index/detail/fm_index_iterator.hpp @@ -31,8 +31,11 @@ // DAMAGE. // // ============================================================================ -// Author: Christopher Pockrandt -// ============================================================================ + +/*!\file + * \author Christopher Pockrandt + * \brief Contains the internal representation of a node of the seqan3::fm_index_iterator. + */ #pragma once @@ -42,16 +45,11 @@ #include - -/*!\file - * \brief TODO - * \author Christopher Pockrandt - */ - namespace seqan3::detail { -template // TODO: suffix_array_concept does not work here. not looked into it yet +// NOTE: index_t requires fm_index_concept. circular dependency +template struct fm_index_iterator_node { using size_type = typename index_t::size_type; diff --git a/include/seqan3/index/fm_index.hpp b/include/seqan3/index/fm_index.hpp index 056b9bc1b13..a38de76091c 100644 --- a/include/seqan3/index/fm_index.hpp +++ b/include/seqan3/index/fm_index.hpp @@ -2,8 +2,8 @@ // SeqAn - The Library for Sequence Analysis // ============================================================================ // -// Copyright (c) 2006-2017, Knut Reinert & Freie Universitaet Berlin -// Copyright (c) 2016-2017, Knut Reinert & MPI Molekulare Genetik +// Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin +// Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -31,10 +31,13 @@ // DAMAGE. // // ============================================================================ -// Author: Christopher Pockrandt -// ============================================================================ -// #include +/*!\file + * \author Christopher Pockrandt + * \brief Contains the unidirectional seqan3::fm_index. + */ + +#include #include #include @@ -65,7 +68,8 @@ struct fm_index_default_traits // TODO: noexcept is still missing -// TODO: check whether input_range_concept is the correct one! depends on open decisions in sdsl (im-construction, writing in-memory data to tmpfs and on the construction algorithms) +// TODO: check whether input_range_concept is the correct one! depends on open decisions in sdsl +// (im-construction, writing in-memory data to tmpfs and on the construction algorithms) /*!\brief The SeqAn FM Index. * \ingroup fm_index diff --git a/include/seqan3/index/fm_index_iterator.hpp b/include/seqan3/index/fm_index_iterator.hpp index d34dfd90bc6..207bf92ac92 100644 --- a/include/seqan3/index/fm_index_iterator.hpp +++ b/include/seqan3/index/fm_index_iterator.hpp @@ -2,8 +2,8 @@ // SeqAn - The Library for Sequence Analysis // ============================================================================ // -// Copyright (c) 2006-2017, Knut Reinert & Freie Universitaet Berlin -// Copyright (c) 2016-2017, Knut Reinert & MPI Molekulare Genetik +// Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin +// Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -31,16 +31,21 @@ // DAMAGE. // // ============================================================================ -// Author: Christopher Pockrandt -// ============================================================================ + +/*!\file + * \author Christopher Pockrandt + * \brief Contains the seqan3::fm_index_iterator used to search in the unidirectional seqan3::fm_index. + */ #pragma once +#include + #include #include #include #include -#include +#include #include @@ -51,7 +56,8 @@ namespace seqan3 { -// TODO: remove mapping by overwriting backward_search. one only has to deal with incomplete alphabets then (maybe add own alphabet type to sdsl?) +// TODO: remove mapping by overwriting backward_search. +// one only has to deal with incomplete alphabets then (maybe add own alphabet type to sdsl?) // TODO: to_rank() + 1 consistent with comp_char, mapping and implicit_sentinel? @@ -109,7 +115,12 @@ class fm_index_iterator { typename index_type::comp_char_type c = 1; // NOTE: start with 0 or 1 depending on implicit_sentintel typename index_type::size_type _lb, _rb; - for (; c < index->m_index.sigma && !sdsl::backward_search(index->m_index, node.lb, node.rb, index->m_index.comp2char[c], _lb, _rb); ++c) {} + while (c < index->m_index.sigma && + !sdsl::backward_search(index->m_index, node.lb, node.rb, index->m_index.comp2char[c], _lb, _rb)) + { + ++c; + } + if (c != index->m_index.sigma) { parent_lb = node.lb; @@ -187,8 +198,11 @@ class fm_index_iterator typename index_type::comp_char_type c = node.last_char + 1; typename index_type::size_type _lb, _rb; - while (c < index->m_index.sigma && !sdsl::backward_search(index->m_index, parent_lb, parent_rb, index->m_index.comp2char[c], _lb, _rb)) + while (c < index->m_index.sigma && + !sdsl::backward_search(index->m_index, parent_lb, parent_rb, index->m_index.comp2char[c], _lb, _rb)) + { ++c; + } if (c != index->m_index.sigma) { diff --git a/test/unit/index/fm_index_iterator_test.cpp b/test/unit/index/fm_index_iterator_test.cpp index 69a3d5853bf..e07cbabb45c 100644 --- a/test/unit/index/fm_index_iterator_test.cpp +++ b/test/unit/index/fm_index_iterator_test.cpp @@ -2,8 +2,8 @@ // SeqAn - The Library for Sequence Analysis // ============================================================================ // -// Copyright (c) 2006-2017, Knut Reinert & Freie Universitaet Berlin -// Copyright (c) 2016-2017, Knut Reinert & MPI Molekulare Genetik +// Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin +// Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -199,7 +199,8 @@ TYPED_TEST(fm_index_iterator_test, incomplete_alphabet) EXPECT_EQ(it, iterator_type(sa)); } - // search a char that does not occur in the text (some rank that is neither the smallest nor the highest smallest occurring in text) + // search a char that does not occur in the text + // (some rank that is neither the smallest nor the highest occurring in text) { text_type text {"ATATAT"_dna4}; index_type sa{text}; diff --git a/test/unit/index/fm_index_test.cpp b/test/unit/index/fm_index_test.cpp index bd78a3404a9..af550ca3c2f 100644 --- a/test/unit/index/fm_index_test.cpp +++ b/test/unit/index/fm_index_test.cpp @@ -2,8 +2,8 @@ // SeqAn - The Library for Sequence Analysis // ============================================================================ // -// Copyright (c) 2006-2017, Knut Reinert & Freie Universitaet Berlin -// Copyright (c) 2016-2017, Knut Reinert & MPI Molekulare Genetik +// Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin +// Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik // All rights reserved. // // Redistribution and use in source and binary forms, with or without