97 template <
typename stream_type,
98 typename seq_legal_alph_type,
106 qual_type & SEQAN3_DOXYGEN_ONLY(qualities))
108 auto stream_view = detail::istreambuf(stream);
109 auto stream_it = std::ranges::begin(stream_view);
112 throw parse_error{
"An entry has to start with the code word LOCUS."};
115 if constexpr (!detail::decays_to_ignore_v<id_type>)
119 std::ranges::copy(
std::string_view{
"LOCUS"}, std::cpp20::back_inserter(
id));
121 while (!is_char<'O'>(*std::ranges::begin(stream_view)))
123 std::ranges::copy(stream_view | detail::take_line_or_throw
125 std::cpp20::back_inserter(
id));
131 detail::consume(stream_view | detail::take_until(!
is_blank));
133 auto read_id_until = [&stream_view, &
id] (
auto predicate)
135 std::ranges::copy(stream_view | detail::take_until_or_throw(predicate)
137 std::cpp20::back_inserter(
id));
145 detail::consume(stream_view | detail::take_line_or_throw);
151 detail::consume(stream_view | detail::take_line_or_throw);
154 detail::consume(stream_view | detail::take_line_or_throw);
155 auto constexpr is_end =
is_char<
'/'> ;
156 if constexpr (!detail::decays_to_ignore_v<seq_type>)
158 auto constexpr is_legal_alph = char_is_valid_for<seq_legal_alph_type>;
160 | detail::take_until_or_throw_and_consume(is_end)
163 if (!is_legal_alph(c))
166 "char_is_valid_for<" +
167 detail::type_name_as_string<seq_legal_alph_type> +
168 "> evaluated to false on " +
169 detail::make_printable(c)};
174 std::cpp20::back_inserter(
sequence));
178 detail::consume(stream_view | detail::take_until_or_throw_and_consume(is_end));
184 template <
typename stream_type,
192 qual_type && SEQAN3_DOXYGEN_ONLY(qualities))
194 std::cpp20::ostreambuf_iterator stream_it{stream};
195 size_t sequence_size{0};
196 [[maybe_unused]]
char buffer[50];
197 if constexpr (!detail::decays_to_ignore_v<seq_type>)
201 if constexpr (detail::decays_to_ignore_v<id_type>)
203 throw std::logic_error{
"The ID field may not be set to ignore when writing genbank files."};
205 else if (ranges::empty(
id))
207 throw std::runtime_error{
"The ID field may not be empty when writing genbank files."};
211 std::ranges::copy(
id, stream_it);
216 std::ranges::copy(
id, stream_it);
218 auto res =
std::to_chars(&buffer[0], &buffer[0] +
sizeof(buffer), sequence_size);
219 std::copy(&buffer[0], res.ptr, stream_it);
224 if constexpr (detail::decays_to_ignore_v<seq_type>)
226 throw std::logic_error{
"The SEQ field may not be set to ignore when writing genbank files."};
228 else if (std::ranges::empty(
sequence))
230 throw std::runtime_error{
"The SEQ field may not be empty when writing genbank files."};
239 while (bp < sequence_size)
251 detail::write_eol(stream_it,
false);
254 detail::write_eol(stream_it,
false);
The <algorithm> header from C++20's standard library.
Core alphabet concept and free function/type trait wrappers.
Provides seqan3::views::char_to.
Provides seqan3::views::chunk.
Provides various utility functions.
Provides various transformation traits used by the range module.
Provides seqan3::dna5, container aliases and string literals.
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
@ id
The identifier, usually a string.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
constexpr auto is_blank
Checks whether c is a blank character.
Definition: predicate.hpp:145
constexpr auto is_digit
Checks whether c is a digital character.
Definition: predicate.hpp:269
constexpr auto is_char
Checks whether a given letter is the same as the template non-type argument.
Definition: predicate.hpp:65
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
constexpr auto chunk
A chunk view.
Definition: chunk.hpp:29
constexpr auto interleave
A view that interleaves a given range into another range at regular intervals.
Definition: interleave.hpp:380
The generic concept for a (biological) sequence.
Provides seqan3::views::interleave.
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.
The <charconv> header from C++17's standard library.
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 embl_genbank_complete_header
Complete header given for embl or genbank.
Definition: output_options.hpp:46
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.