SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::debug_stream_type< char_t > Class Template Reference

A "pretty printer" for most SeqAn data structures and related types. More...

#include <seqan3/core/debug_stream/debug_stream_type.hpp>

Public Types

using fmtflags = typename std::basic_ostream< char_t >::fmtflags
 This type is std::ios_base::fmtflags.
 

Public Member Functions

Constructor, destructor and assignment.

The standard functions are explicitly set to default.

 debug_stream_type ()=default
 Defaulted.
 
 debug_stream_type (debug_stream_type const &)=default
 Defaulted.
 
 debug_stream_type (debug_stream_type &&)=default
 Defaulted.
 
debug_stream_typeoperator= (debug_stream_type const &)=default
 Defaulted.
 
debug_stream_typeoperator= (debug_stream_type &&)=default
 Defaulted.
 
 ~debug_stream_type ()=default
 Defaulted.
 
constexpr debug_stream_type (std::basic_ostream< char_t > &out)
 Construction from an output stream.
 
Miscelleneous
void set_underlying_stream (std::basic_ostream< char_t > &out)
 Change the underlying output stream.
 
Format flags (std::ios_base::fmtflags)

std::ios_base::fmtflags that modify the stream's behaviour.

fmtflags flags () const
 Retrieve the format flags from the stream.
 
fmtflags flags (fmtflags const flgs)
 Replace the current flags on the stream with the given argument.
 
void setf (fmtflags const flag)
 Set the format flag(s) on the stream (current flags are ORed with the argument).
 
void unsetf (fmtflags const flag)
 Unset the format flag(s) on the stream.
 
debug_stream_typeoperator<< (fmtflags const flag)
 Set the format flag(s) on the stream (current flags are ORed with the argument).
 
Format flags (seqan3::fmtflags2)

SeqAn specific debug flags for the debug stream.

fmtflags2 flags2 () const
 Retrieve the format flags from the stream.
 
fmtflags2 flags2 (fmtflags2 flgs)
 Replace the current flags on the stream with the given argument.
 
void setf (fmtflags2 const flag)
 Set the format flag(s) on the stream (current flags are ORed with the argument).
 
void unsetf (fmtflags2 const flag)
 Unset the format flag(s) on the stream.
 
debug_stream_typeoperator<< (fmtflags2 const flag)
 Set the format flag(s) on the stream (current flags are ORed with the argument).
 

Related Symbols

(Note that these are not member symbols.)

template<typename char_t , detail::matrix alignment_matrix_t>
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, alignment_matrix_t &&matrix)
 An alignment matrix can be printed to the seqan3::debug_stream.
 
template<typename char_t , typename coordinate_type >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, coordinate_type &&c)
 A seqan3::detail::advanceable_alignment_coordinate can be printed to the seqan3::debug_stream.
 
template<typename char_t >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, detail::trace_directions const trace)
 All trace_directions can be printed as ascii or as utf8 to the seqan3::debug_stream.
 
template<typename char_t , typename tuple_t >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, tuple_t &&t)
 All tuples can be printed by printing their elements separately.
 
template<typename char_t , typename alignment_result_t >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &stream, alignment_result_t &&result)
 Streams the seqan3::alignment_result to the seqan3::debug_stream.
 
template<typename char_t >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &stream, sam_flag const flag)
 Overload for the seqan3::sam_flags.
 
template<typename char_t , typename search_result_t >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &stream, search_result_t &&result)
 Print the seqan3::search_result to seqan3::debug_stream.
 
Formatted output overloads
template<typename char_t , alphabet alphabet_t>
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, alphabet_t &&l)
 All alphabets can be printed to the seqan3::debug_stream by their char representation.
 
template<typename char_t , seqan3::semialphabet alphabet_t>
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, alphabet_t &&l)
 Overload for the seqan3::mask alphabet.
 
template<typename char_t , typename option_type >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, option_type &&op)
 A type (e.g. an enum) can be made debug streamable by customizing the seqan3::enumeration_names.
 
template<typename char_t , typename byte_type >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, byte_type &&arg)
 A std::byte can be printed by printing its value as integer.
 
template<typename char_t >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, std::nullopt_t arg)
 Make std::nullopt_t printable.
 
template<typename char_t , typename optional_type >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, optional_type &&arg)
 A std::optional can be printed by printing its value or nothing if valueless.
 
template<typename char_t , std::ranges::input_range rng_t>
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, rng_t &&r)
 All input ranges can be printed to the seqan3::debug_stream element-wise (if their elements are printable).
 
template<typename char_t , sequence sequence_t>
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, sequence_t &&sequence)
 All biological sequences can be printed to the seqan3::debug_stream.
 
template<typename char_t , typename variant_type >
debug_stream_type< char_t > & operator<< (debug_stream_type< char_t > &s, variant_type &&v)
 A std::variant can be printed by visiting the stream operator for the corresponding type.
 

Formatted output

debug_stream_typeoperator<< (std::ostream &(*fp)(std::ostream &))
 This overloads enables forwarding std::endl and other manipulators.
 
template<typename other_char_t , typename t >
debug_stream_type< other_char_t > & operator<< (debug_stream_type< other_char_t > &s, t &&v)
 Forwards to the underlying stream object.
 

Detailed Description

template<typename char_t = char>
class seqan3::debug_stream_type< char_t >

A "pretty printer" for most SeqAn data structures and related types.

A global instance of this type exists as seqan3::debug_stream. You can stream to it as you would to std::cout or std::cerr, but the debug stream has special overloads that make certain types streamable (that are not streamable to std::cout). Additionally some data structures are visualised more elaborately via the debug stream and there are extra flags to configure it (seqan3::fmtflags2).

See also
Debug Stream

Example

Simple usage:

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <iostream>
int main()
{
using namespace seqan3::literals;
// The alphabet normally needs to be converted to char explicitly:
std::cout << seqan3::to_char('C'_dna5) << '\n'; // prints 'C'
// The debug_stream, on the other hand, does this automatically:
seqan3::debug_stream << 'C'_dna5 << '\n'; // prints 'C'
// The debug_stream can also print all types that model std::ranges::input_range:
std::vector<seqan3::dna5> vec{"ACGT"_dna5};
seqan3::debug_stream << vec << '\n'; // prints "ACGT"
// ranges of non-alphabets are printed comma-separated:
seqan3::debug_stream << (vec | seqan3::views::to_rank) << '\n'; // prints "[0,1,2,3]"
}
Provides seqan3::debug_stream and related types.
Provides seqan3::dna5, container aliases and string literals.
auto const to_rank
A view that calls seqan3::to_rank() on each element in the input range.
Definition to_rank.hpp:63
constexpr auto to_char
Return the char representation of an alphabet object.
Definition alphabet/concept.hpp:383
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:37
The SeqAn namespace for literals.
Provides seqan3::views::to_rank.

Changing flags:

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
uint8_t i = 71;
seqan3::debug_stream << '\'' << i << "'\n"; // prints '71' (because flag is set by default)
seqan3::debug_stream << '\'' << i << "'\n"; // prints 'G'
seqan3::debug_stream << seqan3::fmtflags2::small_int_as_number << '\'' << i << "'\n"; // prints '71' again
// instead of formatting the stream "inline", one can also call .setf()
}
void unsetf(fmtflags const flag)
Unset the format flag(s) on the stream.
Definition debug_stream_type.hpp:180
@ small_int_as_number
Definition debug_stream_type.hpp:31

See seqan3::fmtflags2 for more details.

Attention
This class does not yet model seqan3::output_stream_over fully,
Todo:
implement.

Member Function Documentation

◆ set_underlying_stream()

template<typename char_t = char>
void seqan3::debug_stream_type< char_t >::set_underlying_stream ( std::basic_ostream< char_t > &  out)
inline

Change the underlying output stream.

Parameters
outReference to the new output stream.

The actual underlying stream that is printed to defaults to std::cerr, but can be changed via this function. You can set any kind of output stream, e.g. a std::ostringstream or a std::ofstream if you want to write to a file, but please be aware that the debug_stream never takes ownership of the underlying stream so you need to take special care that its object lifetime does not end before the debug_stream's.

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <sstream>
int main()
{
using namespace seqan3::literals;
seqan3::debug_stream << "ACGT"_dna5;
o.flush();
seqan3::debug_stream << o.str(); // prints the string stream's buffer: "ACGT"
}
void set_underlying_stream(std::basic_ostream< char_t > &out)
Change the underlying output stream.
Definition debug_stream_type.hpp:113
T flush(T... args)
T str(T... args)

In the case where you wish to print to some stream object locally, instead create you own debug stream:

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <sstream>
int main()
{
using namespace seqan3::literals;
my_stream << "ACGT"_dna5;
o.flush();
seqan3::debug_stream << o.str() << '\n'; // prints the string stream's buffer: "ACGT"
}
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:75

Friends And Related Symbol Documentation

◆ operator<<() [1/16]

template<typename char_t , detail::matrix alignment_matrix_t>
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
alignment_matrix_t &&  matrix 
)
related

An alignment matrix can be printed to the seqan3::debug_stream.

Template Parameters
alignment_matrix_tType of the alignment matrix to be printed; must model seqan3::detail::matrix.
Parameters
sThe seqan3::debug_stream.
matrixThe alignment matrix.

This prints out an alignment matrix which can be a score matrix or a trace matrix.

◆ operator<<() [2/16]

template<typename char_t , seqan3::semialphabet alphabet_t>
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
alphabet_t &&  l 
)
related

Overload for the seqan3::mask alphabet.

Template Parameters
char_tType char type of the debug_stream.
Parameters
sThe seqan3::debug_stream.
lThe mask alphabet letter.

◆ operator<<() [3/16]

template<typename char_t , alphabet alphabet_t>
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
alphabet_t &&  l 
)
related

All alphabets can be printed to the seqan3::debug_stream by their char representation.

Template Parameters
alphabet_tType of the alphabet to be printed; must model seqan3::alphabet.
Parameters
sThe seqan3::debug_stream.
lThe alphabet letter.

◆ operator<<() [4/16]

template<typename char_t , typename byte_type >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
byte_type &&  arg 
)
related

A std::byte can be printed by printing its value as integer.

Template Parameters
byte_typeThe type of the input; must be equal to std::byte.
Parameters
[in]sThe seqan3::debug_stream.
[in]argThe std::byte.

◆ operator<<() [5/16]

template<typename char_t , typename coordinate_type >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
coordinate_type &&  c 
)
related

A seqan3::detail::advanceable_alignment_coordinate can be printed to the seqan3::debug_stream.

Template Parameters
coordinate_typeThe alignment coordinate type.
Parameters
[in]sThe seqan3::debug_stream.
[in]cThe alignment coordinate to print.

Prints the alignment coordinate as a tuple.

◆ operator<<() [6/16]

template<typename char_t >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
detail::trace_directions const  trace 
)
related

All trace_directions can be printed as ascii or as utf8 to the seqan3::debug_stream.

Parameters
sThe seqan3::debug_stream.
traceThe trace direction.

The following table shows the printed symbol of a particular seqan3::detail::trace_directions:

trace direction utf8 ascii
seqan3::detail::trace_directions::none N
seqan3::detail::trace_directions::diagonal D
seqan3::detail::trace_directions::up_open U
seqan3::detail::trace_directions::up u
seqan3::detail::trace_directions::left_open L
seqan3::detail::trace_directions::left l

◆ operator<<() [7/16]

template<typename char_t , typename option_type >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
option_type &&  op 
)
related

A type (e.g. an enum) can be made debug streamable by customizing the seqan3::enumeration_names.

Template Parameters
option_typeType of the enum to be printed.
Parameters
sThe seqan3::debug_stream.
opThe value to print.

This searches the seqan3::enumeration_names of the respective type for the value op and prints the respective string if found or '<UNKNOWN_VALUE>' if the value cannot be found in the map.

◆ operator<<() [8/16]

template<typename char_t , typename optional_type >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
optional_type &&  arg 
)
related

A std::optional can be printed by printing its value or nothing if valueless.

Template Parameters
optional_typeThe type of the optional.
Parameters
[in]sThe seqan3::debug_stream.
[in]argThe std::optional.

◆ operator<<() [9/16]

template<typename char_t , std::ranges::input_range rng_t>
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
rng_t &&  r 
)
related

All input ranges can be printed to the seqan3::debug_stream element-wise (if their elements are printable).

Template Parameters
rng_tType of the range to be printed; must model std::ranges::input_range.
Parameters
sThe seqan3::debug_stream.
rThe input range.

If the element type models seqan3::alphabet (and is not an unsigned integer), the range is printed just as if it were a string, i.e. std::vector<dna4>{'C'_dna4, 'G'_dna4, 'A'_dna4} is printed as "CGA".

In all other cases the elements are comma separated and the range is enclosed in brackets, i.e. std::vector<int>{3, 1, 33, 7} is printed as "[3,1,33,7]".

◆ operator<<() [10/16]

template<typename char_t , sequence sequence_t>
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
sequence_t &&  sequence 
)
related

All biological sequences can be printed to the seqan3::debug_stream.

Template Parameters
sequence_tType of the (biological) sequence to be printed; must model seqan3::sequence.
Parameters
sThe seqan3::debug_stream.
sequenceThe input range.

The (biological) sequence (except for ranges over unsigned integers) is printed just as if it were a string, i.e. std::vector<dna4>{'C'_dna4, 'G'_dna4, 'A'_dna4} is printed as "CGA".

◆ operator<<() [11/16]

template<typename char_t >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
std::nullopt_t  arg 
)
related

Make std::nullopt_t printable.

Template Parameters
optional_typeThis is std::nullopt_t.
Parameters
[in]sThe seqan3::debug_stream.
[in]argThis is std::nullopt.

◆ operator<<() [12/16]

template<typename char_t , typename tuple_t >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
tuple_t &&  t 
)
related

All tuples can be printed by printing their elements separately.

Template Parameters
tuple_tType of the tuple to be printed; must model seqan3::tuple_like.
Parameters
sThe seqan3::debug_stream.
tThe tuple.

◆ operator<<() [13/16]

template<typename char_t , typename variant_type >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  s,
variant_type &&  v 
)
related

A std::variant can be printed by visiting the stream operator for the corresponding type.

Template Parameters
variant_typeThe type of the variant.
Parameters
[in]sThe seqan3::debug_stream.
[in]vThe variant.

Note that in case the variant is valueless(_by_exception), nothing is printed.

◆ operator<<() [14/16]

template<typename char_t , typename alignment_result_t >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  stream,
alignment_result_t &&  result 
)
related

Streams the seqan3::alignment_result to the seqan3::debug_stream.

Template Parameters
char_tThe underlying character type of the seqan3::debug_stream_type.
alignment_result_tA type specialisation of seqan3::alignment_result.
Parameters
[in,out]streamThe output stream.
[in]resultThe alignment result to print.

◆ operator<<() [15/16]

template<typename char_t >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  stream,
sam_flag const  flag 
)
related

Overload for the seqan3::sam_flags.

Template Parameters
char_tType char type of the debug_stream.
Parameters
streamThe seqan3::debug_stream.
flagThe flag to print.

◆ operator<<() [16/16]

template<typename char_t , typename search_result_t >
debug_stream_type< char_t > & operator<< ( debug_stream_type< char_t > &  stream,
search_result_t &&  result 
)
related

Print the seqan3::search_result to seqan3::debug_stream.

Template Parameters
char_tThe underlying character type of the seqan3::debug_stream_type.
search_result_tA specialization of seqan3::search_result.
Parameters
streamThe stream.
resultThe search result to print.

The documentation for this class was generated from the following files:
Hide me