99 template <
typename stream_type,
100 typename seq_legal_alph_type,
101 typename stream_pos_type,
107 stream_pos_type & position_buffer,
110 qual_type & qualities)
115 position_buffer = stream.tellg();
117 auto stream_view = detail::istreambuf(stream);
118 auto stream_it = std::ranges::begin(stream_view);
121 size_t sequence_size_before = 0;
122 size_t sequence_size_after = 0;
123 if constexpr (!detail::decays_to_ignore_v<seq_type>)
124 sequence_size_before = size(
sequence);
127 if (*stream_it !=
'@')
130 + detail::make_printable(*stream_it)};
134#if SEQAN3_WORKAROUND_VIEW_PERFORMANCE
135 auto e = std::ranges::end(stream_view);
136 if constexpr (!detail::decays_to_ignore_v<id_type>)
140 for (; (stream_it != e) && (!(
is_cntrl ||
is_blank))(*stream_it); ++stream_it)
143 id.push_back(*stream_it);
145 id.push_back(
assign_char_to(*stream_it, std::ranges::range_value_t<id_type>{}));
147 for (; (stream_it != e) && (!
is_char<
'\n'>)(*stream_it); ++stream_it)
152 for (; (stream_it != e) && (!
is_char<
'\n'>)(*stream_it); ++stream_it)
155 id.push_back(*stream_it);
157 id.push_back(
assign_char_to(*stream_it, std::ranges::range_value_t<id_type>{}));
163 for (; (stream_it != e) && (!
is_char<
'\n'>)(*stream_it); ++stream_it)
174 if constexpr (!detail::decays_to_ignore_v<seq_type>)
176 for (; (stream_it != e) && (!
is_char<
'+'>)(*stream_it); ++stream_it)
186 if (!char_is_valid_for<seq_legal_alph_type>(*stream_it))
189 + detail::make_printable(*stream_it)};
195 sequence_size_after = size(
sequence);
199 for (; (stream_it != e) && (!
is_char<
'+'>)(*stream_it); ++stream_it)
201 ++sequence_size_after;
208 if (*stream_it !=
'+')
211 + detail::make_printable(*stream_it)};
214 for (; (stream_it != e) && (!
is_char<
'\n'>)(*stream_it); ++stream_it)
223 if constexpr (!detail::decays_to_ignore_v<qual_type>)
225 while (sequence_size_after > sequence_size_before)
232 --sequence_size_after;
235 qualities.push_back(*stream_it);
242 + detail::make_printable(*stream_it)};
252 while (sequence_size_after > sequence_size_before)
258 --sequence_size_after;
265 if ((!
is_char<
'\n'>)(*stream_it))
266 throw parse_error{
"Qualitites longer than sequence."};
273 if constexpr (!detail::decays_to_ignore_v<id_type>)
277 std::ranges::copy(stream_view | detail::take_until_or_throw(
is_cntrl ||
is_blank)
280 detail::consume(stream_view | detail::take_line_or_throw);
284 std::ranges::copy(stream_view | detail::take_line_or_throw
291 detail::consume(stream_view | detail::take_line_or_throw);
295 auto seq_view = stream_view | detail::take_until_or_throw(
is_char<
'+'>)
297 if constexpr (!detail::decays_to_ignore_v<seq_type>)
299 constexpr auto is_legal_alph = char_is_valid_for<seq_legal_alph_type>;
302 | std::views::transform(
303 [is_legal_alph](
char const c)
305 if (!is_legal_alph(c))
308 +
"char_is_valid_for<"
309 + detail::type_name_as_string<seq_legal_alph_type>
310 +
"> evaluated to false on " + detail::make_printable(c)};
316 sequence_size_after = size(
sequence);
320 auto it = begin(seq_view);
321 auto it_end = end(seq_view);
325 ++sequence_size_after;
329 detail::consume(stream_view | detail::take_line_or_throw);
332 auto qview = stream_view | std::views::filter(!
is_space)
333 | detail::take_exactly_or_throw(sequence_size_after - sequence_size_before);
334 if constexpr (!detail::decays_to_ignore_v<qual_type>)
336 std::ranges::copy(qview |
views::char_to<std::ranges::range_value_t<qual_type>>,
341 detail::consume(qview);
347 template <
typename stream_type,
355 qual_type && qualities)
357 seqan3::detail::fast_ostreambuf_iterator stream_it{*stream.rdbuf()};
360 if constexpr (detail::decays_to_ignore_v<id_type>)
362 throw std::logic_error{
"The ID field may not be set to ignore when writing FASTQ files."};
366 if (std::ranges::empty(
id))
370 stream_it.write_range(
id);
375 if constexpr (detail::decays_to_ignore_v<seq_type>)
378 "The SEQ and SEQ_QUAL fields may not both be set to ignore when writing FASTQ files."};
390 if constexpr (!detail::decays_to_ignore_v<id_type>)
395 stream_it.write_range(
id);
401 if constexpr (detail::decays_to_ignore_v<qual_type>)
404 "The QUAL and SEQ_QUAL fields may not both be set to ignore when writing FASTQ files."};
408 if (std::ranges::empty(qualities))
411 if constexpr (std::ranges::sized_range<seq_type> && std::ranges::sized_range<qual_type>)
413 assert(std::ranges::size(
sequence) == std::ranges::size(qualities));
Provides aliases for qualified.
Core alphabet concept and free function/type trait wrappers.
T back_inserter(T... args)
Provides alphabet adaptations for standard char types.
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 assign_char_to
Assign a character to an alphabet object.
Definition alphabet/concept.hpp:524
constexpr auto char_is_valid_for
Returns whether a character is in the valid set of a seqan3::alphabet (usually implies a bijective ma...
Definition alphabet/concept.hpp:670
constexpr auto is_blank
Checks whether c is a blank character.
Definition predicate.hpp:142
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
Provides seqan3::detail::ignore_output_iterator for writing to null stream.
This concept encompasses exactly the types char, signed char, unsigned char, wchar_t,...
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::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:48
The options type defines various option members that influence the behaviour of all or some formats.
Definition sequence_file/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 sequence_file/output_options.hpp:42
bool fastq_double_id
Whether to write the ID only '@' or also after '+' line.
Definition sequence_file/output_options.hpp:37
Provides seqan3::views::take_exactly and seqan3::views::take_exactly_or_throw.
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.
Provides concepts that do not have equivalents in C++20.