20 #ifdef SEQAN3_HAS_BZIP2
21 #include <seqan3/contrib/stream/bz2_ostream.hpp>
23 #ifdef SEQAN3_HAS_ZLIB
24 #include <seqan3/contrib/stream/bgzf_ostream.hpp>
25 #include <seqan3/contrib/stream/gz_ostream.hpp>
30 namespace seqan3::detail
39 template <builtin_
character
char_t>
40 inline auto make_secondary_ostream(std::basic_ostream<char_t> & primary_stream, std::filesystem::path & filename)
41 -> std::unique_ptr<std::basic_ostream<char_t>, std::function<void(std::basic_ostream<char_t>*)>>
44 constexpr
auto stream_deleter_noop = [] (std::basic_ostream<char_t> *) {};
46 [[maybe_unused]] constexpr
auto stream_deleter_default = [] (std::basic_ostream<char_t> * ptr) {
delete ptr; };
48 std::string extension = filename.extension().string();
50 if (extension ==
".gz")
52 #ifdef SEQAN3_HAS_ZLIB
53 filename.replace_extension(
"");
54 return {
new contrib::basic_gz_ostream<char_t>{primary_stream}, stream_deleter_default};
56 throw file_open_error{
"Trying to write a gzipped file, but no ZLIB available."};
59 else if ((extension ==
".bgzf") || (extension ==
".bam"))
61 #ifdef SEQAN3_HAS_ZLIB
62 if (extension !=
".bam")
63 filename.replace_extension(
"");
65 return {
new contrib::basic_bgzf_ostream<char_t>{primary_stream}, stream_deleter_default};
67 throw file_open_error{
"Trying to write a bgzf'ed file, but no ZLIB available."};
70 else if (extension ==
".bz2")
72 #ifdef SEQAN3_HAS_BZIP2
73 filename.replace_extension(
"");
74 return {
new contrib::basic_bz2_ostream<char_t>{primary_stream}, stream_deleter_default};
76 throw file_open_error{
"Trying to write a bzipped file, but no libbz2 available."};
79 else if (extension ==
".zst")
81 throw file_open_error{
"Trying to write a zst'ed file, but SeqAn does not yet support this."};
84 return {&primary_stream, stream_deleter_noop};
Provides concepts for core language types and relations that don't have concepts in C++20 (yet).
This header includes C++17 filesystem support and imports it into namespace std::filesystem (independ...
Provides exceptions used in the I/O module.