SeqAn3 3.4.0-rc.4
The Modern C++ library for sequence analysis.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
bi_fm_index.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2025 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 =
68 seqan3::contrib::sdsl::csa_wt<sdsl_wt_index_type::wavelet_tree_type, // Wavelet tree type
69 10'000'000, // Sampling rate of the suffix array
70 10'000'000, // Sampling rate of the inverse suffix array
71 seqan3::contrib::sdsl::sa_order_sa_sampling<>, // Text or SA based sampling for SA
72 seqan3::contrib::sdsl::isa_sampling<>, // Text or ISA based sampling for ISA
73 sdsl_wt_index_type::alphabet_type>; // How to represent the alphabet
74
78 using sdsl_char_type = typename sdsl_index_type::alphabet_type::char_type;
79
81 using sdsl_sigma_type = typename sdsl_index_type::alphabet_type::sigma_type;
82
85
87 using rev_fm_index_type = detail::reverse_fm_index<alphabet_t, text_layout_mode_, rev_sdsl_index_type>;
89
91 fm_index_type fwd_fm;
92
94 rev_fm_index_type rev_fm;
95
115 template <std::ranges::range text_t>
116 void construct(text_t && text)
117 {
118 detail::fm_index_validator::validate<alphabet_t, text_layout_mode_>(text);
119
120 fwd_fm = fm_index_type{text};
121 rev_fm = rev_fm_index_type{text};
122 }
123
124public:
127
134 using size_type = typename sdsl_index_type::size_type;
136
144
146
147 template <typename bi_fm_index_t>
148 friend class bi_fm_index_cursor;
149
153 bi_fm_index() = default;
154 bi_fm_index(bi_fm_index const &) = default;
155 bi_fm_index & operator=(bi_fm_index const &) = default;
156 bi_fm_index(bi_fm_index &&) = default;
158 ~bi_fm_index() = default;
159
168 template <std::ranges::range text_t>
170 {
171 construct(std::forward<text_t>(text));
172 }
174
187 {
188 return fwd_fm.size();
189 }
190
203 {
204 return size() == 0;
205 }
206
218 bool operator==(bi_fm_index const & rhs) const noexcept
219 {
220 return std::tie(fwd_fm, rev_fm) == std::tie(rhs.fwd_fm, rhs.rev_fm);
221 }
222
234 bool operator!=(bi_fm_index const & rhs) const noexcept
235 {
236 return !(*this == rhs);
237 }
238
254 {
255 return {*this};
256 }
257
271 {
272 return {fwd_fm};
273 }
274
282 template <cereal_archive archive_t>
284 {
285 archive(fwd_fm);
286 archive(rev_fm);
287 }
289};
290
295template <std::ranges::range text_t>
298
299} // 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:51
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:169
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:270
bool operator==(bi_fm_index const &rhs) const noexcept
Compares two indices.
Definition bi_fm_index.hpp:218
bool operator!=(bi_fm_index const &rhs) const noexcept
Compares two indices.
Definition bi_fm_index.hpp:234
static constexpr text_layout text_layout_mode
Indicates whether index is built over a collection.
Definition bi_fm_index.hpp:126
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:253
typename sdsl_index_type::size_type size_type
Type for representing positions in the indexed text.
Definition bi_fm_index.hpp:134
bool empty() const noexcept
Checks whether the index is empty.
Definition bi_fm_index.hpp:202
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:132
size_type size() const noexcept
Returns the length of the indexed text including sentinel characters.
Definition bi_fm_index.hpp:186
~bi_fm_index()=default
Defaulted.
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
size_type size() const noexcept
Returns the length of the indexed text including sentinel characters.
Definition fm_index.hpp:469
alphabet_t alphabet_type
The type of the underlying character of the indexed text.
Definition fm_index.hpp:384
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:69
sdsl_wt_index_type default_sdsl_index_type
The default FM Index Configuration.
Definition fm_index.hpp:141
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