19 #include <range/v3/algorithm/for_each.hpp> 39 template <
template <
typename...>
typename container_type,
typename seq_alph_t,
typename ...rest_t>
41 requires Container<container_type<gapped<seq_alph_t>, rest_t...>>
43 constexpr
auto remove_gap_from_value_type(container_type<gapped<seq_alph_t>, rest_t...>)
44 -> container_type<seq_alph_t, rest_t...>;
47 template <
template <
typename...>
typename container_type,
48 template <
typename...>
typename allocator_type,
49 typename seq_alph_t,
typename ...rest_t>
51 requires Container<container_type<gapped<seq_alph_t>, allocator_type<gapped<seq_alph_t>>, rest_t...>>
53 constexpr
auto remove_gap_from_value_type(container_type<gapped<seq_alph_t>, allocator_type<gapped<seq_alph_t>>, rest_t...>)
54 -> container_type<seq_alph_t, allocator_type<seq_alph_t>, rest_t...>;
65 requires { remove_gap_from_value_type(std::declval<t>()); }
67 struct unaligned_seq<t>
70 using type = decltype(remove_gap_from_value_type(std::declval<t>()));
79 struct unaligned_seq<t>
86 using unaligned_seq_t =
typename unaligned_seq<t>::type;
186 template <
typename t>
189 SEQAN3_CONCEPT AlignedSequence =
191 Alphabet<reference_t<t>> &&
192 WeaklyAssignable<reference_t<t>, gap
const &> &&
193 requires {
typename detail::unaligned_seq_t<t>; } &&
194 requires (t v, detail::unaligned_seq_t<t> unaligned)
196 {
insert_gap(v, v.begin()) } ->
typename t::iterator;
197 {
insert_gap(v, v.begin(), 2) } ->
typename t::iterator;
198 {
erase_gap(v, v.begin()) } ->
typename t::iterator;
199 {
erase_gap(v, v.begin(), v.end()) } ->
typename t::iterator;
225 template <SequenceContainer aligned_seq_t>
227 requires detail::is_gapped_alphabet<value_type_t<aligned_seq_t>>
229 inline typename aligned_seq_t::iterator
insert_gap(aligned_seq_t & aligned_seq,
230 typename aligned_seq_t::const_iterator pos_it)
248 template <SequenceContainer aligned_seq_t>
250 requires detail::is_gapped_alphabet<value_type_t<aligned_seq_t>>
252 inline typename aligned_seq_t::iterator
insert_gap(aligned_seq_t & aligned_seq,
253 typename aligned_seq_t::const_iterator pos_it,
254 typename aligned_seq_t::size_type
size)
274 template <SequenceContainer aligned_seq_t>
276 requires detail::is_gapped_alphabet<value_type_t<aligned_seq_t>>
278 inline typename aligned_seq_t::iterator
erase_gap(aligned_seq_t & aligned_seq,
279 typename aligned_seq_t::const_iterator pos_it)
281 if (*pos_it !=
gap{})
284 return aligned_seq.erase(pos_it);
303 template <SequenceContainer aligned_seq_t>
305 requires detail::is_gapped_alphabet<value_type_t<aligned_seq_t>>
307 inline typename aligned_seq_t::iterator
erase_gap(aligned_seq_t & aligned_seq,
308 typename aligned_seq_t::const_iterator first,
309 typename aligned_seq_t::const_iterator last)
311 for (
auto it = first; it != last; ++it)
313 throw gap_erase_failure(
"The range to be erased contains at least one non-gap character.");
315 return aligned_seq.erase(first, last);
340 template <SequenceContainer aligned_seq_t, std::ranges::ForwardRange unaligned_sequence_type>
342 requires detail::is_gapped_alphabet<value_type_t<aligned_seq_t>> &&
343 WeaklyAssignable<reference_t<aligned_seq_t>, reference_t<unaligned_sequence_type>>
345 inline void assign_unaligned(aligned_seq_t & aligned_seq, unaligned_sequence_type && unaligned_seq)
351 swap(aligned_seq, tmp);
372 template <
typename range_type>
374 requires requires (range_type v)
376 v.insert_gap(
typename range_type::iterator{});
377 v.insert_gap(
typename range_type::iterator{},
typename range_type::size_type{});
381 typename range_type::iterator
const it,
382 typename range_type::size_type
const size = 1)
384 return rng.insert_gap(it,
size);
399 template <
typename range_type>
401 requires requires (range_type v) { v.erase_gap(
typename range_type::iterator{}); }
403 typename range_type::iterator
erase_gap(range_type & rng,
404 typename range_type::iterator
const it)
406 return rng.erase_gap(it);
423 template <
typename range_type>
425 requires requires (range_type v) { v.erase_gap(
typename range_type::iterator{},
typename range_type::iterator{}); }
427 typename range_type::iterator
erase_gap(range_type & rng,
428 typename range_type::iterator
const first,
429 typename range_type::iterator
const last)
431 return rng.erase_gap(first, last);
445 template<TupleLike alignment_t,
size_t ...idx>
449 size_t const alignment_size = get<0>(align).
size();
452 for (
size_t begin_pos = 0; begin_pos < alignment_size; begin_pos += 50)
454 size_t const end_pos =
std::min(begin_pos + 50, alignment_size);
460 stream <<
std::setw(7) << begin_pos <<
' ';
461 for (
size_t pos = begin_pos + 1; pos <= end_pos; ++pos)
465 else if (pos % 5 == 0)
474 [&stream] (
char ch) { stream << ch; });
476 auto stream_f = [&] (
auto const & previous_seq,
auto const & aligned_seq)
480 ranges::for_each(ranges::zip_view(previous_seq, aligned_seq) |
view::slice(begin_pos, end_pos),
481 [&stream] (
auto && ch) { stream << (get<0>(ch) == get<1>(ch) ?
'|' :
' '); });
486 [&stream] (
char ch) { stream << ch; });
488 (stream_f(get<idx>(align), get<idx + 1>(align)), ...);
496 template <
typename ...elems>
497 inline bool constexpr all_satisfy_aligned_seq =
false;
502 template <
typename ...elems>
503 inline bool constexpr all_satisfy_aligned_seq<
type_list<elems...>> = (AlignedSequence<elems> && ...);
514 template <TupleLike tuple_t>
516 requires detail::all_satisfy_aligned_seq<detail::tuple_type_list_t<tuple_t>>
520 static_assert(std::tuple_size_v<tuple_t> >= 2,
"An alignment requires at least two sequences.");
::ranges::distance distance
Alias for ranges::distance. Returns the number of hops from first to last.
Definition: iterator:321
void assign_unaligned(aligned_seq_t &aligned_seq, unaligned_sequence_type &&unaligned_seq)
An implementation of seqan3::AlignedSequence::assign_unaligned_sequence for sequence containers...
Definition: aligned_sequence_concept.hpp:345
typename value_type< t >::type value_type_t
Shortcut for seqan3::value_type (TransformationTrait shortcut).
Definition: pre.hpp:48
aligned_seq_t::iterator insert_gap(aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it)
An implementation of seqan3::AlignedSequence::insert_gap for sequence containers. ...
Definition: aligned_sequence_concept.hpp:229
The alphabet of a gap character '-'.
Definition: gap.hpp:36
::ranges::size size
Alias for ranges::size. Obtains the size of a range whose size can be calculated in constant time...
Definition: ranges:189
The main SeqAn3 namespace.
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition: slice.hpp:144
debug_stream_type & operator<<(debug_stream_type &stream, tuple_t const &alignment)
Streaming operator for alignments, which are represented as tuples of aligned sequences.
Definition: aligned_sequence_concept.hpp:518
Provides various type traits.
Provides seqan3::TupleLike.
Adaptations of concepts from the Ranges TS.
::ranges::begin begin
Alias for ranges::begin. Returns an iterator to the beginning of a range.
Definition: ranges:174
Meta-header for the gap submodule; includes all headers from alphabet/gap/.
auto const to_char
A view that calls seqan3::to_char() on each element in the input range.
Definition: to_char.hpp:66
Thrown in function seqan3::erase_gap, if a position does not contain a gap.
Definition: exception.hpp:23
Definition: aligned_sequence_concept.hpp:35
auto const get
A view calling std::get on each element in a range.
Definition: get.hpp:66
aligned_seq_t::iterator erase_gap(aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it)
An implementation of seqan3::AlignedSequence::erase_gap for sequence containers.
Definition: aligned_sequence_concept.hpp:278
Provides seqan3::view::slice.
meta::list< types... > type_list
Type that contains multiple types, an alias for meta::list.
Definition: type_list.hpp:27
Provides seqan3::view::to_char.
Includes customized exception types for the alignment module .
Specifies requirements of a Range type for which begin returns a type that models std::ForwardIterato...
A "pretty printer" for most SeqAn data structures and related types.
Definition: debug_stream.hpp:78
Adaptations of concepts from the standard library.
::ranges::end end
Alias for ranges::end. Returns an iterator to the end of a range.
Definition: ranges:179
Provides seqan3::debug_stream and related types.