35 #include <seqan3/io/detail/record.hpp> 113 template <
typename t>
116 SEQAN3_CONCEPT AlignmentFileInputTraits = requires (t v)
119 requires WritableAlphabet<typename t::sequence_alphabet>;
120 requires WritableAlphabet<typename t::sequence_legal_alphabet>;
121 requires ExplicitlyConvertibleTo<typename t::sequence_legal_alphabet, typename t::sequence_alphabet>;
122 requires SequenceContainer<typename t::template sequence_container<typename t::sequence_alphabet>>;
125 requires WritableAlphabet<typename t::id_alphabet>;
126 requires SequenceContainer<typename t::template id_container<typename t::id_alphabet>>;
129 requires WritableQualityAlphabet<typename t::quality_alphabet>;
130 requires SequenceContainer<typename t::template quality_container<typename t::quality_alphabet>>;
137 Alphabet<reference_t<detail::transformation_trait_or_t<reference<typename t::ref_sequences>, dna4_vector>>>);
140 requires Alphabet<reference_t<reference_t<typename t::ref_ids>>> &&
142 WritableAlphabet<reference_t<reference_t<typename t::ref_ids>>>);
185 template <
typename ref_sequences_t = ref_info_not_given,
typename ref_
ids_t = std::deque<std::
string>>
200 template <
typename _sequence_alphabet>
207 template <
typename _
id_alphabet>
214 template <
typename _quality_alphabet>
408 using dummy_ref_type = decltype(
view::repeat_n(
typename traits_type::sequence_alphabet{},
size_t{}) |
416 using sequence_type =
typename traits_type::template sequence_container<
418 typename traits_type::sequence_alphabet>;
420 using id_type =
typename traits_type::template id_container<
421 typename traits_type::id_alphabet>;
433 detail::transformation_trait_or_t<
455 using quality_type =
typename traits_type::template quality_container<
456 typename traits_type::quality_alphabet>;
473 decltype(std::declval<sequence_type &>() |
view::slice(0, 0))>,
474 typename traits_type::template sequence_container<
517 static_assert([] () constexpr
519 for (
field f : selected_field_ids::as_array)
520 if (!field_ids::contains(f))
524 "You selected a field that is not valid for aligment files, please refer to the documentation " 525 "of alignment_file_input::field_ids for the accepted values.");
547 using iterator = detail::in_file_iterator<alignment_file_input>;
589 primary_stream{
new std::ifstream{filename, std::ios_base::in | std::ios::binary}, stream_deleter_default}
613 template <IStream2 stream_t, AlignmentFileInputFormat file_format>
615 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
617 primary_stream{&stream, stream_deleter_noop}
623 template <IStream2 stream_t, AlignmentFileInputFormat file_format>
625 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
627 primary_stream{
new stream_t{std::move(stream)}, stream_deleter_default}
656 typename traits_type::ref_ids & ref_ids,
657 typename traits_type::ref_sequences & ref_sequences,
659 primary_stream{
new std::ifstream{filename, std::ios_base::in | std::ios::binary}, stream_deleter_default}
662 set_references(ref_ids, ref_sequences);
692 template <IStream2 stream_t, AlignmentFileInputFormat file_format>
694 typename traits_type::ref_ids & ref_ids,
695 typename traits_type::ref_sequences & ref_sequences,
696 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
698 primary_stream{&stream, stream_deleter_noop}
701 set_references(ref_ids, ref_sequences);
707 template <IStream2 stream_t, AlignmentFileInputFormat file_format>
709 typename traits_type::ref_ids & ref_ids,
710 typename traits_type::ref_sequences & ref_sequences,
711 file_format
const & SEQAN3_DOXYGEN_ONLY(format_tag),
713 primary_stream{
new stream_t{std::move(stream)}, stream_deleter_default}
716 set_references(ref_ids, ref_sequences);
724 typename traits_type::ref_ids &&,
725 typename traits_type::ref_sequences &&,
728 template <IStream2 stream_t, AlignmentFileInputFormat file_format>
730 typename traits_type::ref_ids &&,
731 typename traits_type::ref_sequences &&,
804 return record_buffer;
837 if (!primary_stream->good())
840 secondary_stream = detail::make_secondary_istream(*primary_stream, filename);
841 detail::set_format(format, filename);
848 template <
typename format_type>
849 void init(format_type
const &)
851 static_assert(meta::in<valid_formats, format_type>::value,
852 "You selected a format that is not in the valid_formats of this file.");
854 format = detail::alignment_file_input_format<format_type>{};
855 secondary_stream = detail::make_secondary_istream(*primary_stream);
883 stream_ptr_t primary_stream{
nullptr, stream_deleter_noop};
885 stream_ptr_t secondary_stream{
nullptr, stream_deleter_noop};
891 using format_type =
typename detail::variant_from_tags<valid_formats, detail::alignment_file_input_format>::type;
900 typename traits_type::ref_sequences
const * reference_sequences_ptr{
nullptr};
913 template <std::ranges::ForwardRange ref_sequences_t>
914 void set_references(
typename traits_type::ref_ids & ref_ids, ref_sequences_t && ref_sequences)
919 reference_sequences_ptr = &ref_sequences;
922 for (
size_t idx = 0; idx < ref_ids.size(); ++idx)
925 header_ptr->ref_dict[header_ptr->ref_ids()[idx]] = idx;
931 void read_next_record()
934 record_buffer.clear();
935 detail::get_or_ignore<field::HEADER_PTR>(record_buffer) = header_ptr.get();
945 auto call_read_func = [
this] (
auto & ref_seq_info)
949 f.read(*secondary_stream,
953 detail::get_or_ignore<field::SEQ>(record_buffer),
954 detail::get_or_ignore<field::QUAL>(record_buffer),
955 detail::get_or_ignore<field::ID>(record_buffer),
956 detail::get_or_ignore<field::OFFSET>(record_buffer),
957 detail::get_or_ignore<field::REF_SEQ>(record_buffer),
958 detail::get_or_ignore<field::REF_ID>(record_buffer),
959 detail::get_or_ignore<field::REF_OFFSET>(record_buffer),
960 detail::get_or_ignore<field::ALIGNMENT>(record_buffer),
961 detail::get_or_ignore<field::FLAG>(record_buffer),
962 detail::get_or_ignore<field::MAPQ>(record_buffer),
963 detail::get_or_ignore<field::MATE>(record_buffer),
964 detail::get_or_ignore<field::TAGS>(record_buffer),
965 detail::get_or_ignore<field::EVALUE>(record_buffer),
966 detail::get_or_ignore<field::BIT_SCORE>(record_buffer));
971 assert(!format.valueless_by_exception());
974 call_read_func(*reference_sequences_ptr);
976 call_read_func(std::ignore);
987 template <IStream2 stream_type,
989 AlignmentFileInputFormat file_format,
990 detail::Fields selected_field_ids>
991 alignment_file_input(stream_type && stream,
993 selected_field_ids
const &)
996 type_list<file_format>,
1000 template <IStream2 stream_type,
1001 AlignmentFileInputFormat file_format,
1002 detail::Fields selected_field_ids>
1003 alignment_file_input(stream_type & stream,
1004 file_format
const &,
1005 selected_field_ids
const &)
1008 type_list<file_format>,
1012 template <IStream2 stream_type,
1013 AlignmentFileInputFormat file_format>
1014 alignment_file_input(stream_type && stream,
1015 file_format
const &)
1018 type_list<file_format>,
1022 template <IStream2 stream_type,
1023 AlignmentFileInputFormat file_format>
1024 alignment_file_input(stream_type & stream,
1025 file_format
const &)
1028 type_list<file_format>,
1034 detail::Fields selected_field_ids>
1038 selected_field_ids
const &)
1039 -> alignment_file_input<alignment_file_input_default_traits<std::remove_reference_t<ref_sequences_t>,
1051 -> alignment_file_input<alignment_file_input_default_traits<std::remove_reference_t<ref_sequences_t>,
1058 template <IStream2 stream_type,
1061 AlignmentFileInputFormat file_format,
1062 detail::Fields selected_field_ids>
1063 alignment_file_input(stream_type && stream,
1066 file_format
const &,
1067 selected_field_ids
const &)
1068 -> alignment_file_input<alignment_file_input_default_traits<std::remove_reference_t<ref_sequences_t>,
1071 type_list<file_format>,
1075 template <IStream2 stream_type,
1078 AlignmentFileInputFormat file_format,
1079 detail::Fields selected_field_ids>
1080 alignment_file_input(stream_type & stream,
1083 file_format
const &,
1084 selected_field_ids
const &)
1085 -> alignment_file_input<alignment_file_input_default_traits<std::remove_reference_t<ref_sequences_t>,
1088 type_list<file_format>,
1092 template <IStream2 stream_type,
1095 AlignmentFileInputFormat file_format>
1096 alignment_file_input(stream_type && stream,
1099 file_format
const &)
1100 -> alignment_file_input<alignment_file_input_default_traits<std::remove_reference_t<ref_sequences_t>,
1103 type_list<file_format>,
1107 template <IStream2 stream_type,
1110 AlignmentFileInputFormat file_format>
1111 alignment_file_input(stream_type & stream,
1114 file_format
const &)
1115 -> alignment_file_input<alignment_file_input_default_traits<std::remove_reference_t<ref_sequences_t>,
1118 type_list<file_format>,
1137 seqan3::detail::Fields selected_field_ids,
1138 seqan3::detail::TypeListOfAlignmentFileInputFormats valid_formats,
1140 struct tuple_size<
seqan3::alignment_file_input<traits_type, selected_field_ids, valid_formats, stream_char_t>>
1143 static constexpr
size_t value = selected_field_ids::as_array.
size();
1151 template <
size_t elem_no,
1153 seqan3::detail::Fields selected_field_ids,
1154 seqan3::detail::TypeListOfAlignmentFileInputFormats valid_formats,
1156 struct tuple_element<elem_no,
seqan3::alignment_file_input<traits_type, selected_field_ids, valid_formats, stream_char_t>>
1157 : tuple_element<elem_no, typename seqan3::alignment_file_input<traits_type,
1160 stream_char_t>::file_as_tuple_type>
Provides quality alphabet composites.
A combined alphabet that can hold values of either of its alternatives.
Definition: alphabet_variant.hpp:205
The (reference) "sequence" information, usually a range of nucleotides or amino acids.
The "sequence", usually a range of nucleotides or amino acids.
Provides exceptions used in the I/O module.
The (pairwise) alignment stored in an seqan3::alignment object.
The alignment flag (bit information), uint16_t value.
The class template that file records are based on; behaves like an std::tuple.
Definition: record.hpp:187
Provides seqan3::aa27, container aliases and string literals.
SeqAn specific customisations in the standard namespace.
The 15 letter DNA alphabet, containing all IUPAC smybols minus the gap.
Definition: dna15.hpp:48
::ranges::size size
Alias for ranges::size. Obtains the size of a range whose size can be calculated in constant time...
Definition: ranges:189
The main SeqAn3 namespace.
The qualities, usually in phred-score notation.
The e-value (length normalized bit score), double value.
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition: slice.hpp:144
Provides seqan3::concatenated_sequences.
Sequence (REF_SEQ) relative start position (0-based), unsigned value.
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:127
The five letter DNA alphabet of A,C,G,T and the unknown character N.
Definition: dna5.hpp:48
Provides alphabet adaptations for standard char types.
Provides seqan3::TupleLike.
Provides seqan3::view::repeat_n.
Provides the seqan3::record template and the seqan3::field enum.
Sequence (SEQ) relative start position (0-based), unsigned value.
The identifier, usually a string.
Adaptations of concepts from the Ranges TS.
The mate pair information given as a std::tuple of reference name, offset and template length...
The identifier of the (reference) sequence that SEQ was aligned to.
A pointer to the seqan3::alignment_file_header object storing header information. ...
Provides seqan3::phred42 quality scores.
Provides helper data structures for the seqan3::alignment_file_output.
Provides various type traits on generic types.
Provides seqan3::view::slice.
::ranges::default_sentinel_t default_sentinel_t
Alias for ranges::default_sentinel_t. Type of ranges::default_sentinel.
Definition: iterator:351
Meta-header for the nucleotide submodule; includes all headers from alphabet/nucleotide/.
meta::list< types... > type_list
Type that contains multiple types, an alias for meta::list.
Definition: type_list.hpp:27
Exposes the reference of another type.
Definition: pre.hpp:70
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition: repeat_n.hpp:97
field
An enumerator for the fields used in file formats.Some of the fields are shared between formats...
Definition: record.hpp:63
The optional tags in the SAM format, stored in a dictionary.
Specifies requirements of a Range type for which begin returns a type that models std::ForwardIterato...
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.
Quality type for traditional Sanger and modern Illumina Phred scores (typical range).
Definition: phred42.hpp:43
Provides the seqan3::detail::in_file_iterator class template.
Provides seqan3::gap_decorator.
constexpr auto transform
A range adaptor that takes a invocable and returns a view of the elements with the invocable applied...
Definition: ranges:911
The bit score (statistical significance indicator), unsigned value.
The mapping quality of the SEQ alignment, usually a ohred-scaled score.
The concept Integral is satisfied if and only if T is an integral type.
A gap decorator allows the annotation of sequences with gap symbols while leaving the underlying sequ...
Definition: gap_decorator.hpp:83
The SAM tag dictionary class that stores all optional SAM fields.
Definition: sam_tag_dictionary.hpp:324
This header includes C++17 filesystem support and imports it into namespace seqan3::filesystem (indep...