95 #ifdef SEQAN3_DEPRECATED_310
96 template <
typename stream_type,
97 typename seq_legal_alph_type,
bool seq_qual_combined,
105 qual_type & SEQAN3_DOXYGEN_ONLY(qualities))
107 template <
typename stream_type,
108 typename seq_legal_alph_type,
116 qual_type & SEQAN3_DOXYGEN_ONLY(qualities))
119 auto stream_view = detail::istreambuf(stream);
120 auto stream_it = std::ranges::begin(stream_view);
123 std::ranges::copy(stream_view | detail::take_until_or_throw(
is_cntrl ||
is_blank),
124 std::cpp20::back_inserter(idbuffer));
125 if (idbuffer !=
"ID")
126 throw parse_error{
"An entry has to start with the code word ID."};
128 if constexpr (!detail::decays_to_ignore_v<id_type>)
132 std::ranges::copy(idbuffer |
views::char_to<std::ranges::range_value_t<id_type>>, std::cpp20::back_inserter(
id));
135 std::ranges::copy(stream_view | detail::take_until_or_throw(is_char<'S'>)
137 std::cpp20::back_inserter(
id));
138 id.push_back(*stream_it);
140 }
while (*stream_it !=
'Q');
147 detail::consume(stream_view | detail::take_until(!
is_blank));
152 std::ranges::copy(stream_view | detail::take_until_or_throw(
is_blank || is_char<';'> ||
is_cntrl)
154 std::cpp20::back_inserter(
id));
158 std::ranges::copy(stream_view | detail::take_until_or_throw(is_char<';'>)
160 std::cpp20::back_inserter(
id));
170 detail::consume(stream_view | detail::take_until_or_throw(is_char<'S'>));
172 }
while (*stream_it !=
'Q');
174 detail::consume(stream_view | detail::take_line_or_throw);
177 auto constexpr is_end =
is_char<
'/'> ;
178 if constexpr (!detail::decays_to_ignore_v<seq_type>)
181 | detail::take_until_or_throw(is_end);
183 auto constexpr is_legal_alph = char_is_valid_for<seq_legal_alph_type>;
186 if (!is_legal_alph(c))
189 "char_is_valid_for<" +
190 detail::type_name_as_string<seq_legal_alph_type> +
191 "> evaluated to false on " +
192 detail::make_printable(c)};
197 std::cpp20::back_inserter(
sequence));
201 detail::consume(stream_view | detail::take_until(is_end));
210 template <
typename stream_type,
218 qual_type && SEQAN3_DOXYGEN_ONLY(qualities))
220 seqan3::detail::fast_ostreambuf_iterator stream_it{*stream.rdbuf()};
222 [[maybe_unused]]
size_t sequence_size = 0;
224 if constexpr (!detail::decays_to_ignore_v<seq_type>)
225 sequence_size = std::ranges::distance(
sequence);
228 if constexpr (detail::decays_to_ignore_v<id_type>)
230 throw std::logic_error{
"The ID field may not be set to ignore when writing embl files."};
234 if (ranges::empty(
id))
239 stream_it.write_range(
id);
244 stream_it.write_range(
id);
246 stream_it.write_number(sequence_size);
252 if constexpr (detail::decays_to_ignore_v<seq_type>)
254 throw std::logic_error{
"The SEQ field may not be set to ignore when writing embl files."};
263 stream_it.write_number(sequence_size);
268 auto it = std::ranges::begin(char_sequence);
269 size_t written_chars{0};
270 uint8_t chunk_size{10u};
272 while (it != std::ranges::end(char_sequence))
274 auto current_end = it;
275 size_t steps = std::ranges::advance(current_end, chunk_size, std::ranges::end(char_sequence));
277 using subrange_t = std::ranges::subrange<decltype(it), decltype(it), std::ranges::subrange_kind::sized>;
278 it = stream_it.write_range(subrange_t{it, current_end, chunk_size - steps});
280 written_chars += chunk_size;
282 if (written_chars % 60 == 0)
284 stream_it.write_number(written_chars);
290 auto characters_in_last_line = sequence_size % 60;
291 auto number_of_padding_needed = 65 - characters_in_last_line - characters_in_last_line / chunk_size;
293 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.
Provides seqan3::views::to_char.
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.
constexpr auto is_blank
Checks whether c is a blank character.
Definition: predicate.hpp:163
constexpr auto is_digit
Checks whether c is a digital character.
Definition: predicate.hpp:287
constexpr auto is_char
Checks whether a given letter is the same as the template non-type argument.
Definition: predicate.hpp:83
constexpr auto is_space
Checks whether c is a space character.
Definition: predicate.hpp:146
constexpr auto is_cntrl
Checks whether c is a control character.
Definition: predicate.hpp:110
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:471
auto const to_char
A view that calls seqan3::to_char() on each element in the input range.
Definition: to_char.hpp:68
auto const char_to
A view over an alphabet, given a range of characters.
Definition: char_to.hpp:72
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:95
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.
Adaptations of concepts from the Ranges TS.
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::detail::take_line and seqan3::detail::take_line_or_throw.
Provides seqan3::views::take_until and seqan3::views::take_until_or_throw.
Provides traits to inspect some information of a type, for example its name.
Provides character predicates for tokenisation.
Provides seqan3::views::repeat_n.