36 #include <seqan3/io/detail/record.hpp>
141 template <
typename t>
156 requires std::is_floating_point_v<typename t::bpp_prob>;
157 requires std::numeric_limits<typename t::bpp_partner>::is_integer;
173 requires std::is_same_v<typename t::structure_alphabet, dssp9>
178 requires std::is_base_of_v<alphabet_tuple_base
179 <
typename t::template structured_seq_alphabet
180 <
typename t::seq_alphabet,
typename t::structure_alphabet>,
181 typename t::seq_alphabet,
typename t::structure_alphabet>,
182 typename t::template structured_seq_alphabet<typename t::seq_alphabet, typename t::structure_alphabet>>;
189 requires std::is_floating_point_v<typename t::energy_type::value_type>;
192 requires std::is_floating_point_v<typename t::react_type>;
200 requires std::numeric_limits<typename t::offset_type>::is_integer;
237 template <
typename _seq_alphabet>
246 template <
typename _
id_alphabet>
258 template <
typename _bpp_prob,
typename _bpp_partner>
259 using bpp_item = std::pair<_bpp_prob, _bpp_partner>;
262 template <
typename _bpp_item>
266 template <
typename _bpp_queue>
275 template <
typename _structure_alphabet>
281 template <
typename _seq_alphabet,
typename _structure_alphabet>
285 template <
typename _structured_seq_alphabet>
299 template <
typename _react_type>
308 template <
typename _comment_alphabet>
334 template <
typename _seq_alphabet,
typename _structure_alphabet>
496 static_assert([]() constexpr
498 for (
field f : selected_field_ids::as_array)
499 if (!field_ids::contains(f))
503 "You selected a field that is not valid for structure files, please refer to the documentation "
504 "of structure_file_input::field_ids for the accepted values.");
506 static_assert([]() constexpr
511 }(),
"You may not select field::structured_seq and either of field::seq and field::structure "
512 "at the same time.");
520 using seq_type =
typename traits_type::template seq_container<typename traits_type::seq_alphabet>;
522 using id_type =
typename traits_type::template id_container<typename traits_type::id_alphabet>;
524 using bpp_type =
typename traits_type::template bpp_container
525 <
typename traits_type::template bpp_queue
526 <
typename traits_type::template bpp_item
527 <
typename traits_type::bpp_prob,
typename traits_type::bpp_partner>>>;
530 <
typename traits_type::structure_alphabet>;
533 <
typename traits_type::template structured_seq_alphabet
534 <
typename traits_type::seq_alphabet,
typename traits_type::structure_alphabet>>;
538 using react_type =
typename traits_type::template react_container<typename traits_type::react_type>;
541 <
typename traits_type::comment_alphabet>;
569 using iterator = detail::in_file_iterator<structure_file_input>;
610 primary_stream{
new std::ifstream{}, stream_deleter_default}
612 primary_stream->rdbuf()->pubsetbuf(stream_buffer.data(), stream_buffer.size());
613 static_cast<std::basic_ifstream<char> *
>(primary_stream.get())->open(filename,
614 std::ios_base::in | std::ios::binary);
616 if (!primary_stream->good())
617 throw file_open_error{
"Could not open file " + filename.string() +
" for reading."};
620 secondary_stream = detail::make_secondary_istream(*primary_stream, filename);
623 detail::set_format(format, filename);
641 template <input_stream stream_t, structure_file_input_format file_format>
643 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
char>
646 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
648 primary_stream{&stream, stream_deleter_noop},
649 format{detail::structure_file_input_format_exposer<file_format>{}}
651 static_assert(list_traits::contains<file_format, valid_formats>,
652 "You selected a format that is not in the valid_formats of this file.");
655 secondary_stream = detail::make_secondary_istream(*primary_stream);
659 template <input_stream stream_t, structure_file_input_format file_format>
661 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
char>
664 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
666 primary_stream{
new stream_t{std::move(stream)}, stream_deleter_default},
667 format{detail::structure_file_input_format_exposer<file_format>{}}
669 static_assert(list_traits::contains<file_format, valid_formats>,
670 "You selected a format that is not in the valid_formats of this file.");
673 secondary_stream = detail::make_secondary_istream(*primary_stream);
698 if (!first_record_was_read)
701 first_record_was_read =
true;
766 std::vector<char> stream_buffer{std::vector<char>(1'000'000)};
773 using stream_ptr_t = std::unique_ptr<std::basic_istream<stream_char_type>,
774 std::function<void(std::basic_istream<stream_char_type>*)>>;
776 static void stream_deleter_noop(std::basic_istream<stream_char_type> *) {}
778 static void stream_deleter_default(std::basic_istream<stream_char_type> * ptr) {
delete ptr; }
781 stream_ptr_t primary_stream{
nullptr, stream_deleter_noop};
783 stream_ptr_t secondary_stream{
nullptr, stream_deleter_noop};
786 bool first_record_was_read{
false};
791 using format_type =
typename detail::variant_from_tags<
valid_formats,
792 detail::structure_file_input_format_exposer>::type;
798 void read_next_record()
801 record_buffer.
clear();
804 if ((std::istreambuf_iterator<stream_char_type>{*secondary_stream} ==
805 std::istreambuf_iterator<stream_char_type>{}))
811 assert(!format.valueless_by_exception());
812 std::visit([&] (
auto & f)
818 "You may not select field::structured_seq and field::structure at the same time.");
820 "You may not select field::structured_seq and field::seq at the same time.");
821 f.read_structure_record(*secondary_stream,
823 detail::get_or_ignore<field::structured_seq>(record_buffer),
824 detail::get_or_ignore<field::id>(record_buffer),
825 detail::get_or_ignore<field::bpp>(record_buffer),
826 detail::get_or_ignore<field::structured_seq>(record_buffer),
827 detail::get_or_ignore<field::energy>(record_buffer),
828 detail::get_or_ignore<field::react>(record_buffer),
829 detail::get_or_ignore<field::react_err>(record_buffer),
830 detail::get_or_ignore<field::comment>(record_buffer),
831 detail::get_or_ignore<field::offset>(record_buffer));
835 f.read_structure_record(*secondary_stream,
837 detail::get_or_ignore<field::seq>(record_buffer),
838 detail::get_or_ignore<field::id>(record_buffer),
839 detail::get_or_ignore<field::bpp>(record_buffer),
840 detail::get_or_ignore<field::structure>(record_buffer),
841 detail::get_or_ignore<field::energy>(record_buffer),
842 detail::get_or_ignore<field::react>(record_buffer),
843 detail::get_or_ignore<field::react_err>(record_buffer),
844 detail::get_or_ignore<field::comment>(record_buffer),
845 detail::get_or_ignore<field::offset>(record_buffer));
860 template <input_stream stream_type,
862 detail::fields_specialisation selected_field_ids>
869 template <input_stream stream_type,
Provides seqan3::aa27, container aliases and string literals.
Provides alphabet adaptations for standard char types.
The twenty-seven letter amino acid alphabet.
Definition: aa27.hpp:46
The protein structure alphabet of the characters "HGIEBTSCX".
Definition: dssp9.hpp:63
The 15 letter RNA alphabet, containing all IUPAC smybols minus the gap.
Definition: rna15.hpp:51
The five letter RNA alphabet of A,C,G,U and the unknown character N.
Definition: rna5.hpp:49
A seqan3::alphabet_tuple_base that joins an aminoacid alphabet with a protein structure alphabet.
Definition: structured_aa.hpp:56
A seqan3::alphabet_tuple_base that joins a nucleotide alphabet with an RNA structure alphabet.
Definition: structured_rna.hpp:57
Provides the dssp format for protein structure.
This header includes C++17 filesystem support and imports it into namespace std::filesystem (independ...
field
An enumerator for the fields used in file formats.
Definition: record.hpp:63
@ energy
Energy of a folded sequence, represented by one float number.
@ comment
Comment field of arbitrary content, usually a string.
@ structure
Fixed interactions, usually a string of structure alphabet characters.
@ bpp
Base pair probability matrix of interactions, usually a matrix of float numbers.
@ react
Reactivity values of the sequence characters given in a vector of float numbers.
@ react_err
Reactivity error values given in a vector corresponding to seqan3::field::react.
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
@ structured_seq
Sequence and fixed interactions combined in one range.
@ id
The identifier, usually a string.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
constexpr bool contains
Whether a type occurs in a type list or not.
Definition: traits.hpp:231
Provides the seqan3::detail::in_file_iterator class template.
Resolves to std::ranges::explicitly_convertible_to<type1, type2>(). <dl class="no-api">This entity i...
A concept that indicates whether an alphabet represents RNA structure.
A more refined container concept than seqan3::container.
Refines seqan3::alphabet and adds assignability.
Provides exceptions used in the I/O module.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides seqan3::rna15, container aliases and string literals.
Provides seqan3::rna5, container aliases and string literals.
A class template that holds a choice of seqan3::field.
Definition: record.hpp:128
void clear() noexcept(noexcept(std::apply(expander, std::declval< record & >())))
Clears containers that provide .clear() and (re-)initialises all other elements with = {}.
Definition: record.hpp:235
Type that contains multiple types.
Definition: type_list.hpp:29
Provides seqan3::structure_record.
Provides the composite of aminoacid with structure alphabets.
Provides traits for seqan3::type_list.
Provides C++20 additions to the type_traits header.
Adaptations of concepts from the standard library.