102 template <
typename stream_type,
103 typename seq_legal_alph_type,
111 qual_type & qualities)
113 auto stream_view = detail::istreambuf(stream);
114 auto stream_it = begin(stream_view);
117 size_t sequence_size_before = 0;
118 size_t sequence_size_after = 0;
119 if constexpr (!detail::decays_to_ignore_v<seq_type>)
123 if (*stream_it !=
'@')
126 detail::make_printable(*stream_it)};
130 if constexpr (!detail::decays_to_ignore_v<id_type>)
134 std::ranges::copy(stream_view | detail::take_until_or_throw(
is_cntrl ||
is_blank)
136 std::cpp20::back_inserter(
id));
137 detail::consume(stream_view | detail::take_line_or_throw);
141 std::ranges::copy(stream_view | detail::take_line_or_throw
143 std::cpp20::back_inserter(
id));
148 detail::consume(stream_view | detail::take_line_or_throw);
152 auto seq_view = stream_view | detail::take_until_or_throw(is_char<'+'>)
154 if constexpr (!detail::decays_to_ignore_v<seq_type>)
156 auto constexpr is_legal_alph = char_is_valid_for<seq_legal_alph_type>;
159 if (!is_legal_alph(c))
162 "char_is_valid_for<" +
163 detail::type_name_as_string<seq_legal_alph_type> +
164 "> evaluated to false on " +
165 detail::make_printable(c)};
170 std::cpp20::back_inserter(
sequence));
175 auto it = begin(seq_view);
176 auto it_end = end(seq_view);
180 ++sequence_size_after;
184 detail::consume(stream_view | detail::take_line_or_throw);
187 auto qview = stream_view | std::views::filter(!
is_space)
188 | detail::take_exactly_or_throw(sequence_size_after - sequence_size_before);
189 if constexpr (!detail::decays_to_ignore_v<qual_type>)
191 std::ranges::copy(qview |
views::char_to<std::ranges::range_value_t<qual_type>>,
192 std::cpp20::back_inserter(qualities));
196 detail::consume(qview);
201 template <
typename stream_type,
209 qual_type && qualities)
211 seqan3::detail::fast_ostreambuf_iterator stream_it{*stream.rdbuf()};
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 FASTQ files."};
220 if (std::ranges::empty(
id))
224 stream_it.write_range(
id);
229 if constexpr (detail::decays_to_ignore_v<seq_type>)
231 throw std::logic_error{
"The SEQ and SEQ_QUAL fields may not both be set to ignore when writing FASTQ files."};
243 if constexpr (!detail::decays_to_ignore_v<id_type>)
248 stream_it.write_range(
id);
254 if constexpr (detail::decays_to_ignore_v<qual_type>)
256 throw std::logic_error{
"The QUAL and SEQ_QUAL fields may not both be set to ignore when writing FASTQ files."};
260 if (std::ranges::empty(qualities))
263 if constexpr (std::ranges::sized_range<seq_type> && std::ranges::sized_range<qual_type>)
The <algorithm> header from C++20's standard library.
Provides aliases for qualified.
Core alphabet concept and free function/type trait wrappers.
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 is_blank
Checks whether c is a blank character.
Definition: predicate.hpp:145
constexpr auto is_space
Checks whether c is a space character.
Definition: predicate.hpp:128
constexpr auto is_cntrl
Checks whether c is a control character.
Definition: predicate.hpp:92
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
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:151
Provides seqan3::detail::ignore_output_iterator for writing to null stream.
The generic concept for a (biological) sequence.
Provides various utility functions.
Provides seqan3::detail::istreambuf.
The main SeqAn3 namespace.
Definition: cigar_operation_table.hpp:2
SeqAn specific customisations in the standard namespace.
Provides character predicates for tokenisation.
The <ranges> header from C++20's standard library.
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:43
bool fastq_double_id
Whether to write the ID only '@' or also after '+' line.
Definition: output_options.hpp:38
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.