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

The options type defines various option members that influence the behaviour of all or some formats. More...

#include <seqan3/io/sam_file/input_options.hpp>

+ Inheritance diagram for seqan3::sam_file_input_options< sequence_legal_alphabet >:

Public Attributes

std::ostreamstream_warnings_to {std::addressof(std::cerr)}
 The stream to write warnings to. Defaults to std::cerr.
 

Detailed Description

template<typename sequence_legal_alphabet>
struct seqan3::sam_file_input_options< sequence_legal_alphabet >

The options type defines various option members that influence the behaviour of all or some formats.

Remarks
For a complete overview, take a look at SAM File

Member Data Documentation

◆ stream_warnings_to

template<typename sequence_legal_alphabet >
std::ostream* seqan3::sam_file_input_options< sequence_legal_alphabet >::stream_warnings_to {std::addressof(std::cerr)}

The stream to write warnings to. Defaults to std::cerr.

Example

// 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>
// A helper struct to create a temporary file and remove it when it goes out of scope.
struct temporary_file
{
temporary_file()
{
std::ofstream file{path}; // Create file
}
temporary_file(temporary_file const &) = delete;
temporary_file & operator=(temporary_file const &) = delete;
temporary_file(temporary_file &&) = delete;
temporary_file & operator=(temporary_file &&) = delete;
~temporary_file()
{
}
std::string read_content() const
{
std::ifstream file{path};
}
};
static constexpr auto sam_file_raw = R"(@HD VN:1.6 pb:5.0.0
@SQ SN:ref LN:34
)";
static auto get_sam_file_input()
{
}
void defaults_to_cerr()
{
auto fin = get_sam_file_input();
std::cerr << "Written to cerr: ";
auto it = fin.begin(); // Prints to cerr: "Unsupported SAM header tag in @HD: pb"
}
void redirect_to_cout()
{
auto fin = get_sam_file_input();
fin.options.stream_warnings_to = std::addressof(std::cout); // Equivalent to `= &std::cout;`
std::cout << "Written to cout: ";
auto it = fin.begin(); // Prints to cout: "Unsupported SAM header tag in @HD: pb"
}
void redirect_to_file()
{
temporary_file tmp_file{};
auto fin = get_sam_file_input();
{ // Inner scope to close file before reading
std::ofstream warning_file{tmp_file.path};
fin.options.stream_warnings_to = std::addressof(warning_file); // Equivalent to `= &warning_file;`
auto it = fin.begin(); // Prints to file: "Unsupported SAM header tag in @HD: pb"
}
std::cout << "Written to file: " << tmp_file.read_content();
}
void silence_warnings()
{
auto fin = get_sam_file_input();
fin.options.stream_warnings_to = nullptr;
auto it = fin.begin(); // No warning emitted
}
int main()
{
defaults_to_cerr();
redirect_to_cout();
redirect_to_file();
silence_warnings();
}
T addressof(T... args)
The SAM format (tag).
Definition format_sam.hpp:105
A class for reading SAM files, both SAM and its binary representation BAM are supported.
Definition sam_file/input.hpp:239
T remove(T... args)
Provides seqan3::sam_file_input and corresponding traits classes.
T temp_directory_path(T... args)

Output to std::cerr:

Written to cerr: Unsupported SAM header tag in @HD: pb

Output to std::cout:

Written to cout: Unsupported SAM header tag in @HD: pb
Written to file: Unsupported SAM header tag in @HD: pb

This entity is experimental and subject to change in the future. Experimental since version 3.4.


The documentation for this struct was generated from the following file:
Hide me