57template <matrix matrix_t,
typename first_sequence_t = std::nullopt_t,
typename second_sequence_t = std::nullopt_t>
71 static constexpr bool is_optional_score = is_type_specialisation_of_v<entry_t, std::optional>;
164 size_t row = coordinate.row;
165 size_t col = coordinate.col;
208 assert(masking_matrix.rows() ==
rows());
209 assert(masking_matrix.cols() ==
cols());
231 assert(new_rows <=
rows());
232 assert(new_cols <=
cols());
270 template <
typename ostream_t>
277 auto char_first_sequence = [&]([[maybe_unused]]
size_t const i) ->
std::string
285 auto char_second_sequence = [&]([[maybe_unused]]
size_t const i) ->
std::string
296 size_t const length_bytes = symbol.size();
298 size_t const offset = length_bytes - length;
303 auto print_first_cell = [&](
std::string const & symbol)
305 cout << symbol << symbols.
col_sep;
309 auto print_first_row = [&]
311 print_first_cell(
" ");
314 for (
size_t col = 0; col <
cols() - 1; ++col)
315 print_cell(char_first_sequence(col));
321 auto print_divider = [&]
324 for (
size_t col = 0; col <
cols(); ++col)
337 if (symbols.
row_sep[0] !=
'\0')
342 print_first_cell(symbols.
epsilon);
344 print_first_cell(char_second_sequence(
row - 1));
346 for (
size_t col = 0; col <
cols(); ++col)
356 size_t col_width = 1;
358 for (
size_t col = 0; col <
cols(); ++col)
380 template <
typename value_type>
385 stream << flags << entry;
386 return strstream.
str();
394 for (
auto it = str.cbegin(); it < str.cend(); ++it, ++length)
397 if ((v & 0b11100000) == 0b11000000)
399 else if ((v & 0b11110000) == 0b11100000)
401 else if ((v & 0b11111000) == 0b11110000)
455template <matrix matrix_t>
460template <matrix matrix_t,
typename first_sequence_t,
typename second_sequence_t>
479template <
typename char_t, detail::matrix alignment_matrix_t>
485 debug.stream_matrix(sstream, s.
flags2());
491template <
typename char_t, std::ranges::input_range alignment_matrix_t>
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:75
fmtflags2 flags2() const
Retrieve the format flags from the stream.
Definition debug_stream_type.hpp:203
A debug matrix to wrap alignment matrices and sequences and make them printable together.
Definition debug_matrix.hpp:59
std::optional< size_t > _cols
The number of columns the debug matrix should have. Must be at most the size of the original matrix.
Definition debug_matrix.hpp:441
debug_matrix & mask_matrix(row_wise_matrix< bool > masking_matrix) noexcept
Masks entries out of the current matrix. This operations changes the way this.at(i,...
Definition debug_matrix.hpp:206
first_sequence_t const & first_sequence() const noexcept
The first sequence of the sequence alignment.
Definition debug_matrix.hpp:144
debug_matrix(matrix_t &&, first_sequence_t &&, second_sequence_t &&) -> debug_matrix< matrix_t, first_sequence_t, second_sequence_t >
The type deduction guide for the constructor seqan3::detail::debug_matrix(matrix_t,...
static constexpr format_type unicode
The format when printing to a unicode stream.
Definition debug_matrix.hpp:425
static std::string as_string(value_type &&entry, fmtflags2 const flags) noexcept
Convert a value into a std::string.
Definition debug_matrix.hpp:381
size_t rows() const noexcept
The number of rows in the matrix.
Definition debug_matrix.hpp:126
size_t cols() const noexcept
The number of columns in the matrix.
Definition debug_matrix.hpp:135
bool _transpose
Whether the current matrix should be transposed.
Definition debug_matrix.hpp:445
debug_matrix & operator=(debug_matrix &&)=default
Defaulted.
debug_matrix()=default
Defaulted.
debug_matrix(debug_matrix &&)=default
Defaulted.
bool _transpose_mask
Whether the masking matrix should be transposed.
Definition debug_matrix.hpp:447
size_t auto_column_width(fmtflags2 const flags) const noexcept
Determines the largest width of all entries in the matrix, e.g. -152 has width 4.
Definition debug_matrix.hpp:354
debug_matrix(debug_matrix const &)=default
Defaulted.
debug_matrix & sub_matrix(size_t const new_rows, size_t const new_cols) noexcept
Limits the view port of the current matrix.
Definition debug_matrix.hpp:229
static constexpr bool is_traceback_matrix
Whether the value_type is trace_directions.
Definition debug_matrix.hpp:68
debug_matrix & mask_matrix(std::vector< bool > masking_vector) noexcept
Creates the masking_matrix out of the given masking_vector and calls mask_matrix(row_wise_matrix<bool...
Definition debug_matrix.hpp:219
std::conditional_t< is_traceback_matrix||is_optional_score, entry_t, std::optional< entry_t > > value_type
The type of an entry in the matrix.
Definition debug_matrix.hpp:78
second_sequence_t const & second_sequence() const noexcept
The second sequence of the sequence alignment.
Definition debug_matrix.hpp:153
static constexpr bool is_optional_score
Whether a score matrix already returns std::optional scores. (Where std::nullopt means unset/invalid/...
Definition debug_matrix.hpp:71
~debug_matrix()=default
Defaulted.
static constexpr format_type csv
The format when printing to a ascii stream.
Definition debug_matrix.hpp:423
std::optional< row_wise_matrix< bool > > _masking_matrix
The masking matrix.
Definition debug_matrix.hpp:443
value_type reference
The type of a reference to an entry in the matrix.
Definition debug_matrix.hpp:80
static constexpr bool has_second_sequence
Whether the current debug_matrix was given a second_sequence.
Definition debug_matrix.hpp:64
std::optional< size_t > _rows
The number of rows the debug matrix should have. Must be at most the size of the original matrix.
Definition debug_matrix.hpp:439
matrix_t _matrix
The matrix.
Definition debug_matrix.hpp:433
first_sequence_t _first_sequence
The first sequence of the sequence alignment.
Definition debug_matrix.hpp:435
debug_matrix & transpose_matrix() noexcept
Transposes the current matrix.
Definition debug_matrix.hpp:249
debug_matrix(matrix_t matrix)
Construct the matrix out of an existing matrix.
Definition debug_matrix.hpp:100
second_sequence_t _second_sequence
The second sequence of the sequence alignment.
Definition debug_matrix.hpp:437
typename std::remove_reference_t< matrix_t >::value_type entry_t
The entry type.
Definition debug_matrix.hpp:66
void stream_matrix(ostream_t &cout, fmtflags2 const flags) const noexcept
Prints this matrix into the given stream.
Definition debug_matrix.hpp:271
debug_matrix & operator=(debug_matrix const &)=default
Defaulted.
debug_matrix(matrix_t &&) -> debug_matrix< matrix_t >
The type deduction guide for the constructor seqan3::detail::debug_matrix(matrix_t)
const_reference at(matrix_coordinate const &coordinate) const noexcept
A reference to the entry of the matrix at the given coordinate.
Definition debug_matrix.hpp:162
typename std::remove_reference_t< matrix_t >::size_type size_type
The size type.
Definition debug_matrix.hpp:84
std::string entry_at(matrix_coordinate const coordinate, fmtflags2 flags) const noexcept
Same as at(coordinate), but as string.
Definition debug_matrix.hpp:368
debug_matrix(matrix_t matrix, first_sequence_t first_sequence, second_sequence_t second_sequence)
Construct the matrix out of an existing matrix and two sequences.
Definition debug_matrix.hpp:108
static size_t unicode_str_length(std::string const &str) noexcept
The length of the str (traceback symbols are unicode aware).
Definition debug_matrix.hpp:391
std::optional< size_t > column_width
What is the width (number of chars) of an entry. Defaults to auto_column_width.
Definition debug_matrix.hpp:429
static constexpr bool has_first_sequence
Whether the current debug_matrix was given a first_sequence.
Definition debug_matrix.hpp:62
Defines the requirements of a matrix (e.g. score matrices, trace matrices).
Definition matrix_concept.hpp:58
A two dimensional matrix used inside of alignment algorithms.
Definition two_dimensional_matrix.hpp:62
A helper concept definition for ranges that can be streamed to the seqan3::debug_stream.
Definition range.hpp:36
Provides seqan3::debug_stream and related types.
Provides seqan3::debug_stream and related types.
debug_stream_type< char_t > & operator<<(debug_stream_type< char_t > &stream, alignment_t &&alignment)
Stream operator for alignments, which are represented as tuples of aligned sequences.
Definition debug_stream_alignment.hpp:107
trace_directions
The possible directions a trace can have. The values can be combined by the logical |-operator.
Definition trace_directions.hpp:26
@ row
The corresponding alignment coordinate will be incrementable/decrementable in the row index.
@ up
Trace comes from the above entry.
@ left
Trace comes from the left entry.
@ diagonal
Trace comes from the diagonal entry.
fmtflags2
Flags that change the behaviour of the seqan3::debug_stream.
Definition debug_stream_type.hpp:28
@ utf8
Enables use of non-ASCII UTF8 characters in formatted output.
Definition debug_stream_type.hpp:30
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
Provides seqan3::detail::matrix.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
SeqAn specific customisations in the standard namespace.
Provides seqan3::debug_stream and related types.
Provides seqan3::debug_stream and related types.
Provides seqan3::detail::row_wise_matrix.
A strong type for designated initialisation of the column index of a matrix.
Definition matrix_coordinate.hpp:29
Strong type for setting the column dimension of a matrix.
Definition two_dimensional_matrix.hpp:29
Strong type for setting the row dimension of a matrix.
Definition two_dimensional_matrix.hpp:37
A strong type for designated initialisation of the row index of a matrix.
Definition matrix_coordinate.hpp:58
Provides type traits for working with templates.
Provides the declaration of seqan3::detail::trace_directions.