20 #include <type_traits> 26 #pragma GCC diagnostic push 27 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 41 #include <seqan3/io/detail/record.hpp> 142 template <
typename t>
145 SEQAN3_CONCEPT structure_file_input_traits = requires(t v)
149 requires writable_alphabet<typename t::seq_alphabet>;
150 requires writable_alphabet<typename t::seq_legal_alphabet>;
151 requires explicitly_convertible_to<typename t::seq_legal_alphabet, typename t::seq_alphabet>;
152 requires sequence_container<typename t::template seq_container<typename t::seq_alphabet>>;
155 requires writable_alphabet<typename t::id_alphabet>;
156 requires sequence_container<typename t::template id_container<typename t::id_alphabet>>;
159 requires std::is_floating_point_v<typename t::bpp_prob>;
176 requires std::is_same_v<typename t::structure_alphabet, dssp9>
177 || rna_structure_alphabet<typename t::structure_alphabet>;
178 requires sequence_container<typename t::template structure_container<typename t::structure_alphabet>>;
182 <
typename t::template structured_seq_alphabet
183 <
typename t::seq_alphabet,
typename t::structure_alphabet>,
184 typename t::seq_alphabet,
typename t::structure_alphabet>,
185 typename t::template structured_seq_alphabet<typename t::seq_alphabet, typename t::structure_alphabet>>;
192 requires std::is_floating_point_v<typename t::energy_type::value_type>;
195 requires std::is_floating_point_v<typename t::react_type>;
196 requires sequence_container<typename t::template react_container<typename t::react_type>>;
199 requires writable_alphabet<typename t::comment_alphabet>;
200 requires sequence_container<typename t::template comment_container<typename t::comment_alphabet>>;
240 template <
typename _seq_alphabet>
249 template <
typename _
id_alphabet>
261 template <
typename _bpp_prob,
typename _bpp_partner>
265 template <
typename _bpp_item>
269 template <
typename _bpp_queue>
278 template <
typename _structure_alphabet>
284 template <
typename _seq_alphabet,
typename _structure_alphabet>
288 template <
typename _structured_seq_alphabet>
302 template <
typename _react_type>
311 template <
typename _comment_alphabet>
337 template <
typename _seq_alphabet,
typename _structure_alphabet>
499 static_assert([]() constexpr
501 for (
field f : selected_field_ids::as_array)
506 "You selected a field that is not valid for structure files, please refer to the documentation " 507 "of structure_file_input::field_ids for the accepted values.");
509 static_assert([]() constexpr
514 }(),
"You may not select field::structured_seq and either of field::seq and field::structure " 515 "at the same time.");
522 using seq_type =
typename traits_type::template seq_container<typename traits_type::seq_alphabet>;
525 using id_type =
typename traits_type::template id_container<typename traits_type::id_alphabet>;
528 <
typename traits_type::template
bpp_queue 529 <
typename traits_type::template
bpp_item 530 <
typename traits_type::bpp_prob,
typename traits_type::bpp_partner>>>;
533 <
typename traits_type::structure_alphabet>;
537 <
typename traits_type::seq_alphabet,
typename traits_type::structure_alphabet>>;
541 using react_type =
typename traits_type::template react_container<typename traits_type::react_type>;
544 <
typename traits_type::comment_alphabet>;
572 using iterator = detail::in_file_iterator<structure_file_input>;
613 primary_stream{
new std::ifstream{filename, std::ios_base::in | std::ios::binary}, stream_deleter_default}
615 if (!primary_stream->good())
619 secondary_stream = detail::make_secondary_istream(*primary_stream, filename);
622 detail::set_format(format, filename);
640 template <input_stream stream_t, structure_file_input_format file_format>
645 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
647 primary_stream{&stream, stream_deleter_noop},
648 format{detail::structure_file_input_format_exposer<file_format>{}}
650 static_assert(list_traits::contains<file_format, valid_formats>,
651 "You selected a format that is not in the valid_formats of this file.");
654 secondary_stream = detail::make_secondary_istream(*primary_stream);
658 template <input_stream stream_t, structure_file_input_format file_format>
660 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type,
char>
663 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
665 primary_stream{
new stream_t{
std::move(stream)}, stream_deleter_default},
666 format{detail::structure_file_input_format_exposer<file_format>{}}
668 static_assert(list_traits::contains<file_format, valid_formats>,
669 "You selected a format that is not in the valid_formats of this file.");
672 secondary_stream = detail::make_secondary_istream(*primary_stream);
697 if (!first_record_was_read)
700 first_record_was_read =
true;
778 stream_ptr_t primary_stream{
nullptr, stream_deleter_noop};
780 stream_ptr_t secondary_stream{
nullptr, stream_deleter_noop};
783 bool first_record_was_read{
false};
788 using format_type =
typename detail::variant_from_tags<
valid_formats,
789 detail::structure_file_input_format_exposer>::type;
795 void read_next_record()
798 record_buffer.clear();
808 assert(!format.valueless_by_exception());
815 "You may not select field::structured_seq and field::structure at the same time.");
817 "You may not select field::structured_seq and field::seq at the same time.");
818 f.read_structure_record(*secondary_stream,
820 detail::get_or_ignore<field::structured_seq>(record_buffer),
821 detail::get_or_ignore<field::id>(record_buffer),
822 detail::get_or_ignore<field::bpp>(record_buffer),
823 detail::get_or_ignore<field::structured_seq>(record_buffer),
824 detail::get_or_ignore<field::energy>(record_buffer),
825 detail::get_or_ignore<field::react>(record_buffer),
826 detail::get_or_ignore<field::react_err>(record_buffer),
827 detail::get_or_ignore<field::comment>(record_buffer),
828 detail::get_or_ignore<field::offset>(record_buffer));
832 f.read_structure_record(*secondary_stream,
834 detail::get_or_ignore<field::seq>(record_buffer),
835 detail::get_or_ignore<field::id>(record_buffer),
836 detail::get_or_ignore<field::bpp>(record_buffer),
837 detail::get_or_ignore<field::structure>(record_buffer),
838 detail::get_or_ignore<field::energy>(record_buffer),
839 detail::get_or_ignore<field::react>(record_buffer),
840 detail::get_or_ignore<field::react_err>(record_buffer),
841 detail::get_or_ignore<field::comment>(record_buffer),
842 detail::get_or_ignore<field::offset>(record_buffer));
856 template <input_stream stream_type,
866 template <input_stream stream_type,
868 detail::fields_specialisation selected_field_ids>
872 type_list<file_format>>;
877 #pragma GCC diagnostic pop
A seqan3::alphabet_tuple_base that joins an aminoacid alphabet with a protein structure alphabet...
Definition: structured_aa.hpp:51
The protein structure alphabet of the characters "HGIEBTSCX".
Definition: dssp9.hpp:60
meta::list< types... > type_list
Type that contains multiple types, an alias for meta::list.
Definition: type_list.hpp:31
Provides exceptions used in the I/O module.
Base pair probability matrix of interactions, usually a matrix of float numbers.
The five letter RNA alphabet of A,C,G,U and the unknown character N.
Definition: rna5.hpp:46
The identifier, usually a string.
Provides traits for seqan3::type_list.
Meta-header for the structure module. It includes all headers from alphabet/structure/.
The main SeqAn3 namespace.
The "sequence", usually a range of nucleotides or amino acids.
Provides seqan3::rna5, container aliases and string literals.
Provides seqan3::concatenated_sequences.
Provides seqan3::rna15, container aliases and string literals.
The twenty-seven letter amino acid alphabet.
Definition: aa27.hpp:43
Energy of a folded sequence, represented by one float number.
Thrown if there is an unspecified filesystem or stream error while opening, e.g. permission problem...
Definition: exception.hpp:39
A class template that holds a choice of seqan3::field.
Definition: record.hpp:165
Provides alphabet adaptations for standard char types.
Provides the seqan3::record template and the seqan3::field enum.
Comment field of arbitrary content, usually a string.
The 15 letter RNA alphabet, containing all IUPAC smybols minus the gap.
Definition: rna15.hpp:48
constexpr bool contains
Whether a type occurs in a pack or not.
Definition: traits.hpp:193
Reactivity error values given in a vector corresponding to REACT.
Sequence and fixed interactions combined in one range.
A seqan3::alphabet_tuple_base that joins a nucleotide alphabet with an RNA structure alphabet...
Definition: structured_rna.hpp:52
Sequence (SEQ) relative start position (0-based), unsigned value.
auto const move
A view that turns lvalue-references into rvalue-references.
Definition: move.hpp:68
Fixed interactions, usually a string of structure alphabet characters.
Reactivity values of the sequence characters given in a vector of float numbers.
Meta-header for the aminoacid submodule; includes all headers from alphabet/aminoacid/.
field
An enumerator for the fields used in file formats.Some of the fields are shared between formats...
Definition: record.hpp:64
The concept std::same_as<T, U> is satisfied if and only if T and U denote the same type...
Provides the seqan3::detail::in_file_iterator class template.
This header includes C++17 filesystem support and imports it into namespace seqan3::filesystem (indep...