SeqAn3 3.4.0-rc.4
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-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 <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>)
146 bool 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>)
205 bool 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.
257
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
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_sigma_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
356 _last_char = static_cast<sdsl_char_type>(c);
357 ++depth;
358
359 return true;
360 }
361 return false;
362 }
363
382 {
383#ifndef NDEBUG
384 fwd_cursor_last_used = false;
385#endif
386
387 assert(index != nullptr);
388
389 size_type new_parent_lb = rev_lb, new_parent_rb = rev_rb;
390
391 sdsl_sigma_type c = 1; // NOTE: start with 0 or 1 depending on implicit_sentintel
392 while (c < sigma
393 && !bidirectional_search(index->rev_fm.index,
394 index->rev_fm.index.comp2char[c],
395 rev_lb,
396 rev_rb,
397 fwd_lb,
398 fwd_rb))
399 {
400 ++c;
401 }
402
403 if (c != sigma)
404 {
405 parent_lb = new_parent_lb;
406 parent_rb = new_parent_rb;
407
409 _last_char = static_cast<sdsl_char_type>(c);
410 ++depth;
411
412 return true;
413 }
414 return false;
415 }
416
430 template <typename char_t>
431 requires std::convertible_to<char_t, index_alphabet_type>
432 bool extend_right(char_t const c) noexcept
433 {
434#ifndef NDEBUG
435 fwd_cursor_last_used = true;
436#endif
437
438 assert(index != nullptr);
439 // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
440 // for the indexed text.
441 assert(seqan3::to_rank(static_cast<index_alphabet_type>(c))
442 < ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
443
444 size_type new_parent_lb = fwd_lb, new_parent_rb = fwd_rb;
445
446 auto c_char = seqan3::to_rank(static_cast<index_alphabet_type>(c)) + 1;
447 if (bidirectional_search(index->fwd_fm.index, c_char, fwd_lb, fwd_rb, rev_lb, rev_rb))
448 {
449 parent_lb = new_parent_lb;
450 parent_rb = new_parent_rb;
451
452 _last_char = c_char;
453 ++depth;
454
455 return true;
456 }
457 return false;
458 }
459
461 template <typename char_type>
462 requires seqan3::detail::is_char_adaptation_v<char_type>
463 bool extend_right(char_type const * cstring) noexcept
464 {
466 }
467
481 template <typename char_t>
482 requires std::convertible_to<char_t, index_alphabet_type>
483 bool extend_left(char_t const c) noexcept
484 {
485#ifndef NDEBUG
486 fwd_cursor_last_used = false;
487#endif
488
489 assert(index != nullptr);
490 // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
491 // for the indexed text.
492 assert(seqan3::to_rank(static_cast<index_alphabet_type>(c))
493 < ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
494
495 size_type new_parent_lb = rev_lb, new_parent_rb = rev_rb;
496
497 auto c_char = seqan3::to_rank(static_cast<index_alphabet_type>(c)) + 1;
498 if (bidirectional_search(index->rev_fm.index, c_char, rev_lb, rev_rb, fwd_lb, fwd_rb))
499 {
500 parent_lb = new_parent_lb;
501 parent_rb = new_parent_rb;
502
503 _last_char = c_char;
504 ++depth;
505
506 return true;
507 }
508 return false;
509 }
510
512 template <typename char_type>
513 requires seqan3::detail::is_char_adaptation_v<char_type>
514 bool extend_left(char_type const * cstring) noexcept
515 {
517 }
518
535 template <std::ranges::range seq_t>
536 bool extend_right(seq_t && seq) noexcept
537 {
538 static_assert(std::ranges::forward_range<seq_t>, "The query must model forward_range.");
539 static_assert(std::convertible_to<range_innermost_value_t<seq_t>, index_alphabet_type>,
540 "The alphabet of the sequence must be convertible to the alphabet of the index.");
541
542 assert(index != nullptr);
543
544 auto first = std::ranges::begin(seq);
545 auto last = std::ranges::end(seq);
546
547#ifndef NDEBUG
548 fwd_cursor_last_used = (first != last); // only if seq was not empty
549#endif
550
551 size_type _fwd_lb = fwd_lb, _fwd_rb = fwd_rb, _rev_lb = rev_lb, _rev_rb = rev_rb;
552 size_type new_parent_lb = parent_lb, new_parent_rb = parent_rb;
553 sdsl_char_type c = _last_char;
554 size_t len{0};
555
556 for (auto it = first; it != last; ++len, ++it)
557 {
558 // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
559 // for the indexed text.
560 assert(seqan3::to_rank(static_cast<index_alphabet_type>(*it))
561 < ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
562
563 c = seqan3::to_rank(static_cast<index_alphabet_type>(*it)) + 1;
564
567 if (!bidirectional_search(index->fwd_fm.index, c, _fwd_lb, _fwd_rb, _rev_lb, _rev_rb))
568 return false;
569 }
570
571 fwd_lb = _fwd_lb;
572 fwd_rb = _fwd_rb;
573 rev_lb = _rev_lb;
574 rev_rb = _rev_rb;
575
576 parent_lb = new_parent_lb;
577 parent_rb = new_parent_rb;
578
579 _last_char = c;
580 depth += len;
581
582 return true;
583 }
584
605 template <std::ranges::range seq_t>
606 bool extend_left(seq_t && seq) noexcept
607 {
608 static_assert(std::ranges::bidirectional_range<seq_t>, "The query must model bidirectional_range.");
609 static_assert(std::convertible_to<range_innermost_value_t<seq_t>, index_alphabet_type>,
610 "The alphabet of the sequence must be convertible to the alphabet of the index.");
611 assert(index != nullptr);
612
613 auto rev_seq = std::views::reverse(seq);
614 auto first = std::ranges::begin(rev_seq);
615 auto last = std::ranges::end(rev_seq);
616
617#ifndef NDEBUG
618 if (first != last) // only if seq was not empty
619 fwd_cursor_last_used = false;
620#endif
621
622 size_type _fwd_lb = fwd_lb, _fwd_rb = fwd_rb, _rev_lb = rev_lb, _rev_rb = rev_rb;
623 size_type new_parent_lb = parent_lb, new_parent_rb = parent_rb;
624 sdsl_char_type c = _last_char;
625 size_t len{0};
626
627 for (auto it = first; it != last; ++len, ++it)
628 {
629 // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
630 // for the indexed text.
631 assert(seqan3::to_rank(static_cast<index_alphabet_type>(*it))
632 < ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
633
634 c = seqan3::to_rank(static_cast<index_alphabet_type>(*it)) + 1;
635
638 if (!bidirectional_search(index->rev_fm.index, c, _rev_lb, _rev_rb, _fwd_lb, _fwd_rb))
639 return false;
640 }
641
642 fwd_lb = _fwd_lb;
643 fwd_rb = _fwd_rb;
644 rev_lb = _rev_lb;
645 rev_rb = _rev_rb;
646
647 parent_lb = new_parent_lb;
648 parent_rb = new_parent_rb;
649 _last_char = c;
650 depth += len;
651
652 return true;
653 }
654
682 {
683#ifndef NDEBUG
684 // cycle_back() can only be used if the last extension was to the right.
685 assert(fwd_cursor_last_used);
686#endif
687
688 assert(index != nullptr && query_length() > 0);
689
690 sdsl_sigma_type c = _last_char + 1;
691
692 while (c < sigma
693 && !bidirectional_search_cycle(index->fwd_fm.index,
694 index->fwd_fm.index.comp2char[c],
695 parent_lb,
696 parent_rb,
697 fwd_lb,
698 fwd_rb,
699 rev_lb,
700 rev_rb))
701 {
702 ++c;
703 }
704
705 if (c != sigma)
706 {
708 _last_char = static_cast<sdsl_char_type>(c);
709
710 return true;
711 }
712 return false;
713 }
714
742 {
743#ifndef NDEBUG
744 // cycle_front() can only be used if the last extension was to the left.
745 assert(!fwd_cursor_last_used);
746#endif
747
748 assert(index != nullptr && query_length() > 0);
749
750 sdsl_sigma_type c = _last_char + 1;
751 while (c < sigma
752 && !bidirectional_search_cycle(index->rev_fm.index,
753 index->rev_fm.index.comp2char[c],
754 parent_lb,
755 parent_rb,
756 rev_lb,
757 rev_rb,
758 fwd_lb,
759 fwd_rb))
760 {
761 ++c;
762 }
763
764 if (c != sigma)
765 {
767 _last_char = static_cast<sdsl_char_type>(c);
768
769 return true;
770 }
771 return false;
772 }
773
791 {
792 assert(index != nullptr && query_length() > 0);
793
794 return index->fwd_fm.index.comp2char[_last_char] - 1; // text is not allowed to contain ranks of 0
795 }
796
810 {
811 assert(index != nullptr);
812 // depth == 0 -> root node
813 assert(depth != 0 || (fwd_lb == rev_lb && fwd_rb == rev_rb && fwd_lb == 0 && fwd_rb == index->size() - 1));
814
815 return depth;
816 }
817
838 {
839 assert(index != nullptr);
840
841 fwd_cursor cur{index->fwd_fm};
842 cur.parent_lb = parent_lb;
843 cur.parent_rb = parent_rb;
844 cur.node = {fwd_lb, fwd_rb, depth, _last_char};
845
846#ifndef NDEBUG
847 if (!fwd_cursor_last_used)
848 {
849 // invalidate parent interval
850 cur.parent_lb = 1;
851 cur.parent_rb = 0;
852 }
853#endif
854
855 return cur;
856 }
857
874 template <std::ranges::range text_t>
875 auto path_label(text_t && text) const noexcept
876 requires (index_t::text_layout_mode == text_layout::single)
877 {
878 static_assert(std::ranges::input_range<text_t>, "The text must model input_range.");
879 static_assert(range_dimension_v<text_t> == 1, "The input cannot be a text collection.");
880 static_assert(std::same_as<range_innermost_value_t<text_t>, index_alphabet_type>,
881 "The alphabet types of the given text and index differ.");
882 assert(index != nullptr);
883
884 size_type const query_begin = offset() - index->fwd_fm.index[fwd_lb];
886 }
887
889 template <std::ranges::range text_t>
890 auto path_label(text_t && text) const noexcept
891 requires (index_t::text_layout_mode == text_layout::collection)
892 {
893 static_assert(std::ranges::input_range<text_t>, "The text collection must model input_range.");
894 static_assert(range_dimension_v<text_t> == 2, "The input must be a text collection.");
895 static_assert(std::same_as<range_innermost_value_t<text_t>, index_alphabet_type>,
896 "The alphabet types of the given text and index differ.");
897 assert(index != nullptr);
898
899 // Position of query in concatenated text.
900 size_type const location = offset() - index->fwd_fm.index[fwd_lb];
901
902 // The rank represents the number of start positions of the individual sequences/texts in the collection
903 // before position `location + 1` and thereby also the number of delimiters.
904 size_type const rank = index->fwd_fm.text_begin_rs.rank(location + 1);
905 assert(rank > 0);
906 size_type const text_id = rank - 1;
907
908 // The start location of the `text_id`-th text in the sequence (position of the `rank`-th 1 in the bitvector).
909 size_type const start_location = index->fwd_fm.text_begin_ss.select(rank);
910 // Substract lengths of previous sequences.
912
913 // Take subtext, slice query out of it
915 }
916
929 {
930 assert(index != nullptr && (1 + fwd_rb - fwd_lb == 1 + rev_rb - rev_lb));
931
932 return 1 + fwd_rb - fwd_lb;
933 }
934
947 requires (index_t::text_layout_mode == text_layout::single)
948 {
949 assert(index != nullptr);
950
952 occ.reserve(count());
953 for (size_type i = 0; i < count(); ++i)
954 {
955 occ.emplace_back(0, offset() - index->fwd_fm.index[fwd_lb + i]);
956 }
957 return occ;
958 }
959
962 requires (index_t::text_layout_mode == text_layout::collection)
963 {
964 assert(index != nullptr);
965
967 occ.reserve(count());
968 for (size_type i = 0; i < count(); ++i)
969 {
970 size_type loc = offset() - index->fwd_fm.index[fwd_lb + i];
971 size_type sequence_rank = index->fwd_fm.text_begin_rs.rank(loc + 1);
972 size_type sequence_position = loc - index->fwd_fm.text_begin_ss.select(sequence_rank);
973 occ.emplace_back(sequence_rank - 1, sequence_position);
974 }
975 return occ;
976 }
977
991 requires (index_t::text_layout_mode == text_layout::single)
992 {
993 assert(index != nullptr);
994
995 return std::views::iota(fwd_lb, fwd_lb + count())
996 | std::views::transform(
997 [*this, _offset = offset()](auto sa_pos)
998 {
999 return locate_result_value_type{0u, _offset - index->fwd_fm.index[sa_pos]};
1000 });
1001 }
1002
1005 requires (index_t::text_layout_mode == text_layout::collection)
1006 {
1007 assert(index != nullptr);
1008
1009 return std::views::iota(fwd_lb, fwd_lb + count())
1010 | std::views::transform(
1011 [*this, _offset = offset()](auto sa_pos)
1012 {
1013 auto loc = _offset - index->fwd_fm.index[sa_pos];
1014 size_type sequence_rank = index->fwd_fm.text_begin_rs.rank(loc + 1);
1015 size_type sequence_position = loc - index->fwd_fm.text_begin_ss.select(sequence_rank);
1016 return locate_result_value_type{sequence_rank - 1, sequence_position};
1017 });
1018 }
1019
1027 template <cereal_archive archive_t>
1029 {
1030 archive(fwd_lb);
1031 archive(fwd_rb);
1032 archive(rev_lb);
1033 archive(rev_rb);
1034 archive(sigma);
1035 archive(parent_lb);
1036 archive(parent_rb);
1037 archive(_last_char);
1038 archive(depth);
1039 }
1041};
1042
1043} // 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:928
bool extend_left(seq_t &&seq) noexcept
Tries to extend the query by seq to the left.
Definition bi_fm_index_cursor.hpp:606
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:514
auto path_label(text_t &&text) const noexcept
Returns the searched query.
Definition bi_fm_index_cursor.hpp:875
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:381
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:890
locate_result_type locate() const
Locates the occurrences of the searched query in the text.
Definition bi_fm_index_cursor.hpp:946
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:681
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:741
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:1004
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:837
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:809
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:463
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:790
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:961
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:990
bool extend_right(seq_t &&seq) noexcept
Tries to extend the query by seq to the right.
Definition bi_fm_index_cursor.hpp:536
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:432
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:483
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
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.
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:70
@ single
The text is a single range.
Definition search/fm_index/concept.hpp:72
@ collection
The text is a range of ranges.
Definition search/fm_index/concept.hpp:74
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition slice.hpp:137
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides seqan3::views::slice.
T tie(T... args)
Provides alphabet adaptations for standard uint types.
Hide me