74template <std::ranges::viewable_range inner_type>
75 requires std::ranges::random_access_range<inner_type> && std::ranges::sized_range<inner_type>
76 && (std::is_const_v<std::remove_reference_t<inner_type>> || std::ranges::view<inner_type>)
81 template <
bool = true>
88 using const_iterator = iterator;
91 using ungapped_view_type =
decltype(views::type_reduce(std::declval<inner_type &&>()));
120 using size_type = std::ranges::range_size_t<inner_type>;
156 template <
typename other_range_t>
157 requires (!std::same_as<other_range_t, gap_decorator>)
159 && std::ranges::viewable_range<other_range_t>
181 return anchors.rbegin()->second + ungapped_view.size();
183 return ungapped_view.size();
209 set_iterator_type
it_set = anchors.upper_bound(anchor_gap_t{pos, bound_dummy});
211 if (
it_set == anchors.begin())
213 anchors.emplace_hint(anchors.begin(), anchor_gap_t{pos, count});
219 if (
it_set != anchors.begin())
230 anchor_gap_t
gap{pos,
it_set->second + count};
238 return iterator{*
this, pos};
258 throw gap_erase_failure(
"The range to be erased does not correspond to a consecutive gap.");
278 iterator
erase_gap(const_iterator
const first, const_iterator
const last)
282 set_iterator_type
it = anchors.upper_bound(anchor_gap_t{
pos1, bound_dummy});
284 if (
it == anchors.begin())
294 throw gap_erase_failure{
"The range to be erased does not correspond to a consecutive gap."};
299 it = anchors.erase(
it);
305 it = anchors.erase(
it);
313 return iterator{*
this,
pos1};
278 iterator
erase_gap(const_iterator
const first, const_iterator
const last) {
…}
323 template <
typename unaligned_sequence_t>
324 requires std::assignable_from<gap_decorator &, unaligned_sequence_t>
351 return iterator{*
this};
357 return const_iterator{*
this};
377 return iterator{*
this, size()};
383 return const_iterator{*
this, size()};
407 throw std::out_of_range{
"Trying to access element behind the last in gap_decorator."};
415 throw std::out_of_range{
"Trying to access element behind the last in gap_decorator."};
433 return *iterator{*
this,
i};
462 if (
lhs.size() ==
rhs.size() &&
lhs.anchors ==
rhs.anchors
494 else if (
lit ==
lhs.end())
514 else if (
rit ==
rhs.end())
547 using set_iterator_type =
typename anchor_set_type::iterator;
564 size_type gap_length(set_iterator_type it)
const
566 return (it == anchors.begin()) ? it->second : it->second - (*
std::prev(it)).second;
581 void rupdate(size_type
const pos, size_type
const offset)
583 for (
auto it =
std::prev(anchors.end(), 1); it->first > pos;)
585 anchors.emplace_hint(it, anchor_gap_t{it->first +
offset, it->second +
offset});
586 anchors.erase(*it--);
602 void update(set_iterator_type it, size_type
const offset)
604 while (it != anchors.end())
606 anchor_gap_t gap{it->first -
offset, it->second -
offset};
607 it = anchors.erase(it);
608 it = anchors.insert(it, gap);
614 ungapped_view_type ungapped_view{};
617 anchor_set_type anchors{};
627template <std::ranges::viewable_range urng_t>
628 requires (!std::ranges::view<std::remove_reference_t<urng_t>>)
635template <std::ranges::view urng_t>
655template <std::ranges::viewable_range inner_type>
656 requires std::ranges::random_access_range<inner_type> && std::ranges::sized_range<inner_type>
657 && (std::is_const_v<std::remove_reference_t<inner_type>> || std::ranges::view<inner_type>)
667 int64_t ungapped_view_pos{0};
673 typename gap_decorator::set_iterator_type anchor_set_it{};
675 bool is_at_gap{
true};
683 anchor_set_it = host->anchors.upper_bound(anchor_gap_t{pos, host->bound_dummy});
684 ungapped_view_pos = pos;
686 if (anchor_set_it != host->anchors.begin())
688 typename gap_decorator::set_iterator_type prev{
std::prev(anchor_set_it)};
689 size_type
gap_len{prev->second};
691 if (prev != host->anchors.begin())
694 ungapped_view_pos -= prev->second;
695 left_gap_end = prev->first +
gap_len;
698 if (ungapped_view_pos !=
static_cast<int64_t
>(host->ungapped_view.size()) && pos >= left_gap_end
716 using pointer = value_type *;
724 basic_iterator() =
default;
725 basic_iterator(basic_iterator
const &) =
default;
726 basic_iterator & operator=(basic_iterator
const &) =
default;
727 basic_iterator(basic_iterator &&) =
default;
728 basic_iterator & operator=(basic_iterator &&) =
default;
729 ~basic_iterator() =
default;
734 if (
host_.anchors.size() && (*
host_.anchors.begin()).first == 0)
737 left_gap_end = anchor_set_it->second;
757 basic_iterator & operator++()
762 if (pos < left_gap_end)
768 if (ungapped_view_pos !=
static_cast<int64_t
>(host->ungapped_view.size()))
773 left_gap_end = anchor_set_it->first + anchor_set_it->second
774 - ((anchor_set_it != host->anchors.begin()) ? (
std::prev(anchor_set_it))->second : 0);
778 if (left_gap_end == host->size())
786 basic_iterator operator++(
int)
788 basic_iterator
cpy{*
this};
794 basic_iterator & operator+=(difference_type
const skip)
796 this->jump(this->pos +
skip);
801 basic_iterator operator+(difference_type
const skip)
const
803 return basic_iterator{*(this->host), this->pos +
skip};
807 friend basic_iterator operator+(difference_type
const skip, basic_iterator
const &
it)
813 basic_iterator & operator--()
818 if (pos < left_gap_end)
820 (anchor_set_it != host->anchors.begin()) ? --anchor_set_it : anchor_set_it;
822 if (anchor_set_it != host->anchors.begin())
826 prev->first + prev->second - ((prev != host->anchors.begin()) ?
std::prev(prev)->second : 0);
834 else if (anchor_set_it == host->anchors.end() || pos < anchor_set_it->first)
845 basic_iterator operator--(
int)
847 basic_iterator
cpy{*
this};
853 basic_iterator & operator-=(difference_type
const skip)
855 this->jump(this->pos -
skip);
860 basic_iterator operator-(difference_type
const skip)
const
862 return basic_iterator{*(this->host), this->pos -
skip};
866 friend basic_iterator operator-(difference_type
const skip, basic_iterator
const &
it)
872 difference_type operator-(basic_iterator
const lhs)
const noexcept
874 return static_cast<difference_type
>(this->pos -
lhs.pos);
882 reference operator*()
const
884 return (is_at_gap) ? reference{
gap{}} : reference{host->ungapped_view[ungapped_view_pos]};
888 reference operator[](difference_type
const n)
const
900 friend bool operator==(basic_iterator
const &
lhs, basic_iterator
const &
rhs)
noexcept
902 return lhs.pos ==
rhs.pos;
906 friend bool operator!=(basic_iterator
const &
lhs, basic_iterator
const &
rhs)
noexcept
908 return lhs.pos !=
rhs.pos;
912 friend bool operator<(basic_iterator
const &
lhs, basic_iterator
const &
rhs)
noexcept
918 friend bool operator>(basic_iterator
const &
lhs, basic_iterator
const &
rhs)
noexcept
924 friend bool operator<=(basic_iterator
const &
lhs, basic_iterator
const &
rhs)
noexcept
926 return lhs.pos <=
rhs.pos;
930 friend bool operator>=(basic_iterator
const &
lhs, basic_iterator
const &
rhs)
noexcept
932 return lhs.pos >=
rhs.pos;
Includes customized exception types for the alignment module .
Core alphabet concept and free function/type trait wrappers.
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
A gap decorator allows the annotation of sequences with gap symbols while leaving the underlying sequ...
Definition gap_decorator.hpp:78
reference at(size_type const i)
Return the i-th element as a reference.
Definition gap_decorator.hpp:404
friend bool operator==(gap_decorator const &lhs, gap_decorator const &rhs)
Checks whether lhs is equal to rhs.
Definition gap_decorator.hpp:460
friend void assign_unaligned(gap_decorator &dec, unaligned_sequence_t &&unaligned)
Assigns a new sequence of type seqan3::gap_decorator::unaligned_sequence_type to the decorator.
Definition gap_decorator.hpp:325
gap_decorator & operator=(gap_decorator const &)=default
Defaulted.
gap_decorator(gap_decorator &&rhs)=default
Defaulted.
const_reference at(size_type const i) const
Return the i-th element as a reference.
Definition gap_decorator.hpp:412
std::ranges::range_difference_t< inner_type > difference_type
The difference type of the underlying sequence.
Definition gap_decorator.hpp:126
const_iterator cend() const noexcept
Returns an iterator pointing behind the last element of the decorator.
Definition gap_decorator.hpp:381
const_iterator end() const noexcept
Returns an iterator pointing behind the last element of the decorator.
Definition gap_decorator.hpp:375
reference operator[](size_type const i) const
Return the i-th element as a reference.
Definition gap_decorator.hpp:431
friend bool operator!=(gap_decorator const &lhs, gap_decorator const &rhs)
Checks whether lhs is not equal to rhs.
Definition gap_decorator.hpp:475
iterator erase_gap(const_iterator const it)
Erase one gap symbol at the indicated iterator postion.
Definition gap_decorator.hpp:254
gap_decorator(other_range_t &&range)
Construct with the ungapped range type.
Definition gap_decorator.hpp:160
const_iterator begin() const noexcept
Returns an iterator to the first element of the container.
Definition gap_decorator.hpp:349
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:201
~gap_decorator()=default
Defaulted.
iterator erase_gap(const_iterator const first, const_iterator const last)
Erase gap symbols at the iterator postions [first, last[.
Definition gap_decorator.hpp:278
gap_decorator(gap_decorator const &)=default
Defaulted.
friend bool operator<=(gap_decorator const &lhs, gap_decorator const &rhs)
Checks whether lhs is less than or equal to rhs.
Definition gap_decorator.hpp:504
size_type size() const
Returns the total length of the aligned sequence.
Definition gap_decorator.hpp:178
reference const_reference
const_reference type equals reference type equals value type because the underlying sequence must not...
Definition gap_decorator.hpp:114
gap_decorator & operator=(gap_decorator &&rhs)=default
Defaulted.
gapped< std::ranges::range_value_t< inner_type > > value_type
The variant type of the alphabet type and gap symbol type (see seqan3::gapped).
Definition gap_decorator.hpp:101
friend bool operator>(gap_decorator const &lhs, gap_decorator const &rhs)
Checks whether lhs is greater than rhs.
Definition gap_decorator.hpp:524
friend bool operator>=(gap_decorator const &lhs, gap_decorator const &rhs)
Checks whether lhs is greater than or equal to rhs.
Definition gap_decorator.hpp:533
gap_decorator()=default
Default constructor.
friend bool operator<(gap_decorator const &lhs, gap_decorator const &rhs)
Checks whether lhs is less than rhs.
Definition gap_decorator.hpp:484
std::ranges::range_size_t< inner_type > size_type
The size_type of the underlying sequence.
Definition gap_decorator.hpp:120
const_iterator cbegin() const noexcept
Returns an iterator to the first element of the container.
Definition gap_decorator.hpp:355
Thrown in function seqan3::erase_gap, if a position does not contain a gap.
Definition alignment/exception.hpp:21
The alphabet of a gap character '-'.
Definition gap.hpp:36
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides seqan3::views::type_reduce.