Skip to content

Commit

Permalink
[MISC] Review 1
Browse files Browse the repository at this point in the history
  • Loading branch information
eseiler committed Aug 23, 2019
1 parent 65bc92d commit 0c63c4d
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 46 deletions.
2 changes: 1 addition & 1 deletion doc/tutorial/read_mapper/read_mapper_step2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void map_reads(std::filesystem::path const & query_path,
uint8_t const errors)
//! [map_reads]
{
bi_fm_index<dna5, text_layout::collection> index; // we need to the alphabet and text layout before loading
bi_fm_index<dna5, text_layout::collection> index; // we need the alphabet and text layout before loading
{
std::ifstream is{index_path, std::ios::binary};
cereal::BinaryInputArchive iarchive{is};
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/read_mapper/read_mapper_step3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void map_reads(std::filesystem::path const & query_path,
reference_storage_t & storage,
uint8_t const errors)
{
bi_fm_index<dna5, text_layout::collection> index; // we need to the alphabet and text layout before loading
bi_fm_index<dna5, text_layout::collection> index; // we need the alphabet and text layout before loading
{
std::ifstream is{index_path, std::ios::binary};
cereal::BinaryInputArchive iarchive{is};
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/read_mapper/read_mapper_step4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void map_reads(std::filesystem::path const & query_path,
reference_storage_t & storage,
uint8_t const errors)
{
bi_fm_index<dna5, text_layout::collection> index; // we need to the alphabet and text layout before loading
bi_fm_index<dna5, text_layout::collection> index; // we need the alphabet and text layout before loading
{
std::ifstream is{index_path, std::ios::binary};
cereal::BinaryInputArchive iarchive{is};
Expand Down
4 changes: 2 additions & 2 deletions include/seqan3/search/algorithm/detail/search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ inline auto search_single(index_t const & index, query_t & query, configuration_
}
else
{
using hit_t = std::conditional_t<index_t::is_collection,
using hit_t = std::conditional_t<index_t::text_layout_mode,
std::pair<typename index_t::size_type, typename index_t::size_type>,
typename index_t::size_type>;
std::vector<hit_t> hits;
Expand Down Expand Up @@ -184,7 +184,7 @@ inline auto search_all(index_t const & index, queries_t & queries, configuration
// delegate params: text_position (or cursor). we will withhold all hits of one query anyway to filter
// duplicates. more efficient to call delegate once with one vector instead of calling
// delegate for each hit separately at once.
using text_pos_t = std::conditional_t<index_t::is_collection,
using text_pos_t = std::conditional_t<index_t::text_layout_mode,
std::pair<typename index_t::size_type, typename index_t::size_type>,
typename index_t::size_type>;
using hit_t = std::conditional_t<cfg_t::template exists<search_cfg::output<detail::search_output_index_cursor>>(),
Expand Down
32 changes: 19 additions & 13 deletions include/seqan3/search/fm_index/bi_fm_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace seqan3
* are reserved and may not be used in the text.
*/
template <Semialphabet alphabet_t,
text_layout text_layout_mode,
text_layout text_layout_mode_,
detail::SdslIndex sdsl_index_type_ = default_sdsl_index_type>
class bi_fm_index
{
Expand All @@ -79,17 +79,23 @@ class bi_fm_index
//!\brief The type of the alphabet size of the underlying SDSL index.
using sdsl_sigma_type = typename sdsl_index_type::alphabet_type::sigma_type;

//!\brief The type of the underlying FM index.
using fm_index_type = fm_index<alphabet_t, text_layout_mode, sdsl_index_type>;
//!\brief The type of the underlying FM index for the original text.
using fm_index_type = fm_index<alphabet_t, text_layout_mode_, sdsl_index_type>;

//!\brief The type of the underlying FM index for the reversed text.\if DEV \todo Change sampling behaviour. \endif
using rev_fm_index_type = fm_index<alphabet_t, text_layout_mode_, sdsl_index_type>;
//!\}

//!\brief Underlying FM index for the original text.
fm_index_type fwd_fm;

//!\brief Underlying FM index for the reversed text.
fm_index_type rev_fm;
rev_fm_index_type rev_fm;

public:
//!\brief Indicates whether index is built over a collection.
static constexpr text_layout text_layout_mode = text_layout_mode_;

/*!\name Text types
* \{
*/
Expand All @@ -104,12 +110,12 @@ class bi_fm_index
*/
//!\brief The type of the bidirectional cursor.
using cursor_type = bi_fm_index_cursor<bi_fm_index<alphabet_t, text_layout_mode, sdsl_index_type>>;
//!\brief The type of the unidirectional cursor.
using uni_cursor_type = fm_index_cursor<fm_index_type>;
//!\}
//!\brief The type of the unidirectional cursor on the original text.
using fwd_cursor_type = fm_index_cursor<fm_index_type>;
//!\brief The type of the unidirectional cursor on the reversed text.
using rev_cursor_type = fm_index_cursor<rev_fm_index_type>;

//!\brief Indicates whether index is built over a collection.
static constexpr bool is_collection = text_layout_mode;
//!\}

template <typename fm_index_t>
friend class fm_index_cursor;
Expand Down Expand Up @@ -160,7 +166,7 @@ class bi_fm_index
*/
template <std::ranges::Range text_t>
//!\cond
requires !is_collection
requires !static_cast<bool>(text_layout_mode)
//!\endcond
void construct(text_t && text)
{
Expand All @@ -180,7 +186,7 @@ class bi_fm_index
//!\overload
template <std::ranges::Range text_t>
//!\cond
requires is_collection
requires static_cast<bool>(text_layout_mode)
//!\endcond
void construct(text_t && text)
{
Expand Down Expand Up @@ -294,7 +300,7 @@ class bi_fm_index
*
* No-throw guarantee.
*/
uni_cursor_type fwd_begin() const noexcept
fwd_cursor_type fwd_begin() const noexcept
{
return {fwd_fm};
}
Expand All @@ -313,7 +319,7 @@ class bi_fm_index
*
* No-throw guarantee.
*/
uni_cursor_type rev_begin() const noexcept
rev_cursor_type rev_begin() const noexcept
{
return {rev_fm};
}
Expand Down
18 changes: 9 additions & 9 deletions include/seqan3/search/fm_index/bi_fm_index_cursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ class bi_fm_index_cursor
*/
//!\brief Type for the unidirectional cursor on the original text.
using fwd_cursor = fm_index_cursor<fm_index<typename index_type::char_type,
text_layout{index_type::is_collection},
index_type::text_layout_mode,
typename index_type::sdsl_index_type>>;
//!\brief Type for the unidirectional cursor on the reversed text.
using rev_cursor = fm_index_cursor<fm_index<typename index_type::char_type,
text_layout{index_type::is_collection},
index_type::text_layout_mode,
typename index_type::sdsl_index_type>>;
//!\}

Expand Down Expand Up @@ -250,7 +250,7 @@ class bi_fm_index_cursor
bi_fm_index_cursor(index_t const & _index) noexcept : index(&_index),
fwd_lb(0), fwd_rb(_index.size() - 1),
rev_lb(0), rev_rb(_index.size() - 1),
sigma(_index.fwd_fm.index.sigma - index_t::is_collection),
sigma(_index.fwd_fm.index.sigma - index_t::text_layout_mode),
depth(0)
{}
//\}
Expand Down Expand Up @@ -863,7 +863,7 @@ class bi_fm_index_cursor
template <std::ranges::Range text_t>
auto path_label(text_t && text) const noexcept
//!\cond
requires !index_t::is_collection
requires !static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
static_assert(std::ranges::InputRange<text_t>, "The text must model InputRange.");
Expand All @@ -880,7 +880,7 @@ class bi_fm_index_cursor
template <std::ranges::Range text_t>
auto path_label(text_t && text) const noexcept
//!\cond
requires index_t::is_collection
requires static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
static_assert(std::ranges::InputRange<text_t>, "The text collection must model InputRange.");
Expand Down Expand Up @@ -925,7 +925,7 @@ class bi_fm_index_cursor
*/
std::vector<size_type> locate() const
//!\cond
requires !index_t::is_collection
requires !static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
assert(index != nullptr);
Expand All @@ -941,7 +941,7 @@ class bi_fm_index_cursor
//!\overload
std::vector<std::pair<size_type, size_type>> locate() const
//!\cond
requires index_t::is_collection
requires static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
assert(index != nullptr);
Expand Down Expand Up @@ -972,7 +972,7 @@ class bi_fm_index_cursor
*/
auto lazy_locate() const
//!\cond
requires !index_t::is_collection
requires !static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
assert(index != nullptr);
Expand All @@ -987,7 +987,7 @@ class bi_fm_index_cursor
//!\overload
auto lazy_locate() const
//!\cond
requires index_t::is_collection
requires static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
assert(index != nullptr);
Expand Down
6 changes: 3 additions & 3 deletions include/seqan3/search/fm_index/concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ SEQAN3_CONCEPT FmIndex = std::Semiregular<t> && requires (t index)

// NOTE: circular dependency
// requires FmIndexCursor<typename t::cursor_type>;
requires requires (t index, std::conditional_t<t::is_collection,
requires requires (t index, std::conditional_t<t::text_layout_mode,
std::vector<std::vector<dna4>>,
std::vector<dna4>> const text)
{
Expand Down Expand Up @@ -151,7 +151,7 @@ SEQAN3_CONCEPT FmIndexCursor = std::Semiregular<t> && requires (t cur)
requires requires (typename t::index_type const index) { { t(index) } };

requires requires (t cur, dna4 const c, std::vector<dna4> const seq,
std::conditional_t<t::index_type::is_collection,
std::conditional_t<t::index_type::text_layout_mode,
std::vector<std::vector<dna4>>,
std::vector<dna4>> const text)
{
Expand All @@ -165,7 +165,7 @@ SEQAN3_CONCEPT FmIndexCursor = std::Semiregular<t> && requires (t cur)
{ cur.last_rank() } -> typename t::size_type;
{ cur.query_length() } -> typename t::size_type;
{ cur.count() } -> typename t::size_type;
{ cur.locate() } -> std::conditional_t<t::index_type::is_collection,
{ cur.locate() } -> std::conditional_t<t::index_type::text_layout_mode,
std::vector<std::pair<typename t::size_type, typename t::size_type>>,
std::vector<typename t::size_type>>;
{ cur.lazy_locate() } -> auto;
Expand Down
19 changes: 10 additions & 9 deletions include/seqan3/search/fm_index/fm_index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ enum text_layout : bool

/*!\brief The SeqAn FM Index.
* \implements seqan3::FmIndex
* \tparam is_collection Indicates whether this index works on a text collection or a single text.
* \tparam text_layout_mode Indicates whether this index works on a text collection or a single text.
* See seqan3::text_layout.
* \tparam sdsl_index_type_ The type of the underlying SDSL index, must model seqan3::SdslIndex.
* \details
Expand Down Expand Up @@ -135,7 +135,7 @@ enum text_layout : bool
* \endif
*/
template <Semialphabet alphabet_t,
text_layout text_layout_mode,
text_layout text_layout_mode_,
detail::SdslIndex sdsl_index_type_ = default_sdsl_index_type>
class fm_index
{
Expand Down Expand Up @@ -164,6 +164,9 @@ class fm_index
sdsl::rank_support_sd<1> text_begin_rs;

public:
//!\brief Indicates whether index is built over a collection.
static constexpr text_layout text_layout_mode = text_layout_mode_;

/*!\name Member types
* \{
*/
Expand All @@ -175,8 +178,6 @@ class fm_index
using cursor_type = fm_index_cursor<fm_index<alphabet_t, text_layout_mode, sdsl_index_type>>;
//!\}

//!\brief Indicates whether index is built over a collection.
static constexpr bool is_collection = text_layout_mode;

template <typename bi_fm_index_t>
friend class bi_fm_index_cursor;
Expand Down Expand Up @@ -258,7 +259,7 @@ class fm_index
*/
template <std::ranges::Range text_t>
//!\cond
requires !is_collection
requires !static_cast<bool>(text_layout_mode)
//!\endcond
void construct(text_t && text)
{
Expand Down Expand Up @@ -306,7 +307,7 @@ class fm_index
//!\overload
template <std::ranges::Range text_t>
//!\cond
requires is_collection
requires static_cast<bool>(text_layout_mode)
//!\endcond
void construct(text_t && text)
{
Expand Down Expand Up @@ -500,14 +501,14 @@ class fm_index
std::to_string(alphabet_size<alphabet_t>) + "."};
}

bool tmp = is_collection;
bool tmp = text_layout_mode;
archive(tmp);
if (tmp != is_collection)
if (tmp != text_layout_mode)
{
throw std::logic_error{std::string{"The fm_index was built over a "} +
(tmp ? "text collection" : "single text") +
" but it is being read into a fm_index expecting a " +
(is_collection ? "text collection." : "single text.")};
(text_layout_mode ? "text collection." : "single text.")};
}
}
//!\endcond
Expand Down
14 changes: 7 additions & 7 deletions include/seqan3/search/fm_index/fm_index_cursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class fm_index_cursor

//! \brief Construct from given index.
fm_index_cursor(index_t const & _index) noexcept : index(&_index), node({0, _index.index.size() - 1, 0, 0}),
sigma(_index.index.sigma - index_t::is_collection)
sigma(_index.index.sigma - index_t::text_layout_mode)
{}
//\}

Expand Down Expand Up @@ -443,7 +443,7 @@ class fm_index_cursor
template <std::ranges::Range text_t>
auto path_label(text_t && text) const noexcept
//!\cond
requires !index_t::is_collection
requires !static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
static_assert(std::ranges::InputRange<text_t>, "The text must model InputRange.");
Expand All @@ -460,7 +460,7 @@ class fm_index_cursor
template <std::ranges::Range text_t>
auto path_label(text_t && text) const noexcept
//!\cond
requires index_t::is_collection
requires static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
static_assert(std::ranges::InputRange<text_t>, "The text collection must model InputRange.");
Expand Down Expand Up @@ -505,7 +505,7 @@ class fm_index_cursor
*/
std::vector<size_type> locate() const
//!\cond
requires !index_t::is_collection
requires !static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
assert(index != nullptr);
Expand All @@ -521,7 +521,7 @@ class fm_index_cursor
//!\overload
std::vector<std::pair<size_type, size_type>> locate() const
//!\cond
requires index_t::is_collection
requires static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
assert(index != nullptr);
Expand Down Expand Up @@ -552,7 +552,7 @@ class fm_index_cursor
*/
auto lazy_locate() const
//!\cond
requires !index_t::is_collection
requires !static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
assert(index != nullptr);
Expand All @@ -564,7 +564,7 @@ class fm_index_cursor
//!\overload
auto lazy_locate() const
//!\cond
requires index_t::is_collection
requires static_cast<bool>(index_t::text_layout_mode)
//!\endcond
{
assert(index != nullptr);
Expand Down

0 comments on commit 0c63c4d

Please sign in to comment.