31 #include <seqan3/io/detail/record.hpp>
143 template <
typename _sequence_alphabet>
150 template <
typename _
id_alphabet>
157 template <
typename _quality_alphabet>
328 #ifdef SEQAN3_DEPRECATED_310
334 static_assert([] () constexpr
336 for (
field f : selected_field_ids::as_array)
337 if (!field_ids::contains(f))
341 "You selected a field that is not valid for sequence files, please refer to the documentation "
342 "of sequence_file_input::field_ids for the accepted values.");
344 #ifdef SEQAN3_DEPRECATED_310
345 static_assert([] () constexpr
351 "You may not select field::seq_qual and either of field::seq and field::qual at the same time.");
361 typename traits_type::sequence_alphabet>;
363 using id_type =
typename traits_type::template id_container<
364 typename traits_type::id_alphabet>;
367 typename traits_type::quality_alphabet>;
368 #ifdef SEQAN3_DEPRECATED_310
374 typename traits_type::quality_alphabet>>;
380 using field_types = type_list<sequence_type, id_type, quality_type>;
405 using iterator = detail::in_file_iterator<sequence_file_input>;
448 primary_stream->rdbuf()->pubsetbuf(stream_buffer.
data(), stream_buffer.
size());
450 std::ios_base::in | std::ios::binary);
452 if (!primary_stream->good())
453 throw file_open_error{
"Could not open file " + filename.
string() +
" for reading."};
456 secondary_stream = detail::make_secondary_istream(*primary_stream, filename);
459 using format_variant_t =
typename detail::variant_from_tags<
valid_formats,
460 detail::sequence_file_input_format_exposer>::type;
461 format_variant_t format_variant{};
462 detail::set_format(format_variant, filename);
467 format = std::make_unique<selected_sequence_format<format_t>>();
491 template <input_stream stream_t,
494 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
stream_char_type>
497 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
499 primary_stream{&stream, stream_deleter_noop},
500 format{std::make_unique<selected_sequence_format<file_format>>()}
502 static_assert(list_traits::contains<file_format, valid_formats>,
503 "You selected a format that is not in the valid_formats of this file.");
506 secondary_stream = detail::make_secondary_istream(*primary_stream);
510 template <input_stream stream_t,
513 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
stream_char_type>
516 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
518 primary_stream{
new stream_t{
std::move(stream)}, stream_deleter_default},
519 format{std::make_unique<selected_sequence_format<file_format>>()}
521 static_assert(list_traits::contains<file_format, valid_formats>,
522 "You selected a format that is not in the valid_formats of this file.");
525 secondary_stream = detail::make_secondary_istream(*primary_stream);
550 if (!first_record_was_read)
553 first_record_was_read =
true;
607 #ifdef SEQAN3_DEPRECATED_310
615 sequence_file_input_options_type options;
640 stream_ptr_t primary_stream{
nullptr, stream_deleter_noop};
642 stream_ptr_t secondary_stream{
nullptr, stream_deleter_noop};
645 bool first_record_was_read{
false};
652 void read_next_record()
655 record_buffer.
clear();
665 format->read_sequence_record(*secondary_stream, record_buffer,
options);
678 struct sequence_format_base
683 sequence_format_base() =
default;
684 sequence_format_base(sequence_format_base
const &) =
default;
685 sequence_format_base(sequence_format_base &&) =
default;
686 sequence_format_base &
operator=(sequence_format_base
const &) =
default;
687 sequence_format_base &
operator=(sequence_format_base &&) =
default;
688 virtual ~sequence_format_base() =
default;
701 virtual void read_sequence_record(
std::istream & instream,
717 template <
typename format_t>
718 struct selected_sequence_format final :
public sequence_format_base
723 selected_sequence_format() =
default;
724 selected_sequence_format(selected_sequence_format
const &) =
default;
725 selected_sequence_format(selected_sequence_format &&) =
default;
726 selected_sequence_format &
operator=(selected_sequence_format
const &) =
default;
727 selected_sequence_format &
operator=(selected_sequence_format &&) =
default;
728 ~selected_sequence_format() =
default;
737 #ifdef SEQAN3_DEPRECATED_310
740 _format.read_sequence_record(instream,
742 detail::get_or_ignore<field::_seq_qual_deprecated>(record_buffer),
743 detail::get_or_ignore<field::id>(record_buffer),
744 detail::get_or_ignore<field::_seq_qual_deprecated>(record_buffer));
749 _format.read_sequence_record(instream,
751 detail::get_or_ignore<field::seq>(record_buffer),
752 detail::get_or_ignore<field::id>(record_buffer),
753 detail::get_or_ignore<field::qual>(record_buffer));
758 detail::sequence_file_input_format_exposer<format_t> _format{};
774 template <input_stream stream_type,
783 template <input_stream stream_type,
792 template <input_stream stream_type,
803 template <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
Joins an arbitrary alphabet with a quality alphabet.
Definition: qualified.hpp:61
Provides seqan3::dna15, container aliases and string literals.
Provides seqan3::dna5, container aliases and string literals.
This header includes C++17 filesystem support and imports it into namespace std::filesystem (independ...
field
An enumerator for the fields used in file formats.
Definition: record.hpp:63
@ _seq_qual_deprecated
[DEPRECATED] Sequence and qualities combined in one range. Use field::seq and field::qual instead.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
@ qual
The qualities, usually in Phred score notation.
constexpr bool contains
Whether a type occurs in a type list or not.
Definition: traits.hpp:231
auto const move
A view that turns lvalue-references into rvalue-references.
Definition: move.hpp:74
Provides the seqan3::detail::in_file_iterator class template.
Resolves to std::ranges::explicitly_convertible_to<type1, type2>(). <dl class="no-api">This entity i...
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:29
Provides algorithms for meta programming, parameter packs and seqan3::type_list.
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:172
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:279
Type that contains multiple types.
Definition: type_list.hpp:29
Provides traits for seqan3::type_list.