95 template <
typename stream_type,
96 typename seq_legal_alph_type,
97 typename stream_pos_type,
103 stream_pos_type & position_buffer,
106 qual_type & SEQAN3_DOXYGEN_ONLY(qualities))
108 auto stream_view = detail::istreambuf(stream);
112 position_buffer = stream.tellg();
117 if (idbuffer !=
"ID")
118 throw parse_error{
"An entry has to start with the code word ID."};
120 if constexpr (!detail::decays_to_ignore_v<id_type>)
131 id.push_back(*stream_it);
134 while (*stream_it !=
'Q');
141 detail::consume(stream_view | detail::take_until(!
is_blank));
160 if (idbuffer !=
"SQ")
164 detail::consume(stream_view | detail::take_until_or_throw(is_char<'S'>));
167 while (*stream_it !=
'Q');
169 detail::consume(stream_view | detail::take_line_or_throw);
172 constexpr auto is_end =
is_char<
'/'>;
173 if constexpr (!detail::decays_to_ignore_v<seq_type>)
176 | detail::take_until_or_throw(is_end);
178 constexpr auto is_legal_alph = char_is_valid_for<seq_legal_alph_type>;
182 [is_legal_alph](
char const c)
184 if (!is_legal_alph(c))
187 +
"char_is_valid_for<"
188 + detail::type_name_as_string<seq_legal_alph_type>
189 +
"> evaluated to false on " + detail::make_printable(c)};
198 detail::consume(stream_view | detail::take_until(is_end));
207 template <
typename stream_type,
215 qual_type && SEQAN3_DOXYGEN_ONLY(qualities))
217 seqan3::detail::fast_ostreambuf_iterator stream_it{*stream.rdbuf()};
219 [[maybe_unused]]
size_t sequence_size = 0;
221 if constexpr (!detail::decays_to_ignore_v<seq_type>)
222 sequence_size = std::ranges::distance(
sequence);
225 if constexpr (detail::decays_to_ignore_v<id_type>)
227 throw std::logic_error{
"The ID field may not be set to ignore when writing embl files."};
231 if (std::ranges::empty(
id))
236 stream_it.write_range(
id);
241 stream_it.write_range(
id);
243 stream_it.write_number(sequence_size);
249 if constexpr (detail::decays_to_ignore_v<seq_type>)
251 throw std::logic_error{
"The SEQ field may not be set to ignore when writing embl files."};
260 stream_it.write_number(sequence_size);
266 size_t written_chars{0};
267 uint8_t chunk_size{10u};
269 while (it != std::ranges::end(char_sequence))
271 auto current_end = it;
272 size_t steps = std::ranges::advance(current_end, chunk_size, std::ranges::end(char_sequence));
274 using subrange_t = std::ranges::subrange<
decltype(it),
decltype(it), std::ranges::subrange_kind::sized>;
275 it = stream_it.write_range(subrange_t{it, current_end, chunk_size - steps});
277 written_chars += chunk_size;
279 if (written_chars % 60 == 0)
281 stream_it.write_number(written_chars);
287 auto characters_in_last_line = sequence_size % 60;
288 auto number_of_padding_needed = 65 - characters_in_last_line - characters_in_last_line / chunk_size;
290 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.
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:63
auto const char_to
A view over an alphabet, given a range of characters.
Definition: char_to.hpp:67
constexpr auto is_blank
Checks whether c is a blank character.
Definition: predicate.hpp:142
constexpr auto is_digit
Checks whether c is a digital character.
Definition: predicate.hpp:262
constexpr auto is_char
Checks whether a given letter is the same as the template non-type argument.
Definition: predicate.hpp:63
constexpr auto is_space
Checks whether c is a space character.
Definition: predicate.hpp:125
constexpr auto is_cntrl
Checks whether c is a control character.
Definition: predicate.hpp:90
decltype(detail::transform< trait_t >(list_t{})) transform
Apply a transformation trait to every type in the list and return a seqan3::type_list of the results.
Definition: traits.hpp:470
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:91
The generic concept for a (biological) sequence.
Provides various utility functions.
Provides seqan3::detail::istreambuf.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
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: exception.hpp:48
The options type defines various option members that influence the behaviour of all or some formats.
Definition: output_options.hpp:26
bool add_carriage_return
The default plain text line-ending is "\n", but on Windows an additional carriage return is recommend...
Definition: output_options.hpp:42
bool embl_genbank_complete_header
Complete header given for embl or genbank.
Definition: output_options.hpp:45
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.