SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
gap_decorator.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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 
14 #pragma once
15 
16 #include <limits>
17 #include <set>
18 #include <tuple>
19 #include <type_traits>
20 
29 #include <seqan3/std/algorithm>
30 #include <seqan3/std/ranges>
31 
32 namespace seqan3
33 {
34 
79 template <std::ranges::viewable_range inner_type>
81  requires std::ranges::random_access_range<inner_type> && std::ranges::sized_range<inner_type> &&
82  (std::is_const_v<std::remove_reference_t<inner_type>> || std::ranges::view<inner_type>)
85 {
86 private:
87  // Declaration of class's iterator types; for the definition see below.
89 
94  using const_iterator = iterator;
95 
96 public:
112 
114  using unaligned_seq_type = inner_type;
115 
119  constexpr gap_decorator() = default;
123  constexpr gap_decorator(gap_decorator const &) = default;
125  constexpr gap_decorator & operator=(gap_decorator const &) = default;
127  constexpr gap_decorator(gap_decorator && rhs) = default;
129  constexpr gap_decorator & operator=(gap_decorator && rhs) = default;
131  ~gap_decorator() = default;
132 
134  template <typename other_range_t>
138  std::ranges::viewable_range<other_range_t> // at end, otherwise it competes with the move ctor
140  gap_decorator(other_range_t && range) : ungapped_view{views::type_reduce(std::forward<inner_type>(range))}
141  {} // TODO (@smehringer) only works for copyable views. Has to be changed once views are not required to be copyable anymore.
142  // !\}
143 
155  size_type size() const noexcept
156  {
157  if (anchors.size())
158  return anchors.rbegin()->second + ungapped_view.size();
159 
160  return ungapped_view.size();
161  }
162 
177  {
178  if (!count) // [[unlikely]]
179  return it;
180 
181  size_type const pos = it - begin();
182  assert(pos <= size());
183 
184  set_iterator_type it_set = anchors.upper_bound(anchor_gap_t{pos, bound_dummy});
185 
186  if (it_set == anchors.begin()) // will also catch if anchors is empty since begin() == end()
187  {
188  anchors.emplace_hint(anchors.begin(), anchor_gap_t{pos, count});
189  }
190  else // there are gaps before pos
191  {
192  --it_set;
193  auto gap_len{it_set->second};
194  if (it_set != anchors.begin())
195  gap_len -= (*(std::prev(it_set))).second;
196 
197  if (it_set->first + gap_len >= pos) // extend existing gap
198  {
199  anchor_gap_t gap{it_set->first, it_set->second + count};
200  it_set = anchors.erase(it_set);
201  anchors.insert(it_set, gap);
202  }
203  else // insert new gap
204  {
205  anchor_gap_t gap{pos, it_set->second + count};
206  ++it_set;
207  anchors.insert(it_set, gap);
208  }
209  }
210 
211  // post-processing: reverse update of succeeding gaps
212  rupdate(pos, count);
213  return iterator{*this, pos};
214  }
215 
228  {
229  // check if [it, it+gap_len[ covers [first, last[
230  if ((*it) != gap{}) // [[unlikely]]
231  throw gap_erase_failure("The range to be erased does not correspond to a consecutive gap.");
232 
233  return erase_gap(it, std::next(it));
234  }
235 
250  {
251  size_type const pos1 = first - begin();
252  size_type const pos2 = last - begin();
253  set_iterator_type it = anchors.upper_bound(anchor_gap_t{pos1, bound_dummy}); // first element greater than pos1
254 
255  if (it == anchors.begin())
256  throw gap_erase_failure{"There is no gap to erase in range [" + std::to_string(pos1) + "," +
257  std::to_string(pos2) + "]."};
258 
259  --it;
260  size_type const gap_len = gap_length(it);
261 
262  // check if [it, it+gap_len[ covers [first, last[
263  if ((it->first + gap_len) < pos2) // [[unlikely]]
264  {
265  throw gap_erase_failure{"The range to be erased does not correspond to a consecutive gap."};
266  }
267  // case 1: complete gap is deleted
268  else if (gap_len == pos2 - pos1)
269  {
270  it = anchors.erase(it);
271  }
272  // case 2: gap to be deleted in tail or larger than 1 (equiv. to shift tail left, i.e. pos remains unchanged)
273  else
274  {
275  anchor_gap_t gap{it->first, it->second - pos2 + pos1};
276  it = anchors.erase(it);
277  it = anchors.insert(it, gap); // amortized constant because of hint
278  ++it; // update node after the current
279  }
280 
281  // post-processing: forward update of succeeding gaps
282  update(it, pos2 - pos1);
283 
284  return iterator{*this, pos1};
285  }
286 
291  template <typename unaligned_seq_t> // generic template to use forwarding reference
295  friend void assign_unaligned(gap_decorator & dec, unaligned_seq_t && unaligned)
296  {
297  dec = unaligned;
298  }
300 
317  const_iterator begin() const noexcept
318  {
319  return iterator{*this};
320  }
321 
323  const_iterator cbegin() const noexcept
324  {
325  return const_iterator{*this};
326  }
327 
341  const_iterator end() const noexcept
342  {
343  return iterator{*this, size()};
344  }
345 
347  const_iterator cend() const noexcept
348  {
349  return const_iterator{*this, size()};
350  }
352 
369  {
370  if (i >= size()) // [[unlikely]]
371  throw std::out_of_range{"Trying to access element behind the last in gap_decorator."};
372  return (*this)[i];
373  }
374 
376  const_reference at(size_type const i) const
377  {
378  if (i >= size()) // [[unlikely]]
379  throw std::out_of_range{"Trying to access element behind the last in gap_decorator."};
380  return (*this)[i];
381  }
382 
394  constexpr reference operator[](size_type const i) const noexcept
395  {
396  return *iterator{*this, i};
397  }
399 
419  friend bool operator==(gap_decorator const & lhs, gap_decorator const & rhs) noexcept
421  {
422  if (lhs.size() == rhs.size() &&
423  lhs.anchors == rhs.anchors &&
424  std::ranges::equal(lhs.ungapped_view, rhs.ungapped_view))
425  {
426  return true;
427  }
428 
429  return false;
430  }
431 
433  friend bool operator!=(gap_decorator const & lhs, gap_decorator const & rhs) noexcept
434  {
435  return !(lhs == rhs);
436  }
437 
439  friend bool operator<(gap_decorator const & lhs, gap_decorator const & rhs) noexcept
440  {
441  auto lit = lhs.begin();
442  auto rit = rhs.begin();
443 
444  while (lit != lhs.end() && rit != rhs.end() && *lit == *rit)
445  ++lit, ++rit;
446 
447  if (rit == rhs.end())
448  return false; // lhs == rhs, or rhs prefix of lhs
449  else if (lit == lhs.end())
450  return true; // lhs prefix of rhs
451 
452  return *lit < *rit;
453  }
454 
456  friend bool operator<=(gap_decorator const & lhs, gap_decorator const & rhs) noexcept
457  {
458  auto lit = lhs.begin();
459  auto rit = rhs.begin();
460 
461  while (lit != lhs.end() && rit != rhs.end() && *lit == *rit)
462  ++lit, ++rit;
463 
464  if (lit == lhs.end())
465  return true; // lhs == rhs, or lhs prefix of rhs
466  else if (rit == rhs.end())
467  return false; // rhs prefix of lhs
468 
469  return *lit < *rit;
470  }
471 
473  friend bool operator>(gap_decorator const & lhs, gap_decorator const & rhs) noexcept
474  {
475  return !(lhs <= rhs);
476  }
477 
479  friend bool operator>=(gap_decorator const & lhs, gap_decorator const & rhs) noexcept
480  {
481  return !(lhs < rhs);
482  }
484 
485 private:
487  using anchor_gap_t = typename std::pair<size_t, size_t>;
488 
490  using anchor_set_type = std::set<anchor_gap_t>;
491 
493  using set_iterator_type = typename anchor_set_type::iterator;
494 
496  constexpr static size_t bound_dummy{std::numeric_limits<size_t>::max()};
497 
510  constexpr size_type gap_length(set_iterator_type it) const noexcept
511  {
512  return (it == anchors.begin()) ? it->second : it->second - (*std::prev(it)).second;
513  }
514 
527  void rupdate(size_type const pos, size_type const offset)
528  {
529  for (auto it = std::prev(anchors.end(), 1); it->first > pos;)
530  {
531  anchors.emplace_hint(it, anchor_gap_t{it->first + offset, it->second + offset});
532  anchors.erase(*it--);
533  }
534  }
535 
548  void update(set_iterator_type it, size_type const offset)
549  {
550  while (it != anchors.end())
551  {
552  anchor_gap_t gap{it->first - offset, it->second - offset};
553  it = anchors.erase(it);
554  it = anchors.insert(it, gap);
555  ++it;
556  }
557  }
558 
560  decltype(views::type_reduce(std::declval<inner_type &&>())) ungapped_view{};
561 
563  anchor_set_type anchors{};
564 };
565 
569 template <std::ranges::viewable_range urng_t>
572  requires !std::ranges::view<std::remove_reference_t<urng_t>>
574 gap_decorator(urng_t && range) -> gap_decorator<std::remove_reference_t<urng_t> const &>;
575 
577 template <std::ranges::view urng_t>
578 gap_decorator(urng_t range) -> gap_decorator<urng_t>;
580 
597 template <std::ranges::viewable_range inner_type>
599  requires std::ranges::random_access_range<inner_type> && std::ranges::sized_range<inner_type> &&
600  (std::is_const_v<std::remove_reference_t<inner_type>> || std::ranges::view<inner_type>)
603 {
604 protected:
608  typename gap_decorator::size_type pos{0u};
610  int64_t ungapped_view_pos{0}; // must be signed because we need this value to be -1 in case of leading gaps.
613  typename gap_decorator::size_type left_gap_end{0};
616  typename gap_decorator::set_iterator_type anchor_set_it{};
618  bool is_at_gap{true};
619 
621  void jump(typename gap_decorator::size_type const new_pos)
622  {
623  assert(new_pos <= host->size());
624  pos = new_pos;
625 
626  anchor_set_it = host->anchors.upper_bound(anchor_gap_t{pos, host->bound_dummy});
627  ungapped_view_pos = pos;
628 
629  if (anchor_set_it != host->anchors.begin())
630  {
631  typename gap_decorator::set_iterator_type prev{std::prev(anchor_set_it)};
632  size_type gap_len{prev->second};
633 
634  if (prev != host->anchors.begin())
635  gap_len -= std::prev(prev)->second;
636 
637  ungapped_view_pos -= prev->second;
638  left_gap_end = prev->first + gap_len;
639  }
640 
641  if (ungapped_view_pos != static_cast<int64_t>(host->ungapped_view.size()) &&
642  pos >= left_gap_end && (anchor_set_it == host->anchors.end() || pos < anchor_set_it->first))
643  is_at_gap = false;
644  else
645  is_at_gap = true;
646  }
647 
648 public:
659  using pointer = value_type *;
663 
667  constexpr gap_decorator_iterator() = default;
668  constexpr gap_decorator_iterator(gap_decorator_iterator const &) = default;
669  constexpr gap_decorator_iterator & operator=(gap_decorator_iterator const &) = default;
670  constexpr gap_decorator_iterator(gap_decorator_iterator &&) = default;
671  constexpr gap_decorator_iterator & operator=(gap_decorator_iterator &&) = default;
672  ~gap_decorator_iterator() = default;
673 
675  explicit constexpr gap_decorator_iterator(gap_decorator const & host_) noexcept :
676  host(&host_), anchor_set_it{host_.anchors.begin()}
677  {
678  if (host_.anchors.size() && (*host_.anchors.begin()).first == 0) // there are gaps at the very front
679  {
680  --ungapped_view_pos; // set ungapped_view_pos to -1 so operator++ works without an extra if-branch.
681  left_gap_end = anchor_set_it->second;
682  ++anchor_set_it;
683  }
684  else
685  {
686  is_at_gap = false;
687  }
688  }
689 
691  constexpr gap_decorator_iterator(gap_decorator const & host_,
692  typename gap_decorator::size_type const pos_) noexcept : host(&host_)
693  {
694  jump(pos_); // random access to pos
695  }
697 
701  constexpr gap_decorator_iterator & operator++() noexcept
703  {
704  assert(host); // host is set
705  ++pos;
706 
707  if (pos < left_gap_end) // we stay within the preceding gap stretch
708  return *this;
709 
710  if (anchor_set_it == host->anchors.end() || pos < anchor_set_it->first)
711  { // proceed within the view since we are right of the previous gap but didn't arrive at the right gap yet
712  ++ungapped_view_pos;
713  if (ungapped_view_pos != static_cast<int64_t>(host->ungapped_view.size()))
714  is_at_gap = false;
715  }
716  else
717  { // we arrived at the right gap and have to update the variables. ungapped_view_pos remains unchanged.
718  left_gap_end = anchor_set_it->first + anchor_set_it->second -
719  ((anchor_set_it != host->anchors.begin()) ? (std::prev(anchor_set_it))->second : 0);
720  ++anchor_set_it;
721  is_at_gap = true;
722 
723  if (left_gap_end == host->size()) // very last gap
724  ++ungapped_view_pos;
725  }
726 
727  return *this;
728  }
729 
731  constexpr gap_decorator_iterator operator++(int) noexcept
732  {
733  gap_decorator_iterator cpy{*this};
734  ++(*this);
735  return cpy;
736  }
737 
739  constexpr gap_decorator_iterator & operator+=(difference_type const skip) noexcept
740  {
741  this->jump(this->pos + skip);
742  return *this;
743  }
744 
746  constexpr gap_decorator_iterator operator+(difference_type const skip) const noexcept
747  {
748  return gap_decorator_iterator{*(this->host), this->pos + skip};
749  }
750 
752  constexpr friend gap_decorator_iterator operator+(difference_type const skip,
753  gap_decorator_iterator const & it) noexcept
754  {
755  return it + skip;
756  }
757 
759  constexpr gap_decorator_iterator & operator--() noexcept
760  {
761  assert(host); // host is set
762  --pos;
763 
764  if (pos < left_gap_end)
765  { // there was no gap before but we arrive at the left gap and have to update the variables.
766  (anchor_set_it != host->anchors.begin()) ? --anchor_set_it : anchor_set_it;
767 
768  if (anchor_set_it != host->anchors.begin())
769  {
770  auto prev = std::prev(anchor_set_it);
771  left_gap_end = prev->first + prev->second -
772  ((prev != host->anchors.begin()) ? std::prev(prev)->second : 0);
773  }
774  else // [[unlikely]]
775  {
776  left_gap_end = 0;
777  }
778  is_at_gap = true;
779  }
780  else if (anchor_set_it == host->anchors.end() || pos < anchor_set_it->first)
781  { // we are neither at the left nor right gap
782  --ungapped_view_pos;
783  is_at_gap = false;
784  }
785  // else -> no op (we are still within the right gap stretch)
786 
787  return *this;
788  }
789 
791  constexpr gap_decorator_iterator operator--(int) noexcept
792  {
793  gap_decorator_iterator cpy{*this};
794  --(*this);
795  return cpy;
796  }
797 
799  constexpr gap_decorator_iterator & operator-=(difference_type const skip) noexcept
800  {
801  this->jump(this->pos - skip);
802  return *this;
803  }
804 
806  constexpr gap_decorator_iterator operator-(difference_type const skip) const noexcept
807  {
808  return gap_decorator_iterator{*(this->host), this->pos - skip};
809  }
810 
812  constexpr friend gap_decorator_iterator operator-(difference_type const skip,
813  gap_decorator_iterator const & it) noexcept
814  {
815  return it - skip;
816  }
817 
819  constexpr difference_type operator-(gap_decorator_iterator const lhs) const noexcept
820  {
821  return static_cast<difference_type>(this->pos - lhs.pos);
822  }
824 
828  constexpr reference operator*() const noexcept
830  {
831  return (is_at_gap) ? reference{gap{}} : reference{host->ungapped_view[ungapped_view_pos]};
832  }
833 
835  constexpr reference operator[](difference_type const n) const noexcept
836  {
837  return *(*this + n);
838  }
840 
846  constexpr friend bool operator==(gap_decorator_iterator const & lhs, gap_decorator_iterator const & rhs)
848  noexcept
849  {
850  return lhs.pos == rhs.pos;
851  }
852 
854  constexpr friend bool operator!=(gap_decorator_iterator const & lhs, gap_decorator_iterator const & rhs)
855  noexcept
856  {
857  return lhs.pos != rhs.pos;
858  }
859 
861  constexpr friend bool operator<(gap_decorator_iterator const & lhs, gap_decorator_iterator const & rhs)
862  noexcept
863  {
864  return lhs.pos < rhs.pos;
865  }
866 
868  constexpr friend bool operator>(gap_decorator_iterator const & lhs, gap_decorator_iterator const & rhs)
869  noexcept
870  {
871  return lhs.pos > rhs.pos;
872  }
873 
875  constexpr friend bool operator<=(gap_decorator_iterator const & lhs, gap_decorator_iterator const & rhs)
876  noexcept
877  {
878  return lhs.pos <= rhs.pos;
879  }
880 
882  constexpr friend bool operator>=(gap_decorator_iterator const & lhs, gap_decorator_iterator const & rhs)
883  noexcept
884  {
885  return lhs.pos >= rhs.pos;
886  }
888 };
889 
890 } // namespace seqan
891 
892 namespace seqan3::detail
893 {
894 
896 template <typename type>
897 constexpr int enable_view<seqan3::gap_decorator<type>> = 0;
898 
899 template <typename type>
900 constexpr int enable_view<seqan3::gap_decorator<type> const> = 0;
901 
902 } // namespace seqan3::detail
seqan3::gap_decorator::gap_decorator_iterator::operator>=
constexpr friend bool operator>=(gap_decorator_iterator const &lhs, gap_decorator_iterator const &rhs) noexcept
Checks whether *this is greater than or equal to rhs.
Definition: gap_decorator.hpp:882
seqan3::difference_type_t
typename difference_type< t >::type difference_type_t
Shortcut for seqan3::difference_type (transformation_trait shortcut).
Definition: pre.hpp:166
seqan3::gap_decorator::cbegin
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition: gap_decorator.hpp:323
seqan3::gap
The alphabet of a gap character '-'.
Definition: gap.hpp:36
seqan3::erase_gap
aligned_seq_t::iterator erase_gap(aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it)
An implementation of seqan3::aligned_sequence::erase_gap for sequence containers.
Definition: aligned_sequence_concept.hpp:304
seqan3::gap_decorator::value_type
gapped< value_type_t< inner_type > > value_type
The variant type of the alphabet type and gap symbol type (see seqan3::gapped).
Definition: gap_decorator.hpp:101
seqan3::gap_decorator::operator>
friend bool operator>(gap_decorator const &lhs, gap_decorator const &rhs) noexcept
Checks whether lhs is greater than rhs.
Definition: gap_decorator.hpp:473
seqan3::gap_decorator::operator[]
constexpr reference operator[](size_type const i) const noexcept
Return the i-th element as a reference.
Definition: gap_decorator.hpp:394
seqan3::gap_decorator::gap_decorator_iterator::operator++
constexpr gap_decorator_iterator operator++(int) noexcept
Returns an incremented iterator copy.
Definition: gap_decorator.hpp:731
seqan3::field::offset
Sequence (SEQ) relative start position (0-based), unsigned value.
std::pair
seqan3::gap_erase_failure
Thrown in function seqan3::erase_gap, if a position does not contain a gap.
Definition: exception.hpp:23
seqan3::gap_decorator::size
size_type size() const noexcept
Returns the total length of the aligned sequence.
Definition: gap_decorator.hpp:155
seqan3::gap_decorator::unaligned_seq_type
inner_type unaligned_seq_type
The underlying ungapped range type.
Definition: gap_decorator.hpp:114
seqan3::gap_decorator::operator>=
friend bool operator>=(gap_decorator const &lhs, gap_decorator const &rhs) noexcept
Checks whether lhs is greater than or equal to rhs.
Definition: gap_decorator.hpp:479
std::bidirectional_iterator_tag
seqan3::gap_decorator::begin
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition: gap_decorator.hpp:317
seqan3::size_type_t
typename size_type< t >::type size_type_t
Shortcut for seqan3::size_type (transformation_trait shortcut).
Definition: pre.hpp:195
seqan3::gap_decorator::gap_decorator_iterator::operator>
constexpr friend bool operator>(gap_decorator_iterator const &lhs, gap_decorator_iterator const &rhs) noexcept
Checks whether *this is greater than rhs.
Definition: gap_decorator.hpp:868
concept.hpp
Adaptations of concepts from the standard library.
tuple
seqan3::gap_decorator::end
const_iterator end() const noexcept
Returns an iterator pointing behind the last element of the decorator.
Definition: gap_decorator.hpp:341
seqan3::views::type_reduce
constexpr auto type_reduce
A view adaptor that behaves like std::views::all, but type erases certain ranges.
Definition: type_reduce.hpp:158
exception.hpp
Includes customized exception types for the alignment module .
algorithm
Adaptations of algorithms from the Ranges TS.
seqan3::gap_decorator::gap_decorator_iterator::operator+=
constexpr gap_decorator_iterator & operator+=(difference_type const skip) noexcept
Advances iterator by skip many positions.
Definition: gap_decorator.hpp:739
seqan3::gap_decorator::at
const_reference at(size_type const i) const
Return the i-th element as a reference.
Definition: gap_decorator.hpp:376
seqan3::gap_decorator::gap_decorator_iterator::reference
typename gap_decorator::const_reference reference
The reference type.
Definition: gap_decorator.hpp:657
seqan3::alphabet_variant
A combined alphabet that can hold values of either of its alternatives.
Definition: alphabet_variant.hpp:129
same_as
The concept std::same_as<T, U> is satisfied if and only if T and U denote the same type.
seqan3::gap_decorator::gap_decorator_iterator::operator--
constexpr gap_decorator_iterator & operator--() noexcept
Decrements iterator.
Definition: gap_decorator.hpp:759
seqan3::gap_decorator::gap_decorator_iterator::operator-=
constexpr gap_decorator_iterator & operator-=(difference_type const skip) noexcept
Advances iterator by skip many positions.
Definition: gap_decorator.hpp:799
seqan3::gap_decorator::operator<=
friend bool operator<=(gap_decorator const &lhs, gap_decorator const &rhs) noexcept
Checks whether lhs is less than or equal to rhs.
Definition: gap_decorator.hpp:456
seqan3::gap_decorator::gap_decorator_iterator::operator<
constexpr friend bool operator<(gap_decorator_iterator const &lhs, gap_decorator_iterator const &rhs) noexcept
Checks whether *this is less than rhs.
Definition: gap_decorator.hpp:861
random_access_iterator.hpp
Provides the seqan3::detail::random_access_iterator class.
seqan3::gap_decorator::gap_decorator_iterator::operator<=
constexpr friend bool operator<=(gap_decorator_iterator const &lhs, gap_decorator_iterator const &rhs) noexcept
Checks whether *this is less than or equal to rhs.
Definition: gap_decorator.hpp:875
seqan3::gap_decorator::gap_decorator_iterator::pointer
value_type * pointer
The pointer type.
Definition: gap_decorator.hpp:659
std::add_pointer_t
seqan3::gap_decorator::erase_gap
iterator erase_gap(const_iterator const it)
Erase one gap symbol at the indicated iterator postion.
Definition: gap_decorator.hpp:227
gapped.hpp
Provides seqan3::gapped.
seqan3::gap_decorator::gap_decorator_iterator::gap_decorator_iterator
constexpr gap_decorator_iterator(gap_decorator const &host_, typename gap_decorator::size_type const pos_) noexcept
Construct from seqan3::gap_decorator and explicit position.
Definition: gap_decorator.hpp:691
seqan3::gap_decorator::gap_decorator_iterator::operator--
constexpr gap_decorator_iterator operator--(int) noexcept
Returns a decremented iterator copy.
Definition: gap_decorator.hpp:791
type_reduce.hpp
Provides seqan3::views::type_reduce.
seqan3::gap_decorator::gap_decorator_iterator::operator+
constexpr gap_decorator_iterator operator+(difference_type const skip) const noexcept
Returns an iterator copy advanced by skip many positions.
Definition: gap_decorator.hpp:746
seqan3::gap_decorator::at
reference at(size_type const i)
Return the i-th element as a reference.
Definition: gap_decorator.hpp:368
std::to_string
T to_string(T... args)
seqan3::gap_decorator::gap_decorator
gap_decorator(other_range_t &&range)
Construct with the ungapped range type.
Definition: gap_decorator.hpp:140
gap.hpp
Provides seqan3::gap.
seqan3::gap_decorator::operator!=
friend bool operator!=(gap_decorator const &lhs, gap_decorator const &rhs) noexcept
Checks whether lhs is not equal to rhs.
Definition: gap_decorator.hpp:433
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
assignable_from
The concept std::assignable_from<LHS, RHS> specifies that an expression of the type and value categor...
seqan3::gap_decorator::gap_decorator_iterator::operator-
constexpr friend gap_decorator_iterator operator-(difference_type const skip, gap_decorator_iterator const &it) noexcept
Returns an iterator copy advanced by skip many positions.
Definition: gap_decorator.hpp:812
seqan3::gap_decorator::size_type
size_type_t< inner_type > size_type
The size_type of the underlying sequence.
Definition: gap_decorator.hpp:108
seqan3::gap_decorator::gap_decorator_iterator::value_type
typename gap_decorator::value_type value_type
The value type.
Definition: gap_decorator.hpp:655
seqan3::gap_decorator::gap_decorator_iterator::jump
void jump(typename gap_decorator::size_type const new_pos)
A helper function that performs the random access into the anchor set, updating all member variables.
Definition: gap_decorator.hpp:621
seqan3::gap_decorator::gap_decorator_iterator::gap_decorator_iterator
constexpr gap_decorator_iterator(gap_decorator const &host_) noexcept
Construct from seqan3::gap_decorator and initialising to first position.
Definition: gap_decorator.hpp:675
seqan3::pack_traits::size
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:116
ranges
Adaptations of concepts from the Ranges TS.
seqan3::gap_decorator::difference_type
difference_type_t< inner_type > difference_type
The difference type of the underlying sequence.
Definition: gap_decorator.hpp:110
limits
seqan3::gap_decorator::erase_gap
iterator erase_gap(const_iterator const first, const_iterator const last)
Erase gap symbols at the iterator postions [first, last[.
Definition: gap_decorator.hpp:249
seqan3::gap_decorator::insert_gap
iterator insert_gap(const_iterator const it, size_type const count=1)
Insert a gap of length count at the aligned sequence iterator position.
Definition: gap_decorator.hpp:176
std::remove_cv_t
std::out_of_range
seqan3::gap_decorator::gap_decorator_iterator
The iterator type over a seqan3::gap_decorator.
Definition: gap_decorator.hpp:602
seqan3::gap_decorator::operator<
friend bool operator<(gap_decorator const &lhs, gap_decorator const &rhs) noexcept
Checks whether lhs is less than rhs.
Definition: gap_decorator.hpp:439
seqan3::gap_decorator::assign_unaligned
friend void assign_unaligned(gap_decorator &dec, unaligned_seq_t &&unaligned)
Assigns a new sequence of type seqan3::gap_decorator::unaligned_seq_type to the decorator.
Definition: gap_decorator.hpp:295
seqan3::gap_decorator
A gap decorator allows the annotation of sequences with gap symbols while leaving the underlying sequ...
Definition: gap_decorator.hpp:84
std::numeric_limits::max
T max(T... args)
seqan3::gap_decorator::gap_decorator_iterator::operator-
constexpr gap_decorator_iterator operator-(difference_type const skip) const noexcept
Returns an iterator copy advanced by skip many positions.
Definition: gap_decorator.hpp:806
seqan3::gap_decorator::gap_decorator_iterator::difference_type
typename gap_decorator::difference_type difference_type
The difference type.
Definition: gap_decorator.hpp:653
std::prev
T prev(T... args)
inherited_iterator_base.hpp
Provides the seqan3::detail::inherited_iterator_base template.
seqan3::gap_decorator::gap_decorator_iterator::operator-
constexpr difference_type operator-(gap_decorator_iterator const lhs) const noexcept
Returns the distance between two iterators.
Definition: gap_decorator.hpp:819
seqan3::gap_decorator::gap_decorator_iterator::operator!=
constexpr friend bool operator!=(gap_decorator_iterator const &lhs, gap_decorator_iterator const &rhs) noexcept
Checks whether *this is not equal to rhs.
Definition: gap_decorator.hpp:854
set
concept.hpp
Core alphabet concept and free function/type trait wrappers.
seqan3::pack_traits::count
constexpr ptrdiff_t count
Count the occurrences of a type in a pack.
Definition: traits.hpp:134
seqan3::gap_decorator::cend
const_iterator cend() const noexcept
Returns an iterator pointing behind the last element of the decorator.
Definition: gap_decorator.hpp:347
seqan3::gap_decorator
gap_decorator(urng_t &&range) -> gap_decorator< std::remove_reference_t< urng_t > const & >
Ranges (not views!) always deduce to const & range_type since they are access-only anyway.
std::next
T next(T... args)
seqan3::gap_decorator::gap_decorator_iterator::operator+
constexpr friend gap_decorator_iterator operator+(difference_type const skip, gap_decorator_iterator const &it) noexcept
Returns an iterator copy advanced by skip many positions.
Definition: gap_decorator.hpp:752
seqan3::gap_decorator::gap_decorator_iterator::operator[]
constexpr reference operator[](difference_type const n) const noexcept
Return underlying container value currently pointed at.
Definition: gap_decorator.hpp:835
seqan3::gap_decorator::const_reference
reference const_reference
const_reference type equals reference type equals value type because the underlying sequence must not...
Definition: gap_decorator.hpp:106