60template <detail::fields_specialisation selected_field_
ids_ = fields<field::seq, field::
id, field::structure>,
61 detail::type_list_of_structure_file_output_formats val
id_formats_ = type_list<format_vienna>>
91 for (
field f : selected_field_ids::as_array)
96 "You selected a field that is not valid for structure files, please refer to the documentation "
97 "of structure_file_output::field_ids for the accepted values.");
104 "You may not select field::structured_seq and either of field::seq and field::structure "
105 "at the same time.");
167 ->open(filename, std::ios_base::out | std::ios::binary);
170 throw file_open_error{
"Could not open file " + filename.
string() +
" for writing."};
195 template <output_stream stream_t, structure_file_output_format file_format>
196 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
char>
198 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
202 format{detail::structure_file_output_format_exposer<file_format>{}}
204 static_assert(list_traits::contains<file_format, valid_formats>,
205 "You selected a format that is not in the valid_formats of this file.");
209 template <output_stream stream_t, structure_file_output_format file_format>
210 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
char>
212 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
216 format{detail::structure_file_output_format_exposer<file_format>{}}
218 static_assert(list_traits::contains<file_format, valid_formats>,
219 "You selected a format that is not in the valid_formats of this file.");
286 template <
typename record_t>
288 requires detail::record_like<record_t>
291 detail::get_or_ignore<field::id>(r),
292 detail::get_or_ignore<field::bpp>(r),
293 detail::get_or_ignore<field::structure>(r),
294 detail::get_or_ignore<field::structured_seq>(r),
295 detail::get_or_ignore<field::energy>(r),
296 detail::get_or_ignore<field::react>(r),
297 detail::get_or_ignore<field::react_err>(r),
298 detail::get_or_ignore<field::comment>(r),
299 detail::get_or_ignore<field::offset>(r));
323 template <
typename tuple_t>
363 template <
typename arg_t,
typename... arg_types>
390 template <std::ranges::input_range rng_t>
394 for (
auto &&
record : range)
426 template <std::ranges::input_range rng_t>
435 template <std::ranges::input_range rng_t>
489 template <
typename seq_type,
492 typename structure_type,
493 typename structured_seq_type,
494 typename energy_type,
496 typename comment_type,
497 typename offset_type>
505 react_type && react_error,
509 static_assert(detail::decays_to_ignore_v<structured_seq_type>
510 || (detail::decays_to_ignore_v<seq_type> && detail::decays_to_ignore_v<structure_type>),
511 "You may not select field::structured_seq and either of field::seq and field::structure "
512 "at the same time.");
514 assert(!
format.valueless_by_exception());
518 if constexpr (!detail::decays_to_ignore_v<structured_seq_type>)
560template <output_stream stream_t,
567template <output_stream stream_t,
Output iterator necessary for providing a range-like interface in output file.
Definition: out_file_iterator.hpp:47
A class for writing structured sequence files, e.g. Stockholm, Connect, Vienna, ViennaRNA bpp matrix ...
Definition: io/structure_file/output.hpp:63
std::default_sentinel_t sentinel
The type returned by end().
Definition: io/structure_file/output.hpp:127
void push_back(tuple_t &&t)
Write a record in form of a std::tuple to the file.
Definition: io/structure_file/output.hpp:324
friend structure_file_output & operator|(rng_t &&range, structure_file_output &f)
Write a range of records (or tuples) to the file.
Definition: io/structure_file/output.hpp:427
static void stream_deleter_default(std::basic_ostream< stream_char_type > *ptr)
Stream deleter with default behaviour (ownership assumed).
Definition: io/structure_file/output.hpp:471
format_type format
The actual std::variant holding a pointer to the detected/selected format.
Definition: io/structure_file/output.hpp:485
void const_reference
The const reference type (void).
Definition: io/structure_file/output.hpp:117
friend structure_file_output operator|(rng_t &&range, structure_file_output &&f)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: io/structure_file/output.hpp:436
char stream_char_type
Character type of the stream(s).
Definition: io/structure_file/output.hpp:74
typename detail::variant_from_tags< valid_formats, detail::structure_file_output_format_exposer >::type format_type
Type of the format, a std::variant over the valid_formats.
Definition: io/structure_file/output.hpp:483
stream_ptr_t primary_stream
The primary stream is the user provided stream or the file stream if constructed from filename.
Definition: io/structure_file/output.hpp:477
structure_file_output & operator=(structure_file_output &&)=default
Move assignment is defaulted.
structure_file_output_options options
The options are public and its members can be set directly.
Definition: io/structure_file/output.hpp:445
friend iterator
Befriend iterator so it can access the buffers.
Definition: io/structure_file/output.hpp:551
selected_field_ids_ selected_field_ids
A seqan3::fields list with the fields selected for the record.
Definition: io/structure_file/output.hpp:70
stream_ptr_t secondary_stream
The secondary stream is a compression layer on the primary or just points to the primary (no compress...
Definition: io/structure_file/output.hpp:479
void push_back(record_t &&r)
Write a seqan3::record to the file.
Definition: io/structure_file/output.hpp:287
structure_file_output()=delete
Default constructor is explicitly deleted, you need to give a stream or file name.
structure_file_output(std::filesystem::path filename, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from filename.
Definition: io/structure_file/output.hpp:161
void emplace_back(arg_t &&arg, arg_types &&... args)
Write a record to the file by passing individual fields.
Definition: io/structure_file/output.hpp:364
structure_file_output & operator=(rng_t &&range)
Write a range of records (or tuples) to the file.
Definition: io/structure_file/output.hpp:391
std::vector< char > stream_buffer
A larger (compared to stl default) stream buffer to use when reading from a file.
Definition: io/structure_file/output.hpp:459
void write_record(seq_type &&seq, id_type &&id, bpp_type &&bpp, structure_type &&structure, structured_seq_type &&structured_seq, energy_type &&energy, react_type &&react, react_type &&react_error, comment_type &&comment, offset_type &&offset)
Write record to format.
Definition: io/structure_file/output.hpp:498
void size_type
The size type (void).
Definition: io/structure_file/output.hpp:119
structure_file_output(stream_t &&, file_format const &, selected_field_ids const &) -> structure_file_output< selected_field_ids, type_list< file_format > >
Deduction of the selected fields, the file format and the stream type.
void reference
The reference type (void).
Definition: io/structure_file/output.hpp:115
iterator begin() noexcept
Returns an iterator to current position in the file.
Definition: io/structure_file/output.hpp:244
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: io/structure_file/output.hpp:450
sentinel end() noexcept
Returns a sentinel for comparison with iterator.
Definition: io/structure_file/output.hpp:263
structure_file_output(stream_t &, file_format const &, selected_field_ids const &) -> structure_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...
structure_file_output & operator=(structure_file_output const &)=delete
Copy assignment is explicitly deleted, because you can't have multiple access to the same file.
static void stream_deleter_noop(std::basic_ostream< stream_char_type > *)
Stream deleter that does nothing (no ownership assumed).
Definition: io/structure_file/output.hpp:468
structure_file_output(structure_file_output &&)=default
Move construction is defaulted.
structure_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: io/structure_file/output.hpp:211
void value_type
The value type (void).
Definition: io/structure_file/output.hpp:113
valid_formats_ valid_formats
A seqan3::type_list with the possible formats.
Definition: io/structure_file/output.hpp:72
structure_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: io/structure_file/output.hpp:197
void const_iterator
The const iterator type is void, because files are not const-iterable.
Definition: io/structure_file/output.hpp:125
~structure_file_output()=default
Destructor is defaulted.
structure_file_output(structure_file_output const &)=delete
Copy construction is explicitly deleted, because you can't have multiple access to the same file.
Auxiliary concept that checks whether a type is a specialisation of seqan3::fields.
Definition: detail/record.hpp:35
Provides auxiliary data structures and functions for seqan3::record and seqan3::fields.
Provides seqan3::views::elements.
field
An enumerator for the fields used in file formats.
Definition: record.hpp:63
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: detail/record.hpp:113
void set_format(format_variant_type &format, std::filesystem::path const &file_name)
Sets the file format according to the file name extension.
Definition: io/detail/misc.hpp:68
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:43
@ energy
Energy of a folded sequence, represented by one float number.
@ comment
Comment field of arbitrary content, usually a string.
@ structure
Fixed interactions, usually a string of structure alphabet characters.
@ bpp
Base pair probability matrix of interactions, usually a matrix of float numbers.
@ react
Reactivity values of the sequence characters given in a vector of float numbers.
@ react_err
Reactivity error values given in a vector corresponding to seqan3::field::react.
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
@ structured_seq
Sequence and fixed interactions combined in one range.
@ id
The identifier, usually a string.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
Whether a type behaves like a tuple.
Provides exceptions used in the I/O module.
Provides various utility functions required only for output.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides the seqan3::detail::out_file_iterator class template.
Provides the seqan3::record template and the seqan3::field enum.
Provides seqan3::detail::record_like.
A class template that holds a choice of seqan3::field.
Definition: record.hpp:128
static constexpr bool contains(field f)
Whether a field is contained in the parameter pack.
Definition: record.hpp:149
The class template that file records are based on; behaves like a std::tuple.
Definition: record.hpp:192
The options type defines various option members that influence the behaviour of all or some formats.
Definition: structure_file/output_options.hpp:26
Provides seqan3::structure_file_output_options.
Provides traits for seqan3::type_list.
Provides seqan3::tuple_like.
Provides seqan3::views::convert.
Provides seqan3::views::zip.