20 #include <range/v3/view/chunk.hpp>
96 template <
typename stream_type,
97 typename seq_legal_alph_type,
bool seq_qual_combined,
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 = is_in_alphabet<seq_legal_alph_type>;
162 if (!is_legal_alph(c))
166 " evaluated to false on " +
167 detail::make_printable(c)};
172 std::cpp20::back_inserter(
sequence));
182 template <
typename stream_type,
190 qual_type && SEQAN3_DOXYGEN_ONLY(qualities))
192 std::cpp20::ostreambuf_iterator stream_it{stream};
193 size_t sequence_size{0};
194 [[maybe_unused]]
char buffer[50];
195 if constexpr (!detail::decays_to_ignore_v<seq_type>)
199 if constexpr (detail::decays_to_ignore_v<id_type>)
201 throw std::logic_error{
"The ID field may not be set to ignore when writing genbank files."};
203 else if (ranges::empty(
id))
205 throw std::runtime_error{
"The ID field may not be empty when writing genbank files."};
209 std::ranges::copy(
id, stream_it);
214 std::ranges::copy(
id, stream_it);
216 auto res = std::to_chars(&buffer[0], &buffer[0] +
sizeof(buffer), sequence_size);
217 std::copy(&buffer[0], res.ptr, stream_it);
222 if constexpr (detail::decays_to_ignore_v<seq_type>)
224 throw std::logic_error{
"The SEQ field may not be set to ignore when writing genbank files."};
226 else if (std::ranges::empty(
sequence))
228 throw std::runtime_error{
"The SEQ field may not be empty when writing genbank files."};
237 while (bp < sequence_size)
249 detail::write_eol(stream_it,
false);
252 detail::write_eol(stream_it,
false);
Adaptations of algorithms from the Ranges TS.
Provides seqan3::views::char_to.
Provides seqan3::dna5, container aliases and string literals.
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
constexpr sequenced_policy seq
Global execution policy object for sequenced execution policy.
Definition: execution.hpp:54
@ id
The identifier, usually a string.
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:116
seqan3::type_list< trait_t< pack_t >... > transform
Apply a transformation trait to every type in the pack and return a seqan3::type_list of the results.
Definition: traits.hpp:307
auto const to_char
A view that calls seqan3::to_char() on each element in the input range.
Definition: to_char.hpp:65
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.hpp:624
constexpr auto istreambuf
A view factory that returns a view over the stream buffer of an input stream.
Definition: istreambuf.hpp:113
constexpr auto take_until
A view adaptor that returns elements from the underlying range until the functor evaluates to true (o...
Definition: take_until.hpp:610
auto const char_to
A view over an alphabet, given a range of characters.
Definition: char_to.hpp:69
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.hpp:652
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.hpp:90
constexpr auto interleave
A view that interleaves a given range into another range at regular intervals.
Definition: interleave.hpp:384
The generic concept for a sequence.
Provides seqan3::views::interleave.
Provides various utility functions.
Provides seqan3::fast_istreambuf_iterator and seqan3::fast_ostreambuf_iterator, as well as,...
Provides seqan3::views::istreambuf.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
SeqAn specific customisations in the standard namespace.
Provides character predicates for tokenisation.
Provides various utility functions.
Provides various transformation traits used by the range module.
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 stl <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:22
bool embl_genbank_complete_header
Complete header given for embl or genbank.
Definition: output_options.hpp:42
Provides seqan3::views::take.
Provides seqan3::views::take_line and seqan3::views::take_line_or_throw.
Provides seqan3::views::take_until and seqan3::views::take_until_or_throw.
Provides seqan3::views::to_char.