110template <
typename alignment_type>
113 bool const extended_cigar =
false)
117 "The alignment must be a std::pair or std::tuple of size 2.");
120 (std::equality_comparable_with<gap, std::ranges::range_reference_t<decltype(std::get<0>(
alignment))>>
121 && std::equality_comparable_with<gap, std::ranges::range_reference_t<decltype(std::get<1>(
alignment))>>),
122 "The alignment must contain two ranges whose value_type is comparable to seqan3::gap.");
158 auto to_cigar_op = [extended_cigar](
auto const reference_char,
auto const query_char)
170 uint8_t key = (
static_cast<uint8_t
>(reference_char ==
gap{}) << 1) |
static_cast<uint8_t
>(query_char ==
gap{});
174 if (extended_cigar && (key == 0))
175 key |= ((1 << 2) |
static_cast<uint8_t
>(query_char == reference_char));
185 if (
ref_seq.size() != query_seq.size())
186 throw std::logic_error{
"The aligned sequences (including gaps) must have the same length."};
188 if (std::ranges::empty(
ref_seq))
189 throw std::logic_error{
"The aligned sequences may not be empty."};
191 std::vector<cigar> result{};
194 if (clipped_bases.hard_front)
195 result.
emplace_back(clipped_bases.hard_front,
'H'_cigar_operation);
198 if (clipped_bases.soft_front)
199 result.
emplace_back(clipped_bases.soft_front,
'S'_cigar_operation);
212 if (operation == next_op)
228 if (clipped_bases.soft_back)
229 result.
emplace_back(clipped_bases.soft_back,
'S'_cigar_operation);
232 if (clipped_bases.hard_back)
233 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:93
The alphabet of a gap character '-'.
Definition gap.hpp:36
T emplace_back(T... args)
constexpr auto assign_char_to
Assign a character to an alphabet object.
Definition alphabet/concept.hpp:517
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:111
@ ref_seq
The (reference) "sequence" information, usually a range of nucleotides or amino acids.
Definition record.hpp:80
@ alignment
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
Definition record.hpp:78
constexpr ptrdiff_t count
Count the occurrences of a type in a pack.
Definition type_pack/traits.hpp:161
seqan::stl::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:24
Whether a type behaves like a tuple.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
constexpr auto const & get(configuration< configs_t... > const &config) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition configuration.hpp:412
Helper struct to specialise soft and hard clipping when using seqan3::cigar_from_alignment.
Definition cigar_from_alignment.hpp:27
uint32_t hard_front
The number of hard clipped bases at the front of the CIGAR string.
Definition cigar_from_alignment.hpp:28
uint32_t soft_back
The number of soft clipped bases at the back of the CIGAR string.
Definition cigar_from_alignment.hpp:31
uint32_t hard_back
The number of hard clipped bases at the back of the CIGAR string.
Definition cigar_from_alignment.hpp:29
uint32_t soft_front
The number of soft clipped bases at the front of the CIGAR string.
Definition cigar_from_alignment.hpp:30
Provides seqan3::views::zip.