92 template <
typename stream_type,
93 typename seq_legal_alph_type,
94 typename stream_pos_type,
100 stream_pos_type & position_buffer,
103 qual_type & SEQAN3_DOXYGEN_ONLY(qualities))
108 position_buffer = stream.tellg();
116 if (idbuffer !=
"ID")
117 throw parse_error{
"An entry has to start with the code word ID."};
119 if constexpr (!detail::decays_to_ignore_v<id_type>)
130 id.push_back(*stream_it);
133 while (*stream_it !=
'Q');
159 if (idbuffer !=
"SQ")
166 while (*stream_it !=
'Q');
171 constexpr auto is_end =
is_char<
'/'>;
172 if constexpr (!detail::decays_to_ignore_v<seq_type>)
177 constexpr auto is_legal_alph = char_is_valid_for<seq_legal_alph_type>;
180 | std::views::transform(
181 [is_legal_alph](
char const c)
183 if (!is_legal_alph(c))
186 +
"char_is_valid_for<"
187 + detail::type_name_as_string<seq_legal_alph_type>
200 std::ranges::advance(stream_it, 3u, std::ranges::end(stream_view));
204 template <
typename stream_type,
212 qual_type && SEQAN3_DOXYGEN_ONLY(qualities))
216 [[maybe_unused]]
size_t sequence_size = 0;
218 if constexpr (!detail::decays_to_ignore_v<seq_type>)
219 sequence_size = std::ranges::distance(
sequence);
222 if constexpr (detail::decays_to_ignore_v<id_type>)
224 throw std::logic_error{
"The ID field may not be set to ignore when writing embl files."};
228 if (std::ranges::empty(
id))
233 stream_it.write_range(
id);
238 stream_it.write_range(
id);
240 stream_it.write_number(sequence_size);
246 if constexpr (detail::decays_to_ignore_v<seq_type>)
248 throw std::logic_error{
"The SEQ field may not be set to ignore when writing embl files."};
257 stream_it.write_number(sequence_size);
263 size_t written_chars{0};
264 uint8_t chunk_size{10u};
266 while (it != std::ranges::end(char_sequence))
268 auto current_end = it;
269 size_t steps = std::ranges::advance(current_end, chunk_size, std::ranges::end(char_sequence));
271 using subrange_t = std::ranges::subrange<
decltype(it),
decltype(it), std::ranges::subrange_kind::sized>;
272 it = stream_it.write_range(subrange_t{it, current_end, chunk_size - steps});
274 written_chars += chunk_size;
276 if (written_chars % 60 == 0)
278 stream_it.write_number(written_chars);
284 auto characters_in_last_line = sequence_size % 60;
285 auto number_of_padding_needed = 65 - characters_in_last_line - characters_in_last_line / chunk_size;
287 stream_it.write_number(sequence_size);
Core alphabet concept and free function/type trait wrappers.
T back_inserter(T... args)
Provides seqan3::views::char_to.
Functionally the same as std::ostreambuf_iterator, but offers writing a range more efficiently.
Definition fast_ostreambuf_iterator.hpp:38
Provides various utility functions.
Provides various transformation traits used by the range module.
Provides seqan3::dna5, container aliases and string literals.
Provides seqan3::detail::fast_ostreambuf_iterator.
auto const to_char
A view that calls seqan3::to_char() on each element in the input range.
Definition to_char.hpp:60
auto const char_to
A view over an alphabet, given a range of characters.
Definition char_to.hpp:64
constexpr void consume(rng_t &&rng)
Iterate over a range.
Definition core/range/detail/misc.hpp:28
constexpr auto take_until
A view adaptor that returns elements from the underlying range until the functor evaluates to true (o...
Definition take_until_view.hpp:560
constexpr auto take_until_or_throw
A view adaptor that returns elements from the underlying range until the functor evaluates to true (t...
Definition take_until_view.hpp:574
constexpr auto istreambuf
A view factory that returns a view over the stream buffer of an input stream.
Definition istreambuf_view.hpp:104
constexpr auto take_line_or_throw
A view adaptor that returns a single line from the underlying range (throws if there is no end-of-lin...
Definition take_line_view.hpp:82
constexpr auto is_blank
Checks whether c is a blank character.
Definition predicate.hpp:139
constexpr auto is_digit
Checks whether c is a digital character.
Definition predicate.hpp:259
std::string make_printable(char const c)
Returns a printable value for the given character c.
Definition pretty_print.hpp:45
constexpr auto is_char
Checks whether a given letter is the same as the template non-type argument.
Definition predicate.hpp:60
constexpr auto is_space
Checks whether c is a space character.
Definition predicate.hpp:122
constexpr auto is_cntrl
Checks whether c is a control character.
Definition predicate.hpp:87
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition repeat_n.hpp:88
The generic concept for a (biological) sequence.
Provides various utility functions.
Provides seqan3::detail::istreambuf.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
SeqAn specific customisations in the standard namespace.
Provides character predicates for tokenisation.
Provides seqan3::views::repeat_n.
Provides seqan3::sequence_file_output_options.
Thrown if there is a parse error, such as reading an unexpected character from an input stream.
Definition io/exception.hpp:45
The options type defines various option members that influence the behaviour of all or some formats.
Definition sequence_file/output_options.hpp:23
bool add_carriage_return
The default plain text line-ending is "\n", but on Windows an additional carriage return is recommend...
Definition sequence_file/output_options.hpp:39
bool embl_genbank_complete_header
Complete header given for embl or genbank.
Definition sequence_file/output_options.hpp:42
Provides seqan3::detail::take_line and seqan3::detail::take_line_or_throw.
Provides seqan3::views::take_until and seqan3::views::take_until_or_throw.
Provides seqan3::views::to_char.
Provides traits to inspect some information of a type, for example its name.