SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
bi_fm_index_cursor.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
15 #include <array>
16 #include <seqan3/std/ranges>
17 
18 #include <sdsl/suffix_trees.hpp>
19 
27 
28 namespace seqan3
29 {
30 
56 template <typename index_t>
58 {
59 public:
61  using index_type = index_t;
62 
67  using size_type = typename index_type::size_type;
69 
74  using fwd_cursor = fm_index_cursor<fm_index<typename index_type::alphabet_type,
75  index_type::text_layout_mode,
76  typename index_type::sdsl_index_type>>;
78 
79 private:
81  using sdsl_char_type = typename index_type::sdsl_char_type;
83  using sdsl_index_type = typename index_t::sdsl_index_type;
85  using sdsl_sigma_type = typename index_type::sdsl_sigma_type;
87  using index_alphabet_type = typename index_t::alphabet_type;
92 
94  index_type const * index{nullptr};
95 
100  size_type fwd_lb{};
102  size_type fwd_rb{};
104  size_type rev_lb{};
106  size_type rev_rb{};
107  //\}
108 
110  sdsl_sigma_type sigma{};
111 
118  // parent_* and _last_char only have to be stored for the (unidirectional) cursor that has been used last for
119  // extend_right() or cycle_back() resp. extend_left() or cycle_front(), (i.e. either fwd or rev). Thus there is no
120  // need to store it twice. Once the cursor is switched, the information becomes invalid anyway.
121 
123  size_type parent_lb{};
125  size_type parent_rb{};
127  sdsl_char_type _last_char{};
128  //\}
129 
131  size_type depth{}; // equal for both cursors. only stored once
132 
133  // supports assertions to check whether cycle_back() resp. cycle_front() is called on the same direction as the last
134  // extend_right([...]) resp. extend_left([...])
135 #ifndef NDEBUG
137  // cycle_back() and cycle_front()
138  bool fwd_cursor_last_used = false;
139 #endif
140 
142  size_type offset() const noexcept
143  {
144  assert(index->size() > query_length());
145  return index->size() - query_length() - 1; // since the string is reversed during construction
146  }
147 
149  template <typename csa_t>
151  requires (std::same_as<csa_t, typename index_type::sdsl_index_type> ||
152  std::same_as<csa_t, typename index_type::rev_sdsl_index_type>)
154  bool bidirectional_search(csa_t const & csa, sdsl_char_type const c,
155  size_type & l_fwd, size_type & r_fwd,
156  size_type & l_bwd, size_type & r_bwd) const noexcept
157  {
158  assert((l_fwd <= r_fwd) && (r_fwd < csa.size()));
159  assert(r_fwd + 1 >= l_fwd);
160  assert(r_bwd + 1 - l_bwd == r_fwd + 1 - l_fwd);
161 
162  size_type _l_fwd, _r_fwd, _l_bwd, _r_bwd;
163 
164  size_type cc = c;
165  if constexpr(!std::same_as<index_alphabet_type, sdsl::plain_byte_alphabet>)
166  {
167  cc = csa.char2comp[c];
168  if (cc == 0 && c > 0) // [[unlikely]]
169  return false;
170  }
171 
172  size_type const c_begin = csa.C[cc];
173  if (r_fwd + 1 - l_fwd == csa.size()) // [[unlikely]]
174  {
175  _l_fwd = c_begin;
176  _l_bwd = c_begin;
177  _r_fwd = csa.C[cc + 1] - 1;
178  _r_bwd = _r_fwd;
179  // if we use not the plain_byte_alphabet, we could return always return true here
180  }
181  else
182  {
183  auto const r_s_b = csa.wavelet_tree.lex_count(l_fwd, r_fwd + 1, c);
184  size_type const rank_l = std::get<0>(r_s_b);
185  size_type const s = std::get<1>(r_s_b), b = std::get<2>(r_s_b);
186  size_type const rank_r = r_fwd - l_fwd - s - b + rank_l;
187  _l_fwd = c_begin + rank_l;
188  _r_fwd = c_begin + rank_r;
189  _l_bwd = l_bwd + s;
190  _r_bwd = r_bwd - b;
191  }
192 
193  if (_r_fwd >= _l_fwd)
194  {
195  l_fwd = _l_fwd;
196  r_fwd = _r_fwd;
197  l_bwd = _l_bwd;
198  r_bwd = _r_bwd;
199  assert(r_fwd + 1 >= l_fwd);
200  assert(r_bwd + 1 - l_bwd == r_fwd + 1 - l_fwd);
201  return true;
202  }
203  return false;
204  }
205 
207  template <typename csa_t>
209  requires (std::same_as<csa_t, typename index_type::sdsl_index_type> ||
210  std::same_as<csa_t, typename index_type::rev_sdsl_index_type>)
212  bool bidirectional_search_cycle(csa_t const & csa, sdsl_char_type const c,
213  size_type const l_parent, size_type const r_parent,
214  size_type & l_fwd, size_type & r_fwd,
215  size_type & l_bwd, size_type & r_bwd) const noexcept
216  {
217  assert((l_parent <= r_parent) && (r_parent < csa.size()));
218 
219  size_type c_begin;
220  if constexpr(std::same_as<index_alphabet_type, sdsl::plain_byte_alphabet>)
221  c_begin = csa.C[c]; // TODO: check whether this can be removed
222  else
223  c_begin = csa.C[csa.char2comp[c]];
224 
225  auto const r_s_b = csa.wavelet_tree.lex_count(l_parent, r_parent + 1, c);
226  size_type const s = std::get<1>(r_s_b),
227  b = std::get<2>(r_s_b),
228  rank_l = std::get<0>(r_s_b),
229  rank_r = r_parent - l_parent - s - b + rank_l;
230 
231  size_type const _l_fwd = c_begin + rank_l;
232  size_type const _r_fwd = c_begin + rank_r;
233  size_type const _l_bwd = r_bwd + 1;
234  size_type const _r_bwd = r_bwd + 1 + rank_r - rank_l;
235 
236  if (_r_fwd >= _l_fwd)
237  {
238  l_fwd = _l_fwd;
239  r_fwd = _r_fwd;
240  l_bwd = _l_bwd;
241  r_bwd = _r_bwd;
242  assert(r_fwd + 1 >= l_fwd);
243  assert(r_bwd + 1 - l_bwd == r_fwd + 1 - l_fwd);
244  return true;
245  }
246  return false;
247  }
248 
249 public:
250 
255  // Default construction is necessary to make this class semi-regular and e.g., to allow construction of
256  // std::array of cursors.
257  bi_fm_index_cursor() noexcept = default;
258  bi_fm_index_cursor(bi_fm_index_cursor const &) noexcept = default;
259  bi_fm_index_cursor & operator=(bi_fm_index_cursor const &) noexcept = default;
260  bi_fm_index_cursor(bi_fm_index_cursor &&) noexcept = default;
261  bi_fm_index_cursor & operator=(bi_fm_index_cursor &&) noexcept = default;
262  ~bi_fm_index_cursor() = default;
263 
265  bi_fm_index_cursor(index_t const & _index) noexcept : index(&_index),
266  fwd_lb(0), fwd_rb(_index.size() - 1),
267  rev_lb(0), rev_rb(_index.size() - 1),
268  sigma(_index.fwd_fm.index.sigma - index_t::text_layout_mode),
269  depth(0)
270  {}
271  //\}
272 
285  bool operator==(bi_fm_index_cursor const & rhs) const noexcept
286  {
287  assert(index != nullptr);
288  // equal SA interval implies equal parent node information (or both are root nodes)
289  assert(!(fwd_lb == rhs.fwd_lb && fwd_rb == rhs.fwd_rb && depth == rhs.depth) ||
290  (depth == 0) ||
291  (parent_lb == rhs.parent_lb && parent_rb == rhs.parent_rb && _last_char == rhs._last_char));
292 
293  return std::tie(fwd_lb, fwd_rb, depth) == std::tie(rhs.fwd_lb, rhs.fwd_rb, rhs.depth);
294  }
295 
308  bool operator!=(bi_fm_index_cursor const & rhs) const noexcept
309  {
310  assert(index != nullptr);
311 
312  return !(*this == rhs);
313  }
314 
332  bool extend_right() noexcept
333  {
334  #ifndef NDEBUG
335  fwd_cursor_last_used = true;
336  #endif
337 
338  assert(index != nullptr);
339 
340  size_type new_parent_lb = fwd_lb, new_parent_rb = fwd_rb;
341 
342  sdsl_char_type c = 1; // NOTE: start with 0 or 1 depending on implicit_sentintel
343  while (c < sigma &&
344  !bidirectional_search(index->fwd_fm.index, index->fwd_fm.index.comp2char[c],
345  fwd_lb, fwd_rb, rev_lb, 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, index->rev_fm.index.comp2char[c],
393  rev_lb, rev_rb, fwd_lb, fwd_rb))
394  {
395  ++c;
396  }
397 
398  if (c != sigma)
399  {
400  parent_lb = new_parent_lb;
401  parent_rb = new_parent_rb;
402 
403  _last_char = c;
404  ++depth;
405 
406  return true;
407  }
408  return false;
409  }
410 
424  template <typename char_t>
426  requires std::convertible_to<char_t, index_alphabet_type>
428  bool extend_right(char_t const c) noexcept
429  {
430  #ifndef NDEBUG
431  fwd_cursor_last_used = true;
432  #endif
433 
434  assert(index != nullptr);
435  // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
436  // for the indexed text.
437  assert(seqan3::to_rank(static_cast<index_alphabet_type>(c)) <
438  ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
439 
440  size_type new_parent_lb = fwd_lb, new_parent_rb = fwd_rb;
441 
442  auto c_char = seqan3::to_rank(static_cast<index_alphabet_type>(c)) + 1;
443  if (bidirectional_search(index->fwd_fm.index, c_char, fwd_lb, fwd_rb, rev_lb, rev_rb))
444  {
445  parent_lb = new_parent_lb;
446  parent_rb = new_parent_rb;
447 
448  _last_char = c_char;
449  ++depth;
450 
451  return true;
452  }
453  return false;
454  }
455 
457  template <typename char_type>
459  requires seqan3::detail::is_char_adaptation_v<char_type>
461  bool extend_right(char_type const * cstring) noexcept
462  {
464  }
465 
479  template <typename char_t>
481  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>
514  requires seqan3::detail::is_char_adaptation_v<char_type>
516  bool extend_left(char_type const * cstring) noexcept
517  {
519  }
520 
537  template <std::ranges::range seq_t>
538  bool extend_right(seq_t && seq) noexcept
539  {
540  static_assert(std::ranges::forward_range<seq_t>, "The query must model forward_range.");
541  static_assert(std::convertible_to<range_innermost_value_t<seq_t>, index_alphabet_type>,
542  "The alphabet of the sequence must be convertible to the alphabet of the index.");
543 
544  assert(index != nullptr);
545 
546  auto first = std::ranges::begin(seq);
547  auto last = std::ranges::end(seq);
548 
549  #ifndef NDEBUG
550  fwd_cursor_last_used = (first != last); // only if seq was not empty
551  #endif
552 
553  size_type _fwd_lb = fwd_lb, _fwd_rb = fwd_rb, _rev_lb = rev_lb, _rev_rb = rev_rb;
554  size_type new_parent_lb = parent_lb, new_parent_rb = parent_rb;
555  sdsl_char_type c = _last_char;
556  size_t len{0};
557 
558  for (auto it = first; it != last; ++len, ++it)
559  {
560  // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
561  // for the indexed text.
562  assert(seqan3::to_rank(static_cast<index_alphabet_type>(*it)) <
563  ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
564 
565  c = seqan3::to_rank(static_cast<index_alphabet_type>(*it)) + 1;
566 
567  new_parent_lb = _fwd_lb;
568  new_parent_rb = _fwd_rb;
569  if (!bidirectional_search(index->fwd_fm.index, c, _fwd_lb, _fwd_rb, _rev_lb, _rev_rb))
570  return false;
571  }
572 
573  fwd_lb = _fwd_lb;
574  fwd_rb = _fwd_rb;
575  rev_lb = _rev_lb;
576  rev_rb = _rev_rb;
577 
578  parent_lb = new_parent_lb;
579  parent_rb = new_parent_rb;
580 
581  _last_char = c;
582  depth += len;
583 
584  return true;
585  }
586 
607  template <std::ranges::range seq_t>
608  bool extend_left(seq_t && seq) noexcept
609  {
610  static_assert(std::ranges::bidirectional_range<seq_t>, "The query must model bidirectional_range.");
611  static_assert(std::convertible_to<range_innermost_value_t<seq_t>, index_alphabet_type>,
612  "The alphabet of the sequence must be convertible to the alphabet of the index.");
613  assert(index != nullptr);
614 
615  auto rev_seq = std::views::reverse(seq);
616  auto first = std::ranges::begin(rev_seq);
617  auto last = std::ranges::end(rev_seq);
618 
619  #ifndef NDEBUG
620  if (first != last) // only if seq was not empty
621  fwd_cursor_last_used = false;
622  #endif
623 
624  size_type _fwd_lb = fwd_lb, _fwd_rb = fwd_rb,
625  _rev_lb = rev_lb, _rev_rb = rev_rb;
626  size_type new_parent_lb = parent_lb, new_parent_rb = parent_rb;
627  sdsl_char_type c = _last_char;
628  size_t len{0};
629 
630  for (auto it = first; it != last; ++len, ++it)
631  {
632  // The rank cannot exceed 255 for single text and 254 for text collections as they are reserved as sentinels
633  // for the indexed text.
634  assert(seqan3::to_rank(static_cast<index_alphabet_type>(*it)) <
635  ((index_type::text_layout_mode == text_layout::single) ? 255 : 254));
636 
637  c = seqan3::to_rank(static_cast<index_alphabet_type>(*it)) + 1;
638 
639  new_parent_lb = _rev_lb;
640  new_parent_rb = _rev_rb;
641  if (!bidirectional_search(index->rev_fm.index, c, _rev_lb, _rev_rb, _fwd_lb, _fwd_rb))
642  return false;
643  }
644 
645  fwd_lb = _fwd_lb;
646  fwd_rb = _fwd_rb;
647  rev_lb = _rev_lb;
648  rev_rb = _rev_rb;
649 
650  parent_lb = new_parent_lb;
651  parent_rb = new_parent_rb;
652  _last_char = c;
653  depth += len;
654 
655  return true;
656  }
657 
684  bool cycle_back() noexcept
685  {
686  #ifndef NDEBUG
687  // cycle_back() can only be used if the last extension was to the right.
688  assert(fwd_cursor_last_used);
689  #endif
690 
691  assert(index != nullptr && query_length() > 0);
692 
693  sdsl_char_type c = _last_char + 1;
694 
695  while (c < sigma &&
696  !bidirectional_search_cycle(index->fwd_fm.index, index->fwd_fm.index.comp2char[c],
697  parent_lb, parent_rb, fwd_lb, fwd_rb, rev_lb, rev_rb))
698  {
699  ++c;
700  }
701 
702  if (c != sigma)
703  {
704  _last_char = c;
705 
706  return true;
707  }
708  return false;
709  }
710 
737  bool cycle_front() noexcept
738  {
739  #ifndef NDEBUG
740  // cycle_front() can only be used if the last extension was to the left.
741  assert(!fwd_cursor_last_used);
742  #endif
743 
744  assert(index != nullptr && query_length() > 0);
745 
746  sdsl_char_type c = _last_char + 1;
747  while (c < sigma &&
748  !bidirectional_search_cycle(index->rev_fm.index, index->rev_fm.index.comp2char[c],
749  parent_lb, parent_rb, rev_lb, rev_rb, fwd_lb, fwd_rb))
750  {
751  ++c;
752  }
753 
754  if (c != sigma)
755  {
756  _last_char = c;
757 
758  return true;
759  }
760  return false;
761  }
762 
763 
780  size_type last_rank() noexcept
781  {
782  assert(index != nullptr && query_length() > 0);
783 
784  return index->fwd_fm.index.comp2char[_last_char] - 1; // text is not allowed to contain ranks of 0
785  }
786 
799  size_type query_length() const noexcept
800  {
801  assert(index != nullptr);
802  // depth == 0 -> root node
803  assert(depth != 0 ||
804  (fwd_lb == rev_lb &&
805  fwd_rb == rev_rb &&
806  fwd_lb == 0 &&
807  fwd_rb == index->size() - 1));
808 
809  return depth;
810  }
811 
831  fwd_cursor to_fwd_cursor() const noexcept
832  {
833  assert(index != nullptr);
834 
835  fwd_cursor cur{index->fwd_fm};
836  cur.parent_lb = parent_lb;
837  cur.parent_rb = parent_rb;
838  cur.node = {fwd_lb, fwd_rb, depth, _last_char};
839 
840  #ifndef NDEBUG
841  if (!fwd_cursor_last_used)
842  {
843  // invalidate parent interval
844  cur.parent_lb = 1;
845  cur.parent_rb = 0;
846  }
847  #endif
848 
849  return cur;
850  }
851 
868  template <std::ranges::range text_t>
869  auto path_label(text_t && text) const noexcept
871  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
888  requires (index_t::text_layout_mode == text_layout::collection)
890  {
891  static_assert(std::ranges::input_range<text_t>, "The text collection must model input_range.");
892  static_assert(range_dimension_v<text_t> == 2, "The input must be a text collection.");
893  static_assert(std::same_as<range_innermost_value_t<text_t>, index_alphabet_type>,
894  "The alphabet types of the given text and index differ.");
895  assert(index != nullptr);
896 
897  // Position of query in concatenated text.
898  size_type const location = offset() - index->fwd_fm.index[fwd_lb];
899 
900  // The rank represents the number of start positions of the individual sequences/texts in the collection
901  // before position `location + 1` and thereby also the number of delimiters.
902  size_type const rank = index->fwd_fm.text_begin_rs.rank(location + 1);
903  assert(rank > 0);
904  size_type const text_id = rank - 1;
905 
906  // The start location of the `text_id`-th text in the sequence (position of the `rank`-th 1 in the bitvector).
907  size_type const start_location = index->fwd_fm.text_begin_ss.select(rank);
908  // Substract lengths of previous sequences.
909  size_type const query_begin = location - start_location;
910 
911  // Take subtext, slice query out of it
912  return text[text_id] | views::slice(query_begin, query_begin + query_length());
913  }
914 
926  size_type count() const noexcept
927  {
928  assert(index != nullptr && (1 + fwd_rb - fwd_lb == 1 + rev_rb - rev_lb));
929 
930  return 1 + fwd_rb - fwd_lb;
931  }
932 
946  requires (index_t::text_layout_mode == text_layout::single)
948  {
949  assert(index != nullptr);
950 
951  locate_result_type occ{};
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 
963  requires (index_t::text_layout_mode == text_layout::collection)
965  {
966  assert(index != nullptr);
967 
969  occ.reserve(count());
970  for (size_type i = 0; i < count(); ++i)
971  {
972  size_type loc = offset() - index->fwd_fm.index[fwd_lb + i];
973  size_type sequence_rank = index->fwd_fm.text_begin_rs.rank(loc + 1);
974  size_type sequence_position = loc - index->fwd_fm.text_begin_ss.select(sequence_rank);
975  occ.emplace_back(sequence_rank - 1, sequence_position);
976  }
977  return occ;
978  }
979 
992  auto lazy_locate() const
994  requires (index_t::text_layout_mode == text_layout::single)
996  {
997  assert(index != nullptr);
998 
999  return std::views::iota(fwd_lb, fwd_lb + count())
1000  | std::views::transform([*this, _offset = offset()] (auto sa_pos)
1001  {
1002  return locate_result_value_type{0u, _offset - index->fwd_fm.index[sa_pos]};
1003  });
1004  }
1005 
1007  auto lazy_locate() const
1009  requires (index_t::text_layout_mode == text_layout::collection)
1011  {
1012  assert(index != nullptr);
1013 
1014  return std::views::iota(fwd_lb, fwd_lb + count())
1015  | std::views::transform([*this, _offset = offset()] (auto sa_pos)
1016  {
1017  auto loc = _offset - index->fwd_fm.index[sa_pos];
1018  size_type sequence_rank = index->fwd_fm.text_begin_rs.rank(loc + 1);
1019  size_type sequence_position = loc - index->fwd_fm.text_begin_ss.select(sequence_rank);
1020  return locate_result_value_type{sequence_rank-1, sequence_position};
1021  });
1022  }
1023 
1031  template <cereal_archive archive_t>
1032  void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
1033  {
1034  archive(fwd_lb);
1035  archive(fwd_rb);
1036  archive(rev_lb);
1037  archive(rev_rb);
1038  archive(sigma);
1039  archive(parent_lb);
1040  archive(parent_rb);
1041  archive(_last_char);
1042  archive(depth);
1043  }
1045 };
1046 
1048 
1049 } // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
Provides alphabet adaptations for standard char types.
The SeqAn Bidirectional FM Index Cursor.
Definition: bi_fm_index_cursor.hpp:58
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:332
size_type count() const noexcept
Counts the number of occurrences of the searched query in the text.
Definition: bi_fm_index_cursor.hpp:926
bool extend_left(seq_t &&seq) noexcept
Tries to extend the query by seq to the left.
Definition: bi_fm_index_cursor.hpp:608
bool operator==(bi_fm_index_cursor const &rhs) const noexcept
Compares two cursors.
Definition: bi_fm_index_cursor.hpp:285
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:516
auto path_label(text_t &&text) const noexcept
Returns the searched query.
Definition: bi_fm_index_cursor.hpp:869
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
locate_result_type locate() const
Locates the occurrences of the searched query in the text.
Definition: bi_fm_index_cursor.hpp:944
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
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:684
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:737
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:831
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:799
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:780
index_t index_type
Type of the index.
Definition: bi_fm_index_cursor.hpp:61
typename index_type::size_type size_type
Type for representing positions in the indexed text.
Definition: bi_fm_index_cursor.hpp:67
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
bool operator!=(bi_fm_index_cursor const &rhs) const noexcept
Compares two cursors.
Definition: bi_fm_index_cursor.hpp:308
bi_fm_index_cursor() noexcept=default
Default constructor. Accessing member functions on a default constructed object is undefined behavior...
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
bool extend_right(seq_t &&seq) noexcept
Tries to extend the query by seq to the right.
Definition: bi_fm_index_cursor.hpp:538
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:992
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:428
The SeqAn FM Index Cursor.
Definition: fm_index_cursor.hpp:90
The SeqAn FM Index.
Definition: fm_index.hpp:193
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: concept.hpp:155
typename range_innermost_value< t >::type range_innermost_value_t
Shortcut for seqan3::range_innermost_value (transformation_trait shortcut).
Definition: type_traits.hpp:242
@ 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: concept.hpp:81
@ single
The text is a single range.
Definition: concept.hpp:83
@ collection
The text is a range of ranges.
Definition: concept.hpp:85
decltype(detail::transform< trait_t >(list_t{})) transform
Apply a transformation trait to every type in the list and return a seqan3::type_list of the results.
Definition: traits.hpp:471
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:151
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition: slice.hpp:189
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Adaptations of concepts from the Ranges TS.
T reserve(T... args)
Exposes the size_type of another type.
Definition: pre.hpp:296
T tie(T... args)
Provides alphabet adaptations for standard uint types.
Provides seqan3::views::slice.