166 template <detail::fields_specialisation selected_field_
ids_ = fields<field::seq, field::
id, field::qual>,
167 detail::type_list_of_sequence_file_output_formats val
id_formats_ =
168 type_list<format_embl, format_fasta, format_fastq, format_genbank, format_sam>>
187 static_assert([] () constexpr
189 for (
field f : selected_field_ids::as_array)
194 "You selected a field that is not valid for sequence files, please refer to the documentation "
195 "of sequence_file_output::field_ids for the accepted values.");
197 static_assert([] () constexpr
203 "You may not select field::seq_qual and either of field::seq and field::qual at the same time.");
265 std::ios_base::out | std::ios::binary);
268 throw file_open_error{
"Could not open file " + filename.
string() +
" for writing."};
292 template <output_stream stream_t,
295 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
stream_char_type>
298 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
302 format{detail::sequence_file_output_format_exposer<file_format>{}}
304 static_assert(list_traits::contains<file_format, valid_formats>,
305 "You selected a format that is not in the valid_formats of this file.");
309 template <output_stream stream_t,
312 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
stream_char_type>
315 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
319 format{detail::sequence_file_output_format_exposer<file_format>{}}
321 static_assert(list_traits::contains<file_format, valid_formats>,
322 "You selected a format that is not in the valid_formats of this file.");
389 template <
typename record_t>
392 requires detail::record_like<record_t>
396 detail::get_or_ignore<field::id>(r),
397 detail::get_or_ignore<field::qual>(r),
398 detail::get_or_ignore<field::seq_qual>(r));
423 template <
typename tuple_t>
459 template <
typename arg_t,
typename ...arg_types>
486 template <std::ranges::input_range rng_t>
492 for (
auto &&
record : range)
524 template <std::ranges::input_range rng_t>
535 template <std::ranges::input_range rng_t>
541 #if defined(__GNUC__) && (__GNUC__ == 9)
542 for (
auto &&
record : range)
591 template <
typename seq_t,
typename id_t,
typename qual_t,
typename seq_qual_t>
592 void write_record(seq_t && seq, id_t &&
id, qual_t && qual, seq_qual_t && seq_qual)
594 static_assert(detail::decays_to_ignore_v<seq_qual_t> ||
595 (detail::decays_to_ignore_v<seq_t> && detail::decays_to_ignore_v<qual_t>),
596 "You may not select field::seq_qual and either of field::seq and field::qual at the same time.");
598 if constexpr (!detail::decays_to_ignore_v<seq_qual_t>)
599 static_assert(detail::is_type_specialisation_of_v<std::ranges::range_value_t<seq_qual_t>,
qualified>,
600 "The SEQ_QUAL field must contain a range over the seqan3::qualified alphabet.");
602 assert(!
format.valueless_by_exception());
605 if constexpr (!detail::decays_to_ignore_v<seq_qual_t>)
634 template <output_stream stream_t,
642 template <output_stream stream_t,
650 template <output_stream stream_t,
660 template <output_stream stream_t,
Output iterator necessary for providing a range-like interface in output file.
Definition: out_file_iterator.hpp:47
Joins an arbitrary alphabet with a quality alphabet.
Definition: qualified.hpp:59
A class for writing sequence files, e.g. FASTA, FASTQ ...
Definition: output.hpp:170
static void stream_deleter_noop(std::basic_ostream< stream_char_type > *)
Stream deleter that does nothing (no ownership assumed).
Definition: output.hpp:574
void push_back(record_t &&r)
Write a seqan3::record to the file.
Definition: output.hpp:390
sequence_file_output(std::filesystem::path filename, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from filename.
Definition: output.hpp:259
void const_iterator
The const iterator type is void, because files are not const-iterable.
Definition: output.hpp:223
sequence_file_output & operator=(sequence_file_output const &)=delete
Copy assignment is explicitly deleted, because you can't have multiple access to the same file.
char stream_char_type
Character type of the stream(s).
Definition: output.hpp:181
std::default_sentinel_t sentinel
The type returned by end().
Definition: output.hpp:225
typename detail::variant_from_tags< valid_formats, detail::sequence_file_output_format_exposer >::type format_type
Type of the format, an std::variant over the valid_formats.
Definition: output.hpp:585
sequence_file_output(stream_t &&, file_format const &, selected_field_ids const &) -> sequence_file_output< selected_field_ids, type_list< file_format >>
Deduction guide for given stream, file format and field ids.
friend iterator
Befriend iterator so it can access the buffers.
Definition: output.hpp:625
friend sequence_file_output operator|(rng_t &&range, sequence_file_output &&f)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: output.hpp:536
sequence_file_output(stream_t &&, file_format const &) -> sequence_file_output< typename sequence_file_output<>::selected_field_ids, type_list< file_format >>
This is an overloaded member function, provided for convenience. It differs from the above function o...
format_type format
The actual std::variant holding a pointer to the detected/selected format.
Definition: output.hpp:587
sequence_file_output & operator=(rng_t &&range)
Write a range of records (or tuples) to the file.
Definition: output.hpp:487
sequence_file_output(sequence_file_output &&)=default
Move construction is defaulted.
void push_back(tuple_t &&t)
Write a record in form of a std::tuple to the file.
Definition: output.hpp:424
stream_ptr_t primary_stream
The primary stream is the user provided stream or the file stream if constructed from filename.
Definition: output.hpp:579
sequence_file_output(stream_t &, file_format const &) -> sequence_file_output< typename sequence_file_output<>::selected_field_ids, type_list< file_format >>
Deduction guide for given stream and file format.
friend sequence_file_output & operator|(rng_t &&range, sequence_file_output &f)
Write a range of records (or tuples) to the file.
Definition: output.hpp:525
std::basic_ostream< stream_char_type > & get_stream()
Expose a reference to the secondary stream. [public, but not documented as part of the API].
Definition: output.hpp:557
sequence_file_output(sequence_file_output const &)=delete
Copy construction is explicitly deleted, because you can't have multiple access to the same file.
valid_formats_ valid_formats
A seqan3::type_list with the possible formats.
Definition: output.hpp:179
sequence_file_output(stream_t &, file_format const &, selected_field_ids const &) -> sequence_file_output< selected_field_ids, type_list< file_format >>
This is an overloaded member function, provided for convenience. It differs from the above function o...
selected_field_ids_ selected_field_ids
A seqan3::fields list with the fields selected for the record.
Definition: output.hpp:177
~sequence_file_output()=default
Destructor is defaulted.
sequence_file_output_options options
The options are public and its members can be set directly.
Definition: output.hpp:552
void emplace_back(arg_t &&arg, arg_types &&... args)
Write a record to the file by passing individual fields.
Definition: output.hpp:460
void write_record(seq_t &&seq, id_t &&id, qual_t &&qual, seq_qual_t &&seq_qual)
Write record to format.
Definition: output.hpp:592
void value_type
The value type (void).
Definition: output.hpp:211
sentinel end() noexcept
Returns a sentinel for comparison with iterator.
Definition: output.hpp:366
void reference
The reference type (void).
Definition: output.hpp:213
std::vector< char > stream_buffer
A larger (compared to stl default) stream buffer to use when reading from a file.
Definition: output.hpp:565
static void stream_deleter_default(std::basic_ostream< stream_char_type > *ptr)
Stream deleter with default behaviour (ownership assumed).
Definition: output.hpp:576
sequence_file_output & operator=(sequence_file_output &&)=default
Move assignment is defaulted.
stream_ptr_t secondary_stream
The secondary stream is a compression layer on the primary or just points to the primary (no compress...
Definition: output.hpp:581
void const_reference
The const reference type (void).
Definition: output.hpp:215
sequence_file_output()=delete
Default constructor is explicitly deleted, you need to give a stream or file name.
sequence_file_output(stream_t &stream, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from an existing stream and with specified format.
Definition: output.hpp:297
sequence_file_output(stream_t &&stream, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: output.hpp:314
iterator begin() noexcept
Returns an iterator to current position in the file.
Definition: output.hpp:347
void size_type
The size type (void).
Definition: output.hpp:217
Provides auxiliary data structures and functions for seqan3::record and seqan3::fields.
This header includes C++17 filesystem support and imports it into namespace std::filesystem (independ...
Provides seqan3::views::get.
field
An enumerator for the fields used in file formats.
Definition: record.hpp:62
void set_format(format_variant_type &format, std::filesystem::path const &file_name)
Sets the file format according to the file name extension.
Definition: misc.hpp:67
auto & get_or_ignore(record< field_types, field_ids > &r)
Access an element in a std::tuple or seqan3::record; return reference to std::ignore if not contained...
Definition: record.hpp:121
@ id
The identifier, usually a string.
@ seq_qual
Sequence and qualities combined in one range.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
@ qual
The qualities, usually in Phred score notation.
meta::list< types... > type_list
Type that contains multiple types, an alias for meta::list.
Definition: type_list.hpp:31
constexpr bool contains
Whether a type occurs in a type list or not.
Definition: traits.hpp:194
auto const move
A view that turns lvalue-references into rvalue-references.
Definition: move.hpp:70
Whether a type behaves like a tuple.
Provides various utility functions.
Provides exceptions used in the I/O module.
Provides various utility functions required only for output.
auto make_secondary_ostream(std::basic_ostream< char_t > &primary_stream, std::filesystem::path &filename) -> std::unique_ptr< std::basic_ostream< char_t >, std::function< void(std::basic_ostream< char_t > *)>>
Depending on the given filename/extension, create a compression stream or just forward the primary st...
Definition: misc_output.hpp:39
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides the seqan3::detail::out_file_iterator class template.
Provides algorithms for meta programming, parameter packs and seqan3::type_list.
Provides seqan3::views::convert.
Adaptations of concepts from the Ranges TS.
Provides the seqan3::record template and the seqan3::field enum.
Provides seqan3::detail::record_like.
Provides seqan3::sequence_file_output_options.
A class template that holds a choice of seqan3::field.
Definition: record.hpp:163
static constexpr bool contains(field f)
Whether a field is contained in the parameter pack.
Definition: record.hpp:181
The class template that file records are based on; behaves like an std::tuple.
Definition: record.hpp:223
The options type defines various option members that influence the behaviour of all or some formats.
Definition: output_options.hpp:22
Provides seqan3::tuple_like.
Provides traits for seqan3::type_list.
Provides seqan3::views::zip.