30#include <seqan3/io/detail/record.hpp>
146 template <
typename _sequence_alphabet>
153 template <
typename _
id_alphabet>
160 template <
typename _quality_alphabet>
234 static_assert([] ()
constexpr
236 for (
field f : selected_field_ids::as_array)
237 if (!field_ids::contains(f))
241 "You selected a field that is not valid for sequence files, please refer to the documentation "
242 "of sequence_file_input::field_ids for the accepted values.");
251 typename traits_type::sequence_alphabet>;
253 using id_type =
typename traits_type::template id_container<
254 typename traits_type::id_alphabet>;
257 typename traits_type::quality_alphabet>;
283 using iterator = detail::in_file_iterator<sequence_file_input>;
326 primary_stream->rdbuf()->pubsetbuf(stream_buffer.data(), stream_buffer.size());
328 std::ios_base::in | std::ios::binary);
330 if (!primary_stream->good())
331 throw file_open_error{
"Could not open file " + filename.
string() +
" for reading."};
334 secondary_stream = detail::make_secondary_istream(*primary_stream, filename);
337 using format_variant_t =
typename detail::variant_from_tags<
valid_formats,
338 detail::sequence_file_input_format_exposer>::type;
339 format_variant_t format_variant{};
340 detail::set_format(format_variant, filename);
345 format = std::make_unique<selected_sequence_format<format_t>>();
369 template <input_stream stream_t,
372 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
stream_char_type>
375 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
377 primary_stream{&stream, stream_deleter_noop},
378 format{std::make_unique<selected_sequence_format<file_format>>()}
380 static_assert(list_traits::contains<file_format, valid_formats>,
381 "You selected a format that is not in the valid_formats of this file.");
384 secondary_stream = detail::make_secondary_istream(*primary_stream);
388 template <input_stream stream_t,
391 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
stream_char_type>
394 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
396 primary_stream{
new stream_t{std::move(stream)}, stream_deleter_default},
397 format{std::make_unique<selected_sequence_format<file_format>>()}
399 static_assert(list_traits::contains<file_format, valid_formats>,
400 "You selected a format that is not in the valid_formats of this file.");
403 secondary_stream = detail::make_secondary_istream(*primary_stream);
428 if (!first_record_was_read)
431 first_record_was_read =
true;
512 stream_ptr_t primary_stream{
nullptr, stream_deleter_noop};
514 stream_ptr_t secondary_stream{
nullptr, stream_deleter_noop};
517 bool first_record_was_read{
false};
524 void read_next_record()
527 record_buffer.
clear();
537 format->read_sequence_record(*secondary_stream, record_buffer,
options);
550 struct sequence_format_base
555 sequence_format_base() =
default;
556 sequence_format_base(sequence_format_base
const &) =
default;
557 sequence_format_base(sequence_format_base &&) =
default;
558 sequence_format_base &
operator=(sequence_format_base
const &) =
default;
559 sequence_format_base &
operator=(sequence_format_base &&) =
default;
560 virtual ~sequence_format_base() =
default;
573 virtual void read_sequence_record(
std::istream & instream,
589 template <
typename format_t>
590 struct selected_sequence_format final :
public sequence_format_base
595 selected_sequence_format() =
default;
596 selected_sequence_format(selected_sequence_format
const &) =
default;
597 selected_sequence_format(selected_sequence_format &&) =
default;
598 selected_sequence_format &
operator=(selected_sequence_format
const &) =
default;
599 selected_sequence_format &
operator=(selected_sequence_format &&) =
default;
600 ~selected_sequence_format() =
default;
610 _format.read_sequence_record(instream,
612 detail::get_or_ignore<field::seq>(record_buffer),
613 detail::get_or_ignore<field::id>(record_buffer),
614 detail::get_or_ignore<field::qual>(record_buffer));
619 detail::sequence_file_input_format_exposer<format_t> _format{};
635template <input_stream stream_type,
644template <input_stream stream_type,
653template <input_stream stream_type,
664template <input_stream stream_type,
Provides seqan3::aa27, container aliases and string literals.
Provides alphabet adaptations for standard char types.
The twenty-seven letter amino acid alphabet..
Definition: aa27.hpp:46
The 15 letter DNA alphabet, containing all IUPAC smybols minus the gap..
Definition: dna15.hpp:51
The five letter DNA alphabet of A,C,G,T and the unknown character N..
Definition: dna5.hpp:51
Quality type for traditional Sanger and modern Illumina Phred scores..
Definition: phred42.hpp:47
Provides seqan3::dna15, container aliases and string literals.
Provides seqan3::dna5, container aliases and string literals.
The <filesystem> header from C++17's standard library.
field
An enumerator for the fields used in file formats.
Definition: record.hpp:63
Provides the seqan3::detail::in_file_iterator class template.
Resolves to std::ranges::explicitly_convertible_to<type1, type2>().
A more refined container concept than seqan3::container.
Refines seqan3::alphabet and adds assignability.
A concept that indicates whether a writable alphabet represents quality scores.
Provides exceptions used in the I/O module.
The main SeqAn3 namespace.
Definition: cigar_operation_table.hpp:2
Provides seqan3::phred42 quality scores.
Provides quality alphabet composites.
Provides seqan3::sequence_record.
A class template that holds a choice of seqan3::field.
Definition: record.hpp:128
void clear() noexcept(noexcept(std::apply(expander, std::declval< record & >())))
Clears containers that provide .clear() and (re-)initialises all other elements with = {}.
Definition: record.hpp:235
Type that contains multiple types.
Definition: type_list.hpp:29
Provides traits for seqan3::type_list.