96 template <
typename stream_type,
97 typename seq_legal_alph_type,
105 qual_type & SEQAN3_DOXYGEN_ONLY(qualities))
108 auto stream_it = std::ranges::begin(stream_view);
111 throw parse_error{
"An entry has to start with the code word LOCUS."};
114 if constexpr (!detail::decays_to_ignore_v<id_type>)
118 std::ranges::copy(
std::string_view{
"LOCUS"}, std::cpp20::back_inserter(
id));
120 while (!is_char<'O'>(*std::ranges::begin(stream_view)))
124 std::cpp20::back_inserter(
id));
132 auto read_id_until = [&stream_view, &
id] (
auto predicate)
136 std::cpp20::back_inserter(
id));
154 auto constexpr is_end =
is_char<
'/'> ;
155 if constexpr (!detail::decays_to_ignore_v<seq_type>)
157 auto constexpr is_legal_alph = char_is_valid_for<seq_legal_alph_type>;
162 if (!is_legal_alph(c))
165 "char_is_valid_for<" +
166 detail::type_name_as_string<seq_legal_alph_type> +
167 "> evaluated to false on " +
173 std::cpp20::back_inserter(
sequence));
183 template <
typename stream_type,
191 qual_type && SEQAN3_DOXYGEN_ONLY(qualities))
193 std::cpp20::ostreambuf_iterator stream_it{stream};
194 size_t sequence_size{0};
195 [[maybe_unused]]
char buffer[50];
196 if constexpr (!detail::decays_to_ignore_v<seq_type>)
200 if constexpr (detail::decays_to_ignore_v<id_type>)
202 throw std::logic_error{
"The ID field may not be set to ignore when writing genbank files."};
204 else if (ranges::empty(
id))
206 throw std::runtime_error{
"The ID field may not be empty when writing genbank files."};
210 std::ranges::copy(
id, stream_it);
215 std::ranges::copy(
id, stream_it);
217 auto res =
std::to_chars(&buffer[0], &buffer[0] +
sizeof(buffer), sequence_size);
218 std::copy(&buffer[0], res.ptr, stream_it);
223 if constexpr (detail::decays_to_ignore_v<seq_type>)
225 throw std::logic_error{
"The SEQ field may not be set to ignore when writing genbank files."};
227 else if (std::ranges::empty(
sequence))
229 throw std::runtime_error{
"The SEQ field may not be empty when writing genbank files."};
238 while (bp < 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::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
constexpr void consume(rng_t &&rng)
Iterate over a range (consumes single-pass input ranges).
Definition: misc.hpp:28
constexpr auto take_until
A view adaptor that returns elements from the underlying range until the functor evaluates to true (o...
Definition: take_until_view.hpp:584
constexpr auto take_until_or_throw_and_consume
A view adaptor that returns elements from the underlying range until the functor evaluates to true (t...
Definition: take_until_view.hpp:626
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_view.hpp:598
constexpr auto istreambuf
A view factory that returns a view over the stream buffer of an input stream.
Definition: istreambuf_view.hpp:110
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_view.hpp:85
constexpr void write_eol(it_t &it, bool const add_cr)
Write "\n" or "\r\n" to the stream iterator, depending on arguments.
Definition: misc.hpp:48
@ 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
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: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:379
The generic concept for a (biological) sequence.
Provides seqan3::views::interleave.
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.
Adaptations of concepts from the Ranges TS.
Provides seqan3::sequence_file_output_options.
Provides std::from_chars and std::to_chars if not defined in the stdlib <charconv> header.
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:23
bool embl_genbank_complete_header
Complete header given for embl or genbank.
Definition: output_options.hpp:43
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.