80template <
typename reference_type,
typename sequence_type>
82 reference_type
const & reference,
83 uint32_t
const zero_based_reference_start_position,
84 sequence_type
const & query)
86 if (cigar_vector.
empty())
87 throw std::logic_error{
"An empty CIGAR is not a valid alignment representation."};
92 uint32_t reference_length{0};
93 uint32_t query_length{0};
95 for (
auto [cigar_count, cigar_operation] : cigar_vector)
97 if ((
'M'_cigar_operation == cigar_operation) || (
'='_cigar_operation == cigar_operation)
98 || (
'X'_cigar_operation == cigar_operation))
100 reference_length += cigar_count;
101 query_length += cigar_count;
103 else if (
'D'_cigar_operation == cigar_operation)
105 reference_length += cigar_count;
107 else if (
'I'_cigar_operation == cigar_operation)
109 query_length += cigar_count;
113 if (
static_cast<size_t>(zero_based_reference_start_position + reference_length) > std::ranges::size(reference))
114 throw std::logic_error{
"The CIGAR string indicates a reference length of at least "
115 +
std::to_string(zero_based_reference_start_position + reference_length)
116 +
", but the supplied reference sequence is only of size"
121 uint32_t soft_clipping_start{0};
122 uint32_t soft_clipping_end{0};
125 auto soft_clipping_at = [&cigar_vector](
size_t const index)
127 return cigar_vector[index] ==
'S'_cigar_operation;
130 auto hard_clipping_at = [&](
size_t const index)
132 return cigar_vector[index] ==
'H'_cigar_operation;
135 auto vector_size_at_least = [&](
size_t const min_size)
137 return cigar_vector.
size() >= min_size;
140 auto cigar_count_at = [&](
size_t const index)
163 throw std::logic_error{
"The CIGAR string indicates a query/read sequence length of "
165 +
", but the supplied query/read sequence is of size"
227template <
typename reference_type,
typename sequence_type>
231 sequence_type
const & query)
Includes the aligned_sequence and the related insert_gap and erase_gap functions to enable stl contai...
Provides the seqan3::cigar alphabet.
A gap decorator allows the annotation of sequences with gap symbols while leaving the underlying sequ...
Definition gap_decorator.hpp:78
Provides seqan3::gap_decorator.
auto alignment_from_cigar(std::vector< cigar > const &cigar_vector, reference_type const &reference, uint32_t const zero_based_reference_start_position, sequence_type const &query)
Construct an alignment from a CIGAR string and the corresponding sequences.
Definition alignment_from_cigar.hpp:81
constexpr std::vector< cigar > parse_cigar(std::string_view const cigar_str)
Parses a cigar string into a vector of operation-count pairs (e.g. (M, 3)).
Definition io/sam_file/detail/cigar.hpp:87
@ alignment
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition slice.hpp:137
Auxiliary functions for the SAM IO.
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
Provides seqan3::views::slice.