SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
bi_fm_index_cursor.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 <array>
13#include <ranges>
14
15#include <sdsl/suffix_trees.hpp>
16
24
25namespace seqan3
26{
27
50template <typename index_t>
52{
53public:
55 using index_type = index_t;
56
61 using size_type = typename index_type::size_type;
63
68 using fwd_cursor = fm_index_cursor<fm_index<typename index_type::alphabet_type,
69 index_type::text_layout_mode,
70 typename index_type::sdsl_index_type>>;
72
73private:
75 using sdsl_char_type = typename index_type::sdsl_char_type;
77 using sdsl_index_type = typename index_t::sdsl_index_type;
79 using sdsl_sigma_type = typename index_type::sdsl_sigma_type;
81 using index_alphabet_type = typename index_t::alphabet_type;
86
88 index_type const * index{nullptr};
89
94 size_type fwd_lb{};
96 size_type fwd_rb{};
98 size_type rev_lb{};
100 size_type rev_rb{};
101 //\}
102
104 sdsl_sigma_type sigma{};
105
112 // parent_* and _last_char only have to be stored for the (unidirectional) cursor that has been used last for
113 // extend_right() or cycle_back() resp. extend_left() or cycle_front(), (i.e. either fwd or rev). Thus there is no
114 // need to store it twice. Once the cursor is switched, the information becomes invalid anyway.
115
117 size_type parent_lb{};
119 size_type parent_rb{};
121 sdsl_char_type _last_char{};
122 //\}
123
125 size_type depth{}; // equal for both cursors. only stored once
126
127 // supports assertions to check whether cycle_back() resp. cycle_front() is called on the same direction as the last
128 // extend_right([...]) resp. extend_left([...])
129#ifndef NDEBUG
131 // cycle_back() and cycle_front()
132 bool fwd_cursor_last_used = false;
133#endif
134
136 size_type offset() const noexcept
137 {
138 assert(index->size() > query_length());
139 return index->size() - query_length() - 1; // since the string is reversed during construction
140 }
141
143 template <typename csa_t>
144 requires (std::same_as<csa_t, typename index_type::sdsl_index_type>
145 || std::same_as<csa_t, typename index_type::rev_sdsl_index_type>) bool
146 bidirectional_search(csa_t const & csa,
147 sdsl_char_type const c,
148 size_type & l_fwd,
149 size_type & r_fwd,
150 size_type & l_bwd,
151 size_type & r_bwd) const noexcept
152 {
153 assert((l_fwd <= r_fwd) && (r_fwd < csa.size()));
154 assert(r_fwd + 1 >= l_fwd);
155 assert(r_bwd + 1 - l_bwd == r_fwd + 1 - l_fwd);
156
157 size_type _l_fwd, _r_fwd, _l_bwd, _r_bwd;
158
159 size_type cc = c;
160 if constexpr (!std::same_as<index_alphabet_type, sdsl::plain_byte_alphabet>)
161 {
162 cc = csa.char2comp[c];
163 if (cc == 0 && c > 0) // [[unlikely]]
164 return false;
165 }
166
167 size_type const c_begin = csa.C[cc];
168 if (r_fwd + 1 - l_fwd == csa.size()) // [[unlikely]]
169 {
170 _l_fwd = c_begin;
171 _l_bwd = c_begin;
172 _r_fwd = csa.C[cc + 1] - 1;
173 _r_bwd = _r_fwd;
174 // if we use not the plain_byte_alphabet, we could return always return true here
175 }
176 else
177 {
178 auto const r_s_b = csa.wavelet_tree.lex_count(l_fwd, r_fwd + 1, c);
179 size_type const rank_l = std::get<0>(r_s_b);
180 size_type const s = std::get<1>(r_s_b), b = std::get<2>(r_s_b);
181 size_type const rank_r = r_fwd - l_fwd - s - b + rank_l;
182 _l_fwd = c_begin + rank_l;
183 _r_fwd = c_begin + rank_r;
184 _l_bwd = l_bwd + s;
185 _r_bwd = r_bwd - b;
186 }
187
188 if (_r_fwd >= _l_fwd)
189 {
190 l_fwd = _l_fwd;
191 r_fwd = _r_fwd;
192 l_bwd = _l_bwd;
193 r_bwd = _r_bwd;
194 assert(r_fwd + 1 >= l_fwd);
195 assert(r_bwd + 1 - l_bwd == r_fwd + 1 - l_fwd);
196 return true;
197 }
198 return false;
199 }
200
202 template <typename csa_t>
203 requires (std::same_as<csa_t, typename index_type::sdsl_index_type>
204 || std::same_as<csa_t, typename index_type::rev_sdsl_index_type>) bool
205 bidirectional_search_cycle(csa_t const & csa,
206 sdsl_char_type const c,
207 size_type const l_parent,
208 size_type const r_parent,
209 size_type & l_fwd,
210 size_type & r_fwd,
211 size_type & l_bwd,
212 size_type & r_bwd) const noexcept
213 {
214 assert((l_parent <= r_parent) && (r_parent < csa.size()));
215
216 size_type c_begin;
217 if constexpr (std::same_as<index_alphabet_type, sdsl::plain_byte_alphabet>)
218 c_begin = csa.C[c]; // TODO: check whether this can be removed
219 else
220 c_begin = csa.C[csa.char2comp[c]];
221
222 auto const r_s_b = csa.wavelet_tree.lex_count(l_parent, r_parent + 1, c);
223 size_type const s = std::get<1>(r_s_b), b = std::get<2>(r_s_b), rank_l = std::get<0>(r_s_b),
224 rank_r = r_parent - l_parent - s - b + rank_l;
225
226 size_type const _l_fwd = c_begin + rank_l;
227 size_type const _r_fwd = c_begin + rank_r;
228 size_type const _l_bwd = r_bwd + 1;
229 size_type const _r_bwd = r_bwd + 1 + rank_r - rank_l;
230
231 if (_r_fwd >= _l_fwd)
232 {
233 l_fwd = _l_fwd;
234 r_fwd = _r_fwd;
235 l_bwd = _l_bwd;
236 r_bwd = _r_bwd;
237 assert(r_fwd + 1 >= l_fwd);
238 assert(r_bwd + 1 - l_bwd == r_fwd + 1 - l_fwd);
239 return true;
240 }
241 return false;
242 }
243
244public:
249 // Default construction is necessary to make this class semi-regular and e.g., to allow construction of
250 // std::array of cursors.
251 bi_fm_index_cursor() noexcept = default;
252 bi_fm_index_cursor(bi_fm_index_cursor const &) noexcept = default;
253 bi_fm_index_cursor & operator=(bi_fm_index_cursor const &) noexcept = default;
254 bi_fm_index_cursor(bi_fm_index_cursor &&) noexcept = default;
255 bi_fm_index_cursor & operator=(bi_fm_index_cursor &&) noexcept = default;
256 ~bi_fm_index_cursor() = default;
257
259 bi_fm_index_cursor(index_t const & _index) noexcept :
260 index(&_index),
261 fwd_lb(0),
262 fwd_rb(_index.size() - 1),
263 rev_lb(0),
264 rev_rb(_index.size() - 1),
265 sigma(_index.fwd_fm.index.sigma - index_t::text_layout_mode),
266 depth(0)
267 {}
268 //\}
269
282 bool operator==(bi_fm_index_cursor const & rhs) const noexcept
283 {
284 assert(index != nullptr);
285 // equal SA interval implies equal parent node information (or both are root nodes)
286 assert(!(fwd_lb == rhs.fwd_lb && fwd_rb == rhs.fwd_rb && depth == rhs.depth) || (depth == 0)
287 || (parent_lb == rhs.parent_lb && parent_rb == rhs.parent_rb && _last_char == rhs._last_char));
288
289 return std::tie(fwd_lb, fwd_rb, depth) == std::tie(rhs.fwd_lb, rhs.fwd_rb, rhs.depth);
290 }
291
304 bool operator!=(bi_fm_index_cursor const & rhs) const noexcept
305 {
306 assert(index != nullptr);
307
308 return !(*this == rhs);
309 }
310
328 bool extend_right() noexcept
329 {
330#ifndef NDEBUG
331 fwd_cursor_last_used = true;
332#endif
333
334 assert(index != nullptr);
335
336 size_type new_parent_lb = fwd_lb, new_parent_rb = fwd_rb;
337
338 sdsl_char_type c = 1; // NOTE: start with 0 or 1 depending on implicit_sentintel
339 while (c < sigma
340 && !bidirectional_search(index->fwd_fm.index,
341 index->fwd_fm.index.comp2char[c],
342 fwd_lb,
343 fwd_rb,
344 rev_lb,
345 rev_rb))
346 {
347 ++c;
348 }
349
350 if (c != sigma)
351 {
352 parent_lb = new_parent_lb;
353 parent_rb = new_parent_rb;
354
355 _last_char = c;
356 ++depth;
357
358 return true;
359 }
360 return false;
361 }
362
380 bool extend_left() noexcept
381 {
382#ifndef NDEBUG
383 fwd_cursor_last_used = false;
384#endif
385
386 assert(index != nullptr);
387
388 size_type new_parent_lb = rev_lb, new_parent_rb = rev_rb;
389
390 sdsl_char_type c = 1; // NOTE: start with 0 or 1 depending on implicit_sentintel
391 while (c < sigma
392 && !bidirectional_search(index->rev_fm.index,
393 index->rev_fm.index.comp2char[c],
394 rev_lb,
395 rev_rb,
396 fwd_lb,
397 fwd_rb))
398 {
399 ++c;
400 }
401
402 if (c != sigma)
403 {
404 parent_lb = new_parent_lb;
405 parent_rb = new_parent_rb;
406
407 _last_char = c;
408 ++depth;
409
410 return true;
411 }
412 return false;
413 }
414
428 template <typename char_t>
429 requires std::convertible_to<char_t, index_alphabet_type> bool
430 extend_right(char_t const c) noexcept
431 {
432#ifndef NDEBUG
433 fwd_cursor_last_used = true;
434#endif
435
436 assert(index != nullptr);
437 // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
438 // for the indexed text.
439 assert(seqan3::to_rank(static_cast<index_alphabet_type>(c))
440 < ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
441
442 size_type new_parent_lb = fwd_lb, new_parent_rb = fwd_rb;
443
444 auto c_char = seqan3::to_rank(static_cast<index_alphabet_type>(c)) + 1;
445 if (bidirectional_search(index->fwd_fm.index, c_char, fwd_lb, fwd_rb, rev_lb, rev_rb))
446 {
447 parent_lb = new_parent_lb;
448 parent_rb = new_parent_rb;
449
450 _last_char = c_char;
451 ++depth;
452
453 return true;
454 }
455 return false;
456 }
457
459 template <typename char_type>
460 requires seqan3::detail::is_char_adaptation_v<char_type> bool
461 extend_right(char_type const * cstring) noexcept
462 {
464 }
465
479 template <typename char_t>
480 requires std::convertible_to<char_t, index_alphabet_type> bool
481 extend_left(char_t const c) noexcept
482 {
483#ifndef NDEBUG
484 fwd_cursor_last_used = false;
485#endif
486
487 assert(index != nullptr);
488 // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
489 // for the indexed text.
490 assert(seqan3::to_rank(static_cast<index_alphabet_type>(c))
491 < ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
492
493 size_type new_parent_lb = rev_lb, new_parent_rb = rev_rb;
494
495 auto c_char = seqan3::to_rank(static_cast<index_alphabet_type>(c)) + 1;
496 if (bidirectional_search(index->rev_fm.index, c_char, rev_lb, rev_rb, fwd_lb, fwd_rb))
497 {
498 parent_lb = new_parent_lb;
499 parent_rb = new_parent_rb;
500
501 _last_char = c_char;
502 ++depth;
503
504 return true;
505 }
506 return false;
507 }
508
510 template <typename char_type>
511 requires seqan3::detail::is_char_adaptation_v<char_type> bool
512 extend_left(char_type const * cstring) noexcept
513 {
515 }
516
533 template <std::ranges::range seq_t>
534 bool extend_right(seq_t && seq) noexcept
535 {
536 static_assert(std::ranges::forward_range<seq_t>, "The query must model forward_range.");
537 static_assert(std::convertible_to<range_innermost_value_t<seq_t>, index_alphabet_type>,
538 "The alphabet of the sequence must be convertible to the alphabet of the index.");
539
540 assert(index != nullptr);
541
542 auto first = std::ranges::begin(seq);
543 auto last = std::ranges::end(seq);
544
545#ifndef NDEBUG
546 fwd_cursor_last_used = (first != last); // only if seq was not empty
547#endif
548
549 size_type _fwd_lb = fwd_lb, _fwd_rb = fwd_rb, _rev_lb = rev_lb, _rev_rb = rev_rb;
550 size_type new_parent_lb = parent_lb, new_parent_rb = parent_rb;
551 sdsl_char_type c = _last_char;
552 size_t len{0};
553
554 for (auto it = first; it != last; ++len, ++it)
555 {
556 // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
557 // for the indexed text.
558 assert(seqan3::to_rank(static_cast<index_alphabet_type>(*it))
559 < ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
560
561 c = seqan3::to_rank(static_cast<index_alphabet_type>(*it)) + 1;
562
563 new_parent_lb = _fwd_lb;
564 new_parent_rb = _fwd_rb;
565 if (!bidirectional_search(index->fwd_fm.index, c, _fwd_lb, _fwd_rb, _rev_lb, _rev_rb))
566 return false;
567 }
568
569 fwd_lb = _fwd_lb;
570 fwd_rb = _fwd_rb;
571 rev_lb = _rev_lb;
572 rev_rb = _rev_rb;
573
574 parent_lb = new_parent_lb;
575 parent_rb = new_parent_rb;
576
577 _last_char = c;
578 depth += len;
579
580 return true;
581 }
582
603 template <std::ranges::range seq_t>
604 bool extend_left(seq_t && seq) noexcept
605 {
606 static_assert(std::ranges::bidirectional_range<seq_t>, "The query must model bidirectional_range.");
607 static_assert(std::convertible_to<range_innermost_value_t<seq_t>, index_alphabet_type>,
608 "The alphabet of the sequence must be convertible to the alphabet of the index.");
609 assert(index != nullptr);
610
611 auto rev_seq = std::views::reverse(seq);
612 auto first = std::ranges::begin(rev_seq);
613 auto last = std::ranges::end(rev_seq);
614
615#ifndef NDEBUG
616 if (first != last) // only if seq was not empty
617 fwd_cursor_last_used = false;
618#endif
619
620 size_type _fwd_lb = fwd_lb, _fwd_rb = fwd_rb, _rev_lb = rev_lb, _rev_rb = rev_rb;
621 size_type new_parent_lb = parent_lb, new_parent_rb = parent_rb;
622 sdsl_char_type c = _last_char;
623 size_t len{0};
624
625 for (auto it = first; it != last; ++len, ++it)
626 {
627 // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
628 // for the indexed text.
629 assert(seqan3::to_rank(static_cast<index_alphabet_type>(*it))
630 < ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
631
632 c = seqan3::to_rank(static_cast<index_alphabet_type>(*it)) + 1;
633
634 new_parent_lb = _rev_lb;
635 new_parent_rb = _rev_rb;
636 if (!bidirectional_search(index->rev_fm.index, c, _rev_lb, _rev_rb, _fwd_lb, _fwd_rb))
637 return false;
638 }
639
640 fwd_lb = _fwd_lb;
641 fwd_rb = _fwd_rb;
642 rev_lb = _rev_lb;
643 rev_rb = _rev_rb;
644
645 parent_lb = new_parent_lb;
646 parent_rb = new_parent_rb;
647 _last_char = c;
648 depth += len;
649
650 return true;
651 }
652
679 bool cycle_back() noexcept
680 {
681#ifndef NDEBUG
682 // cycle_back() can only be used if the last extension was to the right.
683 assert(fwd_cursor_last_used);
684#endif
685
686 assert(index != nullptr && query_length() > 0);
687
688 sdsl_char_type c = _last_char + 1;
689
690 while (c < sigma
691 && !bidirectional_search_cycle(index->fwd_fm.index,
692 index->fwd_fm.index.comp2char[c],
693 parent_lb,
694 parent_rb,
695 fwd_lb,
696 fwd_rb,
697 rev_lb,
698 rev_rb))
699 {
700 ++c;
701 }
702
703 if (c != sigma)
704 {
705 _last_char = c;
706
707 return true;
708 }
709 return false;
710 }
711
738 bool cycle_front() noexcept
739 {
740#ifndef NDEBUG
741 // cycle_front() can only be used if the last extension was to the left.
742 assert(!fwd_cursor_last_used);
743#endif
744
745 assert(index != nullptr && query_length() > 0);
746
747 sdsl_char_type c = _last_char + 1;
748 while (c < sigma
749 && !bidirectional_search_cycle(index->rev_fm.index,
750 index->rev_fm.index.comp2char[c],
751 parent_lb,
752 parent_rb,
753 rev_lb,
754 rev_rb,
755 fwd_lb,
756 fwd_rb))
757 {
758 ++c;
759 }
760
761 if (c != sigma)
762 {
763 _last_char = c;
764
765 return true;
766 }
767 return false;
768 }
769
787 {
788 assert(index != nullptr && query_length() > 0);
789
790 return index->fwd_fm.index.comp2char[_last_char] - 1; // text is not allowed to contain ranks of 0
791 }
792
805 size_type query_length() const noexcept
806 {
807 assert(index != nullptr);
808 // depth == 0 -> root node
809 assert(depth != 0 || (fwd_lb == rev_lb && fwd_rb == rev_rb && fwd_lb == 0 && fwd_rb == index->size() - 1));
810
811 return depth;
812 }
813
833 fwd_cursor to_fwd_cursor() const noexcept
834 {
835 assert(index != nullptr);
836
837 fwd_cursor cur{index->fwd_fm};
838 cur.parent_lb = parent_lb;
839 cur.parent_rb = parent_rb;
840 cur.node = {fwd_lb, fwd_rb, depth, _last_char};
841
842#ifndef NDEBUG
843 if (!fwd_cursor_last_used)
844 {
845 // invalidate parent interval
846 cur.parent_lb = 1;
847 cur.parent_rb = 0;
848 }
849#endif
850
851 return cur;
852 }
853
870 template <std::ranges::range text_t>
871 auto path_label(text_t && text) const noexcept
872 requires (index_t::text_layout_mode == text_layout::single)
873 {
874 static_assert(std::ranges::input_range<text_t>, "The text must model input_range.");
875 static_assert(range_dimension_v<text_t> == 1, "The input cannot be a text collection.");
876 static_assert(std::same_as<range_innermost_value_t<text_t>, index_alphabet_type>,
877 "The alphabet types of the given text and index differ.");
878 assert(index != nullptr);
879
880 size_type const query_begin = offset() - index->fwd_fm.index[fwd_lb];
881 return text | views::slice(query_begin, query_begin + query_length());
882 }
883
885 template <std::ranges::range text_t>
886 auto path_label(text_t && text) const noexcept
887 requires (index_t::text_layout_mode == text_layout::collection)
888 {
889 static_assert(std::ranges::input_range<text_t>, "The text collection must model input_range.");
890 static_assert(range_dimension_v<text_t> == 2, "The input must be a text collection.");
891 static_assert(std::same_as<range_innermost_value_t<text_t>, index_alphabet_type>,
892 "The alphabet types of the given text and index differ.");
893 assert(index != nullptr);
894
895 // Position of query in concatenated text.
896 size_type const location = offset() - index->fwd_fm.index[fwd_lb];
897
898 // The rank represents the number of start positions of the individual sequences/texts in the collection
899 // before position `location + 1` and thereby also the number of delimiters.
900 size_type const rank = index->fwd_fm.text_begin_rs.rank(location + 1);
901 assert(rank > 0);
902 size_type const text_id = rank - 1;
903
904 // The start location of the `text_id`-th text in the sequence (position of the `rank`-th 1 in the bitvector).
905 size_type const start_location = index->fwd_fm.text_begin_ss.select(rank);
906 // Substract lengths of previous sequences.
907 size_type const query_begin = location - start_location;
908
909 // Take subtext, slice query out of it
910 return text[text_id] | views::slice(query_begin, query_begin + query_length());
911 }
912
924 size_type count() const noexcept
925 {
926 assert(index != nullptr && (1 + fwd_rb - fwd_lb == 1 + rev_rb - rev_lb));
927
928 return 1 + fwd_rb - fwd_lb;
929 }
930
943 requires (index_t::text_layout_mode == text_layout::single)
944 {
945 assert(index != nullptr);
946
947 locate_result_type occ{};
948 occ.reserve(count());
949 for (size_type i = 0; i < count(); ++i)
950 {
951 occ.emplace_back(0, offset() - index->fwd_fm.index[fwd_lb + i]);
952 }
953 return occ;
954 }
955
958 requires (index_t::text_layout_mode == text_layout::collection)
959 {
960 assert(index != nullptr);
961
963 occ.reserve(count());
964 for (size_type i = 0; i < count(); ++i)
965 {
966 size_type loc = offset() - index->fwd_fm.index[fwd_lb + i];
967 size_type sequence_rank = index->fwd_fm.text_begin_rs.rank(loc + 1);
968 size_type sequence_position = loc - index->fwd_fm.text_begin_ss.select(sequence_rank);
969 occ.emplace_back(sequence_rank - 1, sequence_position);
970 }
971 return occ;
972 }
973
986 auto lazy_locate() const
987 requires (index_t::text_layout_mode == text_layout::single)
988 {
989 assert(index != nullptr);
990
991 return std::views::iota(fwd_lb, fwd_lb + count())
992 | std::views::transform(
993 [*this, _offset = offset()](auto sa_pos)
994 {
995 return locate_result_value_type{0u, _offset - index->fwd_fm.index[sa_pos]};
996 });
997 }
998
1000 auto lazy_locate() const
1001 requires (index_t::text_layout_mode == text_layout::collection)
1002 {
1003 assert(index != nullptr);
1004
1005 return std::views::iota(fwd_lb, fwd_lb + count())
1006 | std::views::transform(
1007 [*this, _offset = offset()](auto sa_pos)
1008 {
1009 auto loc = _offset - index->fwd_fm.index[sa_pos];
1010 size_type sequence_rank = index->fwd_fm.text_begin_rs.rank(loc + 1);
1011 size_type sequence_position = loc - index->fwd_fm.text_begin_ss.select(sequence_rank);
1012 return locate_result_value_type{sequence_rank - 1, sequence_position};
1013 });
1014 }
1015
1023 template <cereal_archive archive_t>
1024 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
1025 {
1026 archive(fwd_lb);
1027 archive(fwd_rb);
1028 archive(rev_lb);
1029 archive(rev_rb);
1030 archive(sigma);
1031 archive(parent_lb);
1032 archive(parent_rb);
1033 archive(_last_char);
1034 archive(depth);
1035 }
1037};
1038
1039} // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
T begin(T... args)
Provides alphabet adaptations for standard char types.
The SeqAn Bidirectional FM Index Cursor.
Definition bi_fm_index_cursor.hpp:52
bool extend_right() noexcept
Tries to extend the query by the smallest possible character to the right such that the query is foun...
Definition bi_fm_index_cursor.hpp:328
size_type count() const noexcept
Counts the number of occurrences of the searched query in the text.
Definition bi_fm_index_cursor.hpp:924
bool extend_left(seq_t &&seq) noexcept
Tries to extend the query by seq to the left.
Definition bi_fm_index_cursor.hpp:604
bool operator==(bi_fm_index_cursor const &rhs) const noexcept
Compares two cursors.
Definition bi_fm_index_cursor.hpp:282
bool extend_left(char_type const *cstring) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition bi_fm_index_cursor.hpp:512
auto path_label(text_t &&text) const noexcept
Returns the searched query.
Definition bi_fm_index_cursor.hpp:871
bool extend_left() noexcept
Tries to extend the query by the smallest possible character to the left such that the query is found...
Definition bi_fm_index_cursor.hpp:380
auto path_label(text_t &&text) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition bi_fm_index_cursor.hpp:886
locate_result_type locate() const
Locates the occurrences of the searched query in the text.
Definition bi_fm_index_cursor.hpp:942
bool cycle_back() noexcept
Tries to replace the rightmost character of the query by the next lexicographically larger character ...
Definition bi_fm_index_cursor.hpp:679
bool cycle_front() noexcept
Tries to replace the leftmost character of the query by the next lexicographically larger character s...
Definition bi_fm_index_cursor.hpp:738
auto lazy_locate() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition bi_fm_index_cursor.hpp:1000
fwd_cursor to_fwd_cursor() const noexcept
Returns a unidirectional seqan3::fm_index_cursor on the original text. path_label() on the returned u...
Definition bi_fm_index_cursor.hpp:833
size_type query_length() const noexcept
Returns the depth of the cursor node in the implicit suffix tree, i.e. the length of the sequence sea...
Definition bi_fm_index_cursor.hpp:805
bool extend_right(char_type const *cstring) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition bi_fm_index_cursor.hpp:461
size_type last_rank() noexcept
Outputs the rightmost respectively leftmost rank depending on whether extend_right() or extend_left()...
Definition bi_fm_index_cursor.hpp:786
index_t index_type
Type of the index.
Definition bi_fm_index_cursor.hpp:55
typename index_type::size_type size_type
Type for representing positions in the indexed text.
Definition bi_fm_index_cursor.hpp:61
bool operator!=(bi_fm_index_cursor const &rhs) const noexcept
Compares two cursors.
Definition bi_fm_index_cursor.hpp:304
std::vector< std::pair< size_type, size_type > > locate() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition bi_fm_index_cursor.hpp:957
bi_fm_index_cursor() noexcept=default
Default constructor. Accessing member functions on a default constructed object is undefined behavior...
auto lazy_locate() const
Locates the occurrences of the searched query in the text on demand, i.e. a std::ranges::view is retu...
Definition bi_fm_index_cursor.hpp:986
bool extend_right(seq_t &&seq) noexcept
Tries to extend the query by seq to the right.
Definition bi_fm_index_cursor.hpp:534
bool extend_right(char_t const c) noexcept
Tries to extend the query by the character c to the right.
Definition bi_fm_index_cursor.hpp:430
bool extend_left(char_t const c) noexcept
Tries to extend the query by the character c to the left.
Definition bi_fm_index_cursor.hpp:481
The SeqAn FM Index Cursor.
Definition fm_index_cursor.hpp:84
The SeqAn FM Index.
Definition fm_index.hpp:186
Provides various transformation traits used by the range module.
T emplace_back(T... args)
Provides the unidirectional seqan3::fm_index.
Provides the seqan3::fm_index_cursor for searching in the unidirectional seqan3::fm_index.
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition alphabet/concept.hpp:152
@ seq
The "sequence", usually a range of nucleotides or amino acids.
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
@ single
The text is a single range.
Definition search/fm_index/concept.hpp:90
@ collection
The text is a range of ranges.
Definition search/fm_index/concept.hpp:92
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition slice.hpp:175
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
T reserve(T... args)
Provides seqan3::views::slice.
T tie(T... args)
Provides alphabet adaptations for standard uint types.
Hide me