94 template <
typename stream_type,
95 typename seq_legal_alph_type,
bool seq_qual_combined,
103 qual_type & SEQAN3_DOXYGEN_ONLY(qualities))
106 auto stream_it = std::ranges::begin(stream_view);
110 std::cpp20::back_inserter(idbuffer));
111 if (idbuffer !=
"ID")
112 throw parse_error{
"An entry has to start with the code word ID."};
114 if constexpr (!detail::decays_to_ignore_v<id_type>)
118 std::ranges::copy(idbuffer |
views::char_to<std::ranges::range_value_t<id_type>>, std::cpp20::back_inserter(
id));
123 std::cpp20::back_inserter(
id));
124 id.push_back(*stream_it);
126 }
while (*stream_it !=
'Q');
140 std::cpp20::back_inserter(
id));
146 std::cpp20::back_inserter(
id));
158 }
while (*stream_it !=
'Q');
163 auto constexpr is_end =
is_char<
'/'> ;
164 if constexpr (!detail::decays_to_ignore_v<seq_type>)
169 auto constexpr is_legal_alph = char_is_valid_for<seq_legal_alph_type>;
172 if (!is_legal_alph(c))
175 "char_is_valid_for<" +
176 detail::type_name_as_string<seq_legal_alph_type> +
177 "> evaluated to false on " +
183 std::cpp20::back_inserter(
sequence));
196 template <
typename stream_type,
204 qual_type && SEQAN3_DOXYGEN_ONLY(qualities))
208 [[maybe_unused]]
size_t sequence_size = 0;
210 if constexpr (!detail::decays_to_ignore_v<seq_type>)
211 sequence_size = std::ranges::distance(
sequence);
214 if constexpr (detail::decays_to_ignore_v<id_type>)
216 throw std::logic_error{
"The ID field may not be set to ignore when writing embl files."};
220 if (ranges::empty(
id))
225 stream_it.write_range(
id);
230 stream_it.write_range(
id);
232 stream_it.write_number(sequence_size);
238 if constexpr (detail::decays_to_ignore_v<seq_type>)
240 throw std::logic_error{
"The SEQ field may not be set to ignore when writing embl files."};
249 stream_it.write_number(sequence_size);
254 auto it = std::ranges::begin(char_sequence);
255 size_t written_chars{0};
256 uint8_t chunk_size{10u};
258 while (it != std::ranges::end(char_sequence))
260 auto current_end = it;
261 size_t steps = std::ranges::advance(current_end, chunk_size, std::ranges::end(char_sequence));
263 using subrange_t = std::ranges::subrange<decltype(it), decltype(it), std::ranges::subrange_kind::sized>;
264 it = stream_it.write_range(subrange_t{it, current_end, chunk_size - steps});
266 written_chars += chunk_size;
268 if (written_chars % 60 == 0)
270 stream_it.write_number(written_chars);
276 auto characters_in_last_line = sequence_size % 60;
277 auto number_of_padding_needed = 65 - characters_in_last_line - characters_in_last_line / chunk_size;
279 stream_it.write_number(sequence_size);
Adaptations of algorithms from the Ranges TS.
Core alphabet concept and free function/type trait wrappers.
Provides seqan3::views::char_to.
Functionally the same as std::ostreambuf_iterator, but offers writing a range more efficiently.
Definition: fast_ostreambuf_iterator.hpp:39
Provides various transformation traits used by the range module.
Provides seqan3::dna5, container aliases and string literals.
Provides seqan3::detail::fast_ostreambuf_iterator.
constexpr auto is_blank
Checks whether c is a blank character.
Definition: predicate.hpp:161
constexpr auto is_digit
Checks whether c is a digital character.
Definition: predicate.hpp:285
std::string make_printable(char const c)
Returns a printable value for the given character c.
Definition: pretty_print.hpp:48
constexpr auto is_char
Checks whether a given letter is the same as the template non-type argument.
Definition: predicate.hpp:81
constexpr auto is_space
Checks whether c is a space character.
Definition: predicate.hpp:144
constexpr auto is_cntrl
Checks whether c is a control character.
Definition: predicate.hpp:108
constexpr void consume(rng_t &&rng)
Iterate over a range (consumes single-pass input ranges).
Definition: misc.hpp:28
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:434
auto const to_char
A view that calls seqan3::to_char() on each element in the input range.
Definition: to_char.hpp:65
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.hpp:614
constexpr auto istreambuf
A view factory that returns a view over the stream buffer of an input stream.
Definition: istreambuf.hpp:114
constexpr auto take_until
A view adaptor that returns elements from the underlying range until the functor evaluates to true (o...
Definition: take_until.hpp:600
auto const char_to
A view over an alphabet, given a range of characters.
Definition: char_to.hpp:70
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:94
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.hpp:90
The generic concept for a (biological) sequence.
Provides various utility functions.
Provides seqan3::views::istreambuf.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
SeqAn specific customisations in the standard namespace.
Provides various utility functions.
Adaptations of concepts from the Ranges TS.
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:22
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:39
bool embl_genbank_complete_header
Complete header given for embl or genbank.
Definition: output_options.hpp:42
Provides seqan3::views::take_line and seqan3::views::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.
Provides character predicates for tokenisation.