20 #ifdef SEQAN3_HAS_BZIP2 21 #include <seqan3/contrib/stream/bz2_istream.hpp> 23 #ifdef SEQAN3_HAS_ZLIB 24 #include <seqan3/contrib/stream/bgzf_istream.hpp> 26 #include <seqan3/contrib/stream/gz_istream.hpp> 40 template <std::ranges::ForwardRange ref_t, std::ranges::ForwardRange query_t>
41 inline bool starts_with(ref_t && reference, query_t && query)
74 template <Char
char_t>
78 assert(primary_stream.good());
88 size_t read_chars = 0;
89 for (; read_chars < magic_number.size(); ++read_chars)
94 magic_number[read_chars] = *it;
99 for (
size_t i = 0 ; i < read_chars; ++i)
100 primary_stream.unget();
105 if (read_chars == magic_number.size() && contrib::_bgzfCheckHeader(magic_number.data()))
107 #ifdef SEQAN3_HAS_ZLIB 108 if ((extension ==
".bgzf"))
109 filename.replace_extension();
111 return {
new contrib::basic_bgzf_istream<char_t>{primary_stream},
112 stream_deleter_default};
114 throw file_open_error{
"Trying to read from a bgzf file, but no ZLIB available."};
117 else if (starts_with(magic_number, magic_header<gz_compression>))
119 #ifdef SEQAN3_HAS_ZLIB 120 if ((extension ==
".gz") || (extension ==
".bgzf"))
121 filename.replace_extension();
123 return {
new contrib::basic_gz_istream<char_t>{primary_stream}, stream_deleter_default};
125 throw file_open_error{
"Trying to read from a gzipped file, but no ZLIB available."};
128 else if (starts_with(magic_number, magic_header<bz2_compression>))
130 #ifdef SEQAN3_HAS_BZIP2 131 if (extension ==
".bz2")
132 filename.replace_extension();
134 return {
new contrib::basic_bz2_istream<char_t>{primary_stream}, stream_deleter_default};
136 throw file_open_error{
"Trying to read from a bzipped file, but no libbz2 available."};
139 else if (starts_with(magic_number, magic_header<zstd_compression>))
141 throw file_open_error{
"Trying to read from a zst'ed file, but SeqAn does not yet support this."};
144 return {&primary_stream, stream_deleter_noop};
148 template <Char
char_t>
152 return make_secondary_istream(primary_stream, p);
Provides concepts for core language types and relations that don't have concepts in C++20 (yet)...
Provides stream compression utilities.
Adaptations of concepts from the Ranges TS.
::ranges::begin begin
Alias for ranges::begin. Returns an iterator to the beginning of a range.
Definition: ranges:174
Definition: aligned_sequence_concept.hpp:35
Requires std::detail::WeaklyEqualityComparableWitht<t1,t2>, but also that t1 and t2, as well as their common_reference_t satisfy std::EqualityComparable.
::ranges::end end
Alias for ranges::end. Returns an iterator to the end of a range.
Definition: ranges:179
This header includes C++17 filesystem support and imports it into namespace seqan3::filesystem (indep...