SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
|
A gap decorator allows the annotation of sequences with gap symbols while leaving the underlying sequence unmodified. More...
#include <seqan3/alignment/decorator/gap_decorator.hpp>
Public Types | |
using | unaligned_sequence_type = inner_type |
The underlying ungapped range type. | |
Range-associated member types | |
using | value_type = gapped< std::ranges::range_value_t< inner_type > > |
The variant type of the alphabet type and gap symbol type (see seqan3::gapped). | |
using | reference = value_type |
Use the value type as reference type because the underlying sequence must not be modified. | |
using | const_reference = reference |
const_reference type equals reference type equals value type because the underlying sequence must not be modified. | |
using | size_type = std::ranges::range_size_t< inner_type > |
The size_type of the underlying sequence. | |
using | difference_type = std::ranges::range_difference_t< inner_type > |
The difference type of the underlying sequence. | |
Public Member Functions | |
Constructors, destructor and assignment | |
gap_decorator ()=default | |
Default constructor. | |
gap_decorator (gap_decorator const &)=default | |
Defaulted. | |
gap_decorator & | operator= (gap_decorator const &)=default |
Defaulted. | |
gap_decorator (gap_decorator &&rhs)=default | |
Defaulted. | |
gap_decorator & | operator= (gap_decorator &&rhs)=default |
Defaulted. | |
~gap_decorator ()=default | |
Defaulted. | |
template<typename other_range_t > requires (!std::same_as<other_range_t, gap_decorator>) && std::same_as<std::remove_cvref_t<other_range_t>, std::remove_cvref_t<inner_type>> && std::ranges::viewable_range<other_range_t> | |
gap_decorator (other_range_t &&range) | |
Construct with the ungapped range type. | |
size_type | size () const |
Returns the total length of the aligned sequence. | |
Iterators | |
const_iterator | begin () const noexcept |
Returns an iterator to the first element of the container. | |
const_iterator | cbegin () const noexcept |
Returns an iterator to the first element of the container. | |
const_iterator | end () const noexcept |
Returns an iterator pointing behind the last element of the decorator. | |
const_iterator | cend () const noexcept |
Returns an iterator pointing behind the last element of the decorator. | |
Element access | |
reference | at (size_type const i) |
Return the i-th element as a reference. | |
const_reference | at (size_type const i) const |
Return the i-th element as a reference. | |
reference | operator[] (size_type const i) const |
Return the i-th element as a reference. | |
Friends | |||||||
Comparison operators | |||||||
Compares two seqan3::gap_decorator 's by underlying sequence and gaps.
ComplexityWorst case: \(O(n*\log k)\) Constant in case the decorators have not the same number of (consecutive) gaps. ExceptionsStrong exception guarantee. | |||||||
bool | operator== (gap_decorator const &lhs, gap_decorator const &rhs) | ||||||
Checks whether lhs is equal to rhs . | |||||||
bool | operator!= (gap_decorator const &lhs, gap_decorator const &rhs) | ||||||
Checks whether lhs is not equal to rhs . | |||||||
bool | operator< (gap_decorator const &lhs, gap_decorator const &rhs) | ||||||
Checks whether lhs is less than rhs . | |||||||
bool | operator<= (gap_decorator const &lhs, gap_decorator const &rhs) | ||||||
Checks whether lhs is less than or equal to rhs . | |||||||
bool | operator> (gap_decorator const &lhs, gap_decorator const &rhs) | ||||||
Checks whether lhs is greater than rhs . | |||||||
bool | operator>= (gap_decorator const &lhs, gap_decorator const &rhs) | ||||||
Checks whether lhs is greater than or equal to rhs . | |||||||
Aligned sequence modifications | |
iterator | insert_gap (const_iterator const it, size_type const count=1) |
Insert a gap of length count at the aligned sequence iterator position. | |
iterator | erase_gap (const_iterator const it) |
Erase one gap symbol at the indicated iterator postion. | |
iterator | erase_gap (const_iterator const first, const_iterator const last) |
Erase gap symbols at the iterator postions [first, last[. | |
template<typename unaligned_sequence_t > requires std::assignable_from<gap_decorator &, unaligned_sequence_t> | |
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. | |
Additional Inherited Members | |
Related Symbols inherited from writable_aligned_sequence | |
std::ranges::iterator_t< aligned_seq_t > | insert_gap (aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it) |
Insert a seqan3::gap into an aligned sequence. | |
std::ranges::iterator_t< aligned_seq_t > | insert_gap (aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it, typename aligned_seq_t::size_type size) |
Insert multiple seqan3::gap into an aligned sequence. | |
std::ranges::iterator_t< aligned_seq_t > | erase_gap (aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it) |
Erase a seqan3::gap from an aligned sequence. | |
std::ranges::iterator_t< aligned_seq_t > | erase_gap (aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator first, typename aligned_seq_t::const_iterator last) |
Erase multiple seqan3::gap from an aligned sequence. | |
void | assign_unaligned (aligned_seq_t &aligned_seq, unaligned_sequence_type &&unaligned_seq) |
Assign an ungapped sequence to a gapped sequence. | |
template<sequence_container aligned_seq_t> | |
aligned_seq_t::iterator | insert_gap (aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it) |
An implementation of seqan3::writable_aligned_sequence::insert_gap for sequence containers. | |
template<sequence_container aligned_seq_t> | |
aligned_seq_t::iterator | insert_gap (aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it, typename aligned_seq_t::size_type size) |
An implementation of seqan3::writable_aligned_sequence::insert_gap for sequence containers. | |
template<sequence_container aligned_seq_t> | |
aligned_seq_t::iterator | erase_gap (aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it) |
An implementation of seqan3::writable_aligned_sequence::erase_gap for sequence containers. | |
template<sequence_container aligned_seq_t> | |
aligned_seq_t::iterator | erase_gap (aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator first, typename aligned_seq_t::const_iterator last) |
An implementation of seqan3::writable_aligned_sequence::erase_gap for sequence containers. | |
template<sequence_container aligned_seq_t, std::ranges::forward_range unaligned_sequence_type> | |
void | assign_unaligned (aligned_seq_t &aligned_seq, unaligned_sequence_type &&unaligned_seq) |
An implementation of seqan3::writable_aligned_sequence::assign_unaligned_sequence for sequence containers. | |
template<typename range_type > | |
std::ranges::iterator_t< range_type > | insert_gap (range_type &rng, std::ranges::iterator_t< range_type > const pos_it, typename range_type::size_type const size=1) |
An implementation of seqan3::writable_aligned_sequence::insert_gap for ranges with the corresponding member function insert_gap(it, size). | |
template<typename range_type > | |
std::ranges::iterator_t< range_type > | erase_gap (range_type &rng, std::ranges::iterator_t< range_type > const pos_it) |
An implementation of seqan3::writable_aligned_sequence::erase_gap for ranges with the corresponding member function erase_gap(it). | |
template<typename range_type > | |
std::ranges::iterator_t< range_type > | erase_gap (range_type &rng, std::ranges::iterator_t< range_type > const first, std::ranges::iterator_t< range_type > const last) |
An implementation of seqan3::writable_aligned_sequence::erase_gap for ranges with the corresponding member function erase_gap(first, last). | |
A gap decorator allows the annotation of sequences with gap symbols while leaving the underlying sequence unmodified.
inner_type | The type of range that will be decorated with gaps; must model std::ranges::random_access_range and std::ranges::sized_range. |
This class may be used whenever you want to store or compute an alignment. The underlying (ungapped) sequence remains unmodified, and is augmented with gap information. The seqan3::gap_decorator behaves just like a vector over a gapped alphabet when iterating over it, inserting/erasing gaps or accessing a position. The only difference lies in the performance and size overhead (see below).
n The length of the underlying sequence. k The number of contiguous gaps (not gap symbols). l The total number of gap symbols.
access next | random access | gap insert/erase at end | gap insert/erase random | size overhead | |
---|---|---|---|---|---|
decorator | \(O(1)\) | \(O(\log(k))\) | \(O(\log(k))\) | \(O(k)\) | \(O(k)\) |
vector | \(O(1)\) | \(O(1)\) | \(O(1)\) | \(O(n)\) | \(O(n)\) |
The size overhead refers to the space that is needed when using each of the data structures in addition to an already existing ungapped sequence.
This decorator stores a std::set over tuples of (pos, cumulative_size)
where every entry represents one contiguous stretch of gaps. pos
is the (virtual) insert position in the underlying range and cumulative_size
is the length of that contiguous stretch of gaps plus the length of all preceding elements. Resolving random access requires logarithmic access into the set and inserting or removing a gap symbol additionally entails updating all subsequent elements in the set to preserve correct cumulative sizes.
using seqan3::gap_decorator< inner_type >::const_reference = reference |
const_reference type equals reference type equals value type because the underlying sequence must not be modified.
using seqan3::gap_decorator< inner_type >::difference_type = std::ranges::range_difference_t<inner_type> |
The difference type of the underlying sequence.
using seqan3::gap_decorator< inner_type >::reference = value_type |
Use the value type as reference type because the underlying sequence must not be modified.
using seqan3::gap_decorator< inner_type >::size_type = std::ranges::range_size_t<inner_type> |
The size_type of the underlying sequence.
using seqan3::gap_decorator< inner_type >::unaligned_sequence_type = inner_type |
The underlying ungapped range type.
using seqan3::gap_decorator< inner_type >::value_type = gapped<std::ranges::range_value_t<inner_type> > |
The variant type of the alphabet type and gap symbol type (see seqan3::gapped).
|
default |
Default constructor.
|
inline |
Construct with the ungapped range type.
|
inline |
Return the i-th element as a reference.
i | The element to retrieve. |
\(O(\log k)\) where \(k\) is the number of gaps.
Throws std::out_of_range exception if i
is out of range.
|
inline |
Return the i-th element as a reference.
i | The element to retrieve. |
\(O(\log k)\) where \(k\) is the number of gaps.
Throws std::out_of_range exception if i
is out of range.
|
inlinenoexcept |
Returns an iterator to the first element of the container.
If the container is empty, the returned iterator will be equal to end().
Constant.
No-throw guarantee.
|
inlinenoexcept |
Returns an iterator to the first element of the container.
If the container is empty, the returned iterator will be equal to end().
Constant.
No-throw guarantee.
|
inlinenoexcept |
Returns an iterator pointing behind the last element of the decorator.
Constant.
No-throw guarantee.
|
inlinenoexcept |
Returns an iterator pointing behind the last element of the decorator.
Constant.
No-throw guarantee.
|
inline |
Erase gap symbols at the iterator postions [first, last[.
[in] | first | The iterator pointing to the position where to start inserting gaps. |
[in] | last | The iterator pointing to the position where to stop erasing gaps. |
seqan3::gap_erase_failure | if [first , last [ does not correspond to a consecutive range of seqan3::gap 's. |
\(O(\log k)\)
|
inline |
Erase one gap symbol at the indicated iterator postion.
it | Iterator indicating the gap to be erased. |
seqan3::gap_erase_failure | if character is no seqan3::gap. |
\(O(\log k)\)
|
inline |
Insert a gap of length count at the aligned sequence iterator position.
it | Iterator indicating the gap start position in the aligned sequence. |
count | Number of gap symbols to be inserted. |
Average and worst case (insertion before last gap): \(O(k)\), Best case (back insertion): \(O(\log k)\).
|
inline |
Return the i-th element as a reference.
i | The element to retrieve. |
This function delegates to an iterator seqan3::gap_decorator.
\(O(\log k)\) where \(k\) is the number of gaps.
|
inline |
Returns the total length of the aligned sequence.
Constant.
Strong exception guarantee.
|
friend |
Assigns a new sequence of type seqan3::gap_decorator::unaligned_sequence_type to the decorator.
[in,out] | dec | The decorator to modify. |
[in] | unaligned | The unaligned sequence to assign. |
|
friend |
Checks whether lhs
is not equal to rhs
.
|
friend |
Checks whether lhs
is less than rhs
.
|
friend |
Checks whether lhs
is less than or equal to rhs
.
|
friend |
Checks whether lhs
is equal to rhs
.
|
friend |
Checks whether lhs
is greater than rhs
.
|
friend |
Checks whether lhs
is greater than or equal to rhs
.