27#include <seqan3/io/detail/record.hpp>
98 requires detail::is_char_adaptation_v<typename t::sequence_alphabet>
143 template <
typename _sequence_alphabet>
150 template <
typename _
id_alphabet>
157 template <
typename _quality_alphabet>
203 detail::type_list_of_sequence_file_input_formats valid_formats_ =
230 for (
field f : selected_field_ids::as_array)
231 if (!field_ids::contains(f))
235 "You selected a field that is not valid for sequence files, please refer to the documentation "
236 "of sequence_file_input::field_ids for the accepted values.");
246 using id_type =
typename traits_type::template id_container<typename traits_type::id_alphabet>;
248 using quality_type =
typename traits_type::template quality_container<typename traits_type::quality_alphabet>;
272 using iterator = detail::in_file_iterator<sequence_file_input>;
313 primary_stream{new
std::ifstream{}, stream_deleter_default}
315 primary_stream->rdbuf()->pubsetbuf(stream_buffer.
data(), stream_buffer.
size());
317 ->
open(filename, std::ios_base::in | std::ios::binary);
319 if (!primary_stream->good())
323 secondary_stream = detail::make_secondary_istream(*primary_stream, filename);
326 using format_variant_t =
327 typename detail::variant_from_tags<valid_formats, detail::sequence_file_input_format_exposer>::type;
328 format_variant_t format_variant{};
329 detail::set_format(format_variant, filename);
332 [&](
auto && selected_format)
334 using format_t = std::remove_cvref_t<
decltype(selected_format)>;
360 template <input_stream stream_t, sequence_file_input_format file_format>
361 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
stream_char_type>
363 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
365 primary_stream{&stream, stream_deleter_noop},
366 format{
std::make_unique<selected_sequence_format<file_format>>()}
369 "You selected a format that is not in the valid_formats of this file.");
372 secondary_stream = detail::make_secondary_istream(*primary_stream);
376 template <input_stream stream_t, sequence_file_input_format file_format>
377 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
stream_char_type>
379 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
381 primary_stream{new stream_t{
std::move(stream)}, stream_deleter_default},
382 format{
std::make_unique<selected_sequence_format<file_format>>()}
385 "You selected a format that is not in the valid_formats of this file.");
388 secondary_stream = detail::make_secondary_istream(*primary_stream);
413 if (!first_record_was_read)
416 first_record_was_read =
true;
497 static void stream_deleter_default(std::basic_istream<stream_char_type> * ptr)
503 stream_ptr_t primary_stream{
nullptr, stream_deleter_noop};
505 stream_ptr_t secondary_stream{
nullptr, stream_deleter_noop};
508 bool first_record_was_read{
false};
515 void read_next_record()
518 record_buffer.
clear();
521 if ((std::istreambuf_iterator<stream_char_type>{*secondary_stream}
522 == std::istreambuf_iterator<stream_char_type>{}))
528 format->read_sequence_record(*secondary_stream, record_buffer, position_buffer,
options);
541 struct sequence_format_base
546 sequence_format_base() =
default;
547 sequence_format_base(sequence_format_base
const &) =
default;
548 sequence_format_base(sequence_format_base &&) =
default;
549 sequence_format_base & operator=(sequence_format_base
const &) =
default;
550 sequence_format_base & operator=(sequence_format_base &&) =
default;
551 virtual ~sequence_format_base() =
default;
565 virtual void read_sequence_record(std::istream & instream,
567 std::streampos & position_buffer,
582 template <
typename format_t>
583 struct selected_sequence_format final :
public sequence_format_base
588 selected_sequence_format() =
default;
589 selected_sequence_format(selected_sequence_format
const &) =
default;
590 selected_sequence_format(selected_sequence_format &&) =
default;
591 selected_sequence_format & operator=(selected_sequence_format
const &) =
default;
592 selected_sequence_format & operator=(selected_sequence_format &&) =
default;
593 ~selected_sequence_format() =
default;
597 void read_sequence_record(std::istream & instream,
599 std::streampos & position_buffer,
604 _format.read_sequence_record(instream,
607 detail::get_or_ignore<field::seq>(record_buffer),
608 detail::get_or_ignore<field::id>(record_buffer),
609 detail::get_or_ignore<field::qual>(record_buffer));
614 detail::sequence_file_input_format_exposer<format_t> _format{};
618 std::unique_ptr<sequence_format_base> format{};
630template <input_stream stream_type, sequence_file_input_format file_format>
638template <input_stream stream_type, sequence_file_input_format file_format>
646template <input_stream stream_type,
657template <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:43
The 15 letter DNA alphabet, containing all IUPAC smybols minus the gap.
Definition dna15.hpp:48
The five letter DNA alphabet of A,C,G,T and the unknown character N.
Definition dna5.hpp:48
Quality type for traditional Sanger and modern Illumina Phred scores.
Definition phred42.hpp:44
The record type of seqan3::sequence_file_input.
Definition sequence_file/record.hpp:26
Provides seqan3::dna15, container aliases and string literals.
Provides seqan3::dna5, container aliases and string literals.
field
An enumerator for the fields used in file formats.
Definition record.hpp:60
constexpr bool contains
Whether a type occurs in a type list or not.
Definition type_list/traits.hpp:249
Provides the seqan3::detail::in_file_iterator class template.
Checks whether from can be explicitly converted to to.
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 aligned_sequence_concept.hpp:26
SeqAn specific customisations in the standard namespace.
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:125
Thrown if there is an unspecified filesystem or stream error while opening, e.g. permission problem.
Definition io/exception.hpp:36
Type that contains multiple types.
Definition type_list.hpp:26
Provides traits for seqan3::type_list.