97 #ifdef SEQAN3_DEPRECATED_310
98 template <
typename stream_type,
99 typename seq_legal_alph_type,
bool seq_qual_combined,
107 qual_type & SEQAN3_DOXYGEN_ONLY(qualities))
109 template <
typename stream_type,
110 typename seq_legal_alph_type,
118 qual_type & SEQAN3_DOXYGEN_ONLY(qualities))
121 auto stream_view = detail::istreambuf(stream);
122 auto stream_it = std::ranges::begin(stream_view);
125 throw parse_error{
"An entry has to start with the code word LOCUS."};
128 if constexpr (!detail::decays_to_ignore_v<id_type>)
132 std::ranges::copy(
std::string_view{
"LOCUS"}, std::cpp20::back_inserter(
id));
134 while (!is_char<'O'>(*std::ranges::begin(stream_view)))
136 std::ranges::copy(stream_view | detail::take_line_or_throw
138 std::cpp20::back_inserter(
id));
144 detail::consume(stream_view | detail::take_until(!
is_blank));
146 auto read_id_until = [&stream_view, &
id] (
auto predicate)
148 std::ranges::copy(stream_view | detail::take_until_or_throw(predicate)
150 std::cpp20::back_inserter(
id));
158 detail::consume(stream_view | detail::take_line_or_throw);
164 detail::consume(stream_view | detail::take_line_or_throw);
167 detail::consume(stream_view | detail::take_line_or_throw);
168 auto constexpr is_end =
is_char<
'/'> ;
169 if constexpr (!detail::decays_to_ignore_v<seq_type>)
171 auto constexpr is_legal_alph = char_is_valid_for<seq_legal_alph_type>;
173 | detail::take_until_or_throw_and_consume(is_end)
176 if (!is_legal_alph(c))
179 "char_is_valid_for<" +
180 detail::type_name_as_string<seq_legal_alph_type> +
181 "> evaluated to false on " +
182 detail::make_printable(c)};
187 std::cpp20::back_inserter(
sequence));
191 detail::consume(stream_view | detail::take_until_or_throw_and_consume(is_end));
197 template <
typename stream_type,
205 qual_type && SEQAN3_DOXYGEN_ONLY(qualities))
207 std::cpp20::ostreambuf_iterator stream_it{stream};
208 size_t sequence_size{0};
209 [[maybe_unused]]
char buffer[50];
210 if constexpr (!detail::decays_to_ignore_v<seq_type>)
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 genbank files."};
218 else if (ranges::empty(
id))
220 throw std::runtime_error{
"The ID field may not be empty when writing genbank files."};
224 std::ranges::copy(
id, stream_it);
229 std::ranges::copy(
id, stream_it);
231 auto res =
std::to_chars(&buffer[0], &buffer[0] +
sizeof(buffer), sequence_size);
232 std::copy(&buffer[0], res.ptr, stream_it);
237 if constexpr (detail::decays_to_ignore_v<seq_type>)
239 throw std::logic_error{
"The SEQ field may not be set to ignore when writing genbank files."};
241 else if (std::ranges::empty(
sequence))
243 throw std::runtime_error{
"The SEQ field may not be empty when writing genbank files."};
252 while (bp < sequence_size)
264 detail::write_eol(stream_it,
false);
267 detail::write_eol(stream_it,
false);
Adaptations of algorithms from the Ranges TS.
Core alphabet concept and free function/type trait wrappers.
Provides seqan3::views::char_to.
Provides seqan3::views::to_char.
Provides various utility functions.
Provides various transformation traits used by the range module.
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
@ id
The identifier, usually a string.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
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
auto const to_char
A view that calls seqan3::to_char() on each element in the input range.
Definition: to_char.hpp:68
auto const char_to
A view over an alphabet, given a range of characters.
Definition: char_to.hpp:72
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 (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.
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:22
bool embl_genbank_complete_header
Complete header given for embl or genbank.
Definition: output_options.hpp:42
Provides seqan3::detail::take_line and seqan3::detail::take_line_or_throw.
Provides seqan3::views::take_until and seqan3::views::take_until_or_throw.
[DEPRECATED] Provides seqan3::views::take.
Provides traits to inspect some information of a type, for example its name.
Provides character predicates for tokenisation.
Provides seqan3::views::chunk.
Provides seqan3::views::interleave.