SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
bi_fm_index.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <filesystem>
13#include <ranges>
14#include <utility>
15
19
20namespace seqan3
21{
22
54template <semialphabet alphabet_t,
55 text_layout text_layout_mode_,
56 detail::sdsl_index sdsl_index_type_ = default_sdsl_index_type>
58{
59private:
64 using sdsl_index_type = sdsl_index_type_;
65
67 using rev_sdsl_index_type = sdsl::csa_wt<sdsl_wt_index_type::wavelet_tree_type, // Wavelet tree type
68 10'000'000, // Sampling rate of the suffix array
69 10'000'000, // Sampling rate of the inverse suffix array
70 sdsl::sa_order_sa_sampling<>, // Text or SA based sampling for SA
71 sdsl::isa_sampling<>, // Text or ISA based sampling for ISA
72 sdsl_wt_index_type::alphabet_type>; // How to represent the alphabet
73
77 using sdsl_char_type = typename sdsl_index_type::alphabet_type::char_type;
78
80 using sdsl_sigma_type = typename sdsl_index_type::alphabet_type::sigma_type;
81
84
86 using rev_fm_index_type = detail::reverse_fm_index<alphabet_t, text_layout_mode_, rev_sdsl_index_type>;
88
90 fm_index_type fwd_fm;
91
93 rev_fm_index_type rev_fm;
94
114 template <std::ranges::range text_t>
115 void construct(text_t && text)
116 {
117 detail::fm_index_validator::validate<alphabet_t, text_layout_mode_>(text);
118
119 fwd_fm = fm_index_type{text};
120 rev_fm = rev_fm_index_type{text};
121 }
122
123public:
125 static constexpr text_layout text_layout_mode = text_layout_mode_;
126
133 using size_type = typename sdsl_index_type::size_type;
135
143
145
146 template <typename bi_fm_index_t>
147 friend class bi_fm_index_cursor;
148
152 bi_fm_index() = default;
153 bi_fm_index(bi_fm_index const &) = default;
154 bi_fm_index & operator=(bi_fm_index const &) = default;
155 bi_fm_index(bi_fm_index &&) = default;
157 ~bi_fm_index() = default;
158
167 template <std::ranges::range text_t>
168 bi_fm_index(text_t && text)
169 {
170 construct(std::forward<text_t>(text));
171 }
173
185 size_type size() const noexcept
186 {
187 return fwd_fm.size();
188 }
189
201 bool empty() const noexcept
202 {
203 return size() == 0;
204 }
205
217 bool operator==(bi_fm_index const & rhs) const noexcept
218 {
219 return std::tie(fwd_fm, rev_fm) == std::tie(rhs.fwd_fm, rhs.rev_fm);
220 }
221
233 bool operator!=(bi_fm_index const & rhs) const noexcept
234 {
235 return !(*this == rhs);
236 }
237
252 cursor_type cursor() const noexcept
253 {
254 return {*this};
255 }
256
270 {
271 return {fwd_fm};
272 }
273
281 template <cereal_archive archive_t>
282 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
283 {
284 archive(fwd_fm);
285 archive(rev_fm);
286 }
288};
289
294template <std::ranges::range text_t>
295bi_fm_index(text_t &&) -> bi_fm_index<range_innermost_value_t<text_t>, text_layout{range_dimension_v<text_t> != 1}>;
297
298} // namespace seqan3
Provides the seqan3::bi_fm_index_cursor for searching in the bidirectional seqan3::bi_fm_index.
The SeqAn Bidirectional FM Index Cursor.
Definition bi_fm_index_cursor.hpp:52
The SeqAn Bidirectional FM Index.
Definition bi_fm_index.hpp:58
bi_fm_index(text_t &&text)
Constructor that immediately constructs the index given a range. The range cannot be empty.
Definition bi_fm_index.hpp:168
bi_fm_index(bi_fm_index &&)=default
Defaulted.
bi_fm_index & operator=(bi_fm_index &&)=default
Defaulted.
bi_fm_index()=default
Defaulted.
fwd_cursor_type fwd_cursor() const noexcept
Returns a unidirectional seqan3::fm_index_cursor on the original text of the bidirectional index that...
Definition bi_fm_index.hpp:269
bool operator==(bi_fm_index const &rhs) const noexcept
Compares two indices.
Definition bi_fm_index.hpp:217
bool operator!=(bi_fm_index const &rhs) const noexcept
Compares two indices.
Definition bi_fm_index.hpp:233
static constexpr text_layout text_layout_mode
Indicates whether index is built over a collection.
Definition bi_fm_index.hpp:125
cursor_type cursor() const noexcept
Returns a seqan3::bi_fm_index_cursor on the index that can be used for searching. .
Definition bi_fm_index.hpp:252
typename sdsl_index_type::size_type size_type
Type for representing positions in the indexed text.
Definition bi_fm_index.hpp:133
bool empty() const noexcept
Checks whether the index is empty.
Definition bi_fm_index.hpp:201
bi_fm_index & operator=(bi_fm_index const &)=default
Defaulted.
bi_fm_index(bi_fm_index const &)=default
Defaulted.
typename fm_index_type::alphabet_type alphabet_type
The type of the underlying character of the indexed text.
Definition bi_fm_index.hpp:131
size_type size() const noexcept
Returns the length of the indexed text including sentinel characters.
Definition bi_fm_index.hpp:185
~bi_fm_index()=default
Defaulted.
The SeqAn FM Index Cursor.
Definition fm_index_cursor.hpp:84
size_type size() const noexcept
Returns the length of the indexed text including sentinel characters.
Definition fm_index.hpp:470
alphabet_t alphabet_type
The type of the underlying character of the indexed text.
Definition fm_index.hpp:385
Provides various transformation traits used by the range module.
Provides the unidirectional seqan3::fm_index.
text_layout
The possible text layouts (single, collection) the seqan3::fm_index and seqan3::bi_fm_index can suppo...
Definition search/fm_index/concept.hpp:88
sdsl_wt_index_type default_sdsl_index_type
The default FM Index Configuration.
Definition fm_index.hpp:142
The basis for seqan3::alphabet, but requires only rank interface (not char).
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
T tie(T... args)
Hide me