113template <
typename alignment_type>
116 bool const extended_cigar =
false)
119 && std::tuple_size_v<std::remove_cvref_t<alignment_type>> == 2),
120 "The alignment must be a std::pair or std::tuple of size 2.");
123 (std::equality_comparable_with<gap, std::ranges::range_reference_t<decltype(std::get<0>(
alignment))>>
124 && std::equality_comparable_with<gap, std::ranges::range_reference_t<
decltype(std::get<1>(
alignment))>>),
125 "The alignment must contain two ranges whose value_type is comparable to seqan3::gap.");
161 auto to_cigar_op = [extended_cigar](
auto const reference_char,
auto const query_char)
173 uint8_t key = (
static_cast<uint8_t
>(reference_char == gap{}) << 1) |
static_cast<uint8_t
>(query_char == gap{});
177 if (extended_cigar && (key == 0))
178 key |= ((1 << 2) |
static_cast<uint8_t
>(query_char == reference_char));
188 if (
ref_seq.size() != query_seq.size())
189 throw std::logic_error{
"The aligned sequences (including gaps) must have the same length."};
191 if (std::ranges::empty(
ref_seq))
197 if (clipped_bases.hard_front)
198 result.
emplace_back(clipped_bases.hard_front,
'H'_cigar_operation);
201 if (clipped_bases.soft_front)
202 result.emplace_back(clipped_bases.soft_front,
'S'_cigar_operation);
215 if (operation == next_op)
221 result.emplace_back(count, operation);
228 result.emplace_back(count, operation);
231 if (clipped_bases.soft_back)
232 result.emplace_back(clipped_bases.soft_back,
'S'_cigar_operation);
235 if (clipped_bases.hard_back)
236 result.emplace_back(clipped_bases.hard_back,
'H'_cigar_operation);
Provides the seqan3::cigar alphabet.
exposition_only::cigar_operation operation
The (extended) cigar operation alphabet of M,D,I,H,N,P,S,X,=.
Definition: alphabet/cigar/cigar.hpp:96
T emplace_back(T... args)
constexpr auto assign_char_to
Assign a character to an alphabet object.
Definition: alphabet/concept.hpp:524
auto cigar_from_alignment(alignment_type const &alignment, cigar_clipped_bases const &clipped_bases={}, bool const extended_cigar=false)
Creates a CIGAR string (SAM format) given a seqan3::detail::pairwise_alignment represented by two seq...
Definition: cigar_from_alignment.hpp:114
@ ref_seq
The (reference) "sequence" information, usually a range of nucleotides or amino acids.
@ alignment
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
constexpr ptrdiff_t count
Count the occurrences of a type in a pack.
Definition: type_pack/traits.hpp:164
seqan::std::views::zip zip
A view adaptor that takes several views and returns tuple-like values from every i-th element of each...
Definition: zip.hpp:27
Whether a type behaves like a tuple.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Helper struct to specialise soft and hard clipping when using seqan3::cigar_from_alignment.
Definition: cigar_from_alignment.hpp:30
uint32_t hard_front
The number of hard clipped bases at the front of the CIGAR string.
Definition: cigar_from_alignment.hpp:31
uint32_t soft_back
The number of soft clipped bases at the back of the CIGAR string.
Definition: cigar_from_alignment.hpp:34
uint32_t hard_back
The number of hard clipped bases at the back of the CIGAR string.
Definition: cigar_from_alignment.hpp:32
uint32_t soft_front
The number of soft clipped bases at the front of the CIGAR string.
Definition: cigar_from_alignment.hpp:33
Provides seqan3::views::zip.