SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
sam_file/input.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <cassert>
13#include <concepts>
14#include <filesystem>
15#include <fstream>
16#include <ranges>
17#include <string>
18#include <variant>
19#include <vector>
20
30#include <seqan3/io/detail/record.hpp>
43
44namespace seqan3
45{
46
47// ---------------------------------------------------------------------------------------------------------------------
48// sam_file_input_traits
49// ---------------------------------------------------------------------------------------------------------------------
50
109template <typename t>
110concept sam_file_input_traits =
111 requires (t v) {
112 // field::seq
117
118 // field::id
120
121 // field::qual
124
125 // field::ref_seq
126 // either ref_info_not_given or a range over ranges over alphabet (e.g. std::vector<dna4_vector>)
127 requires std::same_as<typename t::ref_sequences, ref_info_not_given>
128 || requires () {
129 requires alphabet<std::ranges::range_reference_t<
130 std::ranges::range_reference_t<typename t::ref_sequences>>>;
131 };
132
133 // field::ref_id
135 && (!std::same_as<typename t::ref_sequences, ref_info_not_given>
137 std::ranges::range_reference_t<std::ranges::range_reference_t<typename t::ref_ids>>>);
138 requires std::ranges::forward_range<std::ranges::range_reference_t<typename t::ref_ids>>;
139 requires std::ranges::forward_range<typename t::ref_ids>;
140
141 // field::ref_offset is fixed to std::optional<int32_t>
142 // field::flag is fixed to seqan3::sam_flag
143 // field::mapq is fixed to uint8_t
144 // field::evalue is fixed to double
145 // field::bitscore is fixed to double
146 // field::mate is fixed to std::tuple<ref_id_container<ref_id_alphabet>, ref_offset_type, int32_t>
147 };
149
150// ---------------------------------------------------------------------------------------------------------------------
151// sam_file_input_default_traits
152// ---------------------------------------------------------------------------------------------------------------------
153
169template <typename ref_sequences_t = ref_info_not_given, typename ref_ids_t = std::deque<std::string>>
171{
179
182
184 template <typename _sequence_alphabet>
186
188 template <typename _id_alphabet>
190
193
195 template <typename _quality_alphabet>
197
199 using ref_sequences = ref_sequences_t;
200
202 using ref_ids = ref_ids_t;
204};
205
206// ---------------------------------------------------------------------------------------------------------------------
207// sam_file_input
208// ---------------------------------------------------------------------------------------------------------------------
209
225template <sam_file_input_traits traits_type_ = sam_file_input_default_traits<>,
226 detail::fields_specialisation selected_field_ids_ = fields<field::seq,
227 field::id,
228 field::ref_id,
229 field::ref_offset,
230 field::cigar,
231 field::mapq,
232 field::qual,
233 field::flag,
234 field::mate,
235 field::tags,
236 field::header_ptr>,
237 detail::type_list_of_sam_file_input_formats valid_formats_ = type_list<format_sam, format_bam>>
239{
240public:
246 using traits_type = traits_type_;
248 using selected_field_ids = selected_field_ids_;
250 using valid_formats = valid_formats_;
252 using stream_char_type = char;
254
255private:
257 using dummy_ref_type = decltype(views::repeat_n(typename traits_type::sequence_alphabet{}, size_t{})
258 | std::views::transform(detail::access_restrictor_fn{}));
259
261 using ref_sequence_unsliced_type = detail::lazy_conditional_t<
262 std::ranges::range<typename traits_type::ref_sequences const>,
263 detail::lazy<std::ranges::range_reference_t, typename traits_type::ref_sequences const>,
264 dummy_ref_type>;
265
267 using ref_sequence_sliced_type = decltype(std::declval<ref_sequence_unsliced_type>() | views::slice(0, 0));
268
269public:
278 using id_type = typename traits_type::template id_container<char>;
286 dummy_ref_type,
287 ref_sequence_sliced_type>;
304 using mapq_type = uint8_t;
306 using quality_type = typename traits_type::template quality_container<typename traits_type::quality_alphabet>;
315
318 id_type,
322 mapq_type,
324 flag_type,
325 mate_type,
327 header_type *>;
328
349 field::id,
359
360 static_assert(!selected_field_ids::contains(field::alignment),
361 "The seqan3::field::alignment was removed from the allowed fields for seqan3::sam_file_input. "
362 "Only seqan3::field::cigar is supported. Please see seqan3::alignment_from_cigar on how to get an "
363 "alignment from the cigar information.");
364
365 static_assert(!selected_field_ids::contains(field::offset),
366 "The field::offset is deprecated. Please access field::cigar and retrieve the soft clipping (S) "
367 "value at the front of the CIGAR string (offset = 0 if there is no soft clipping at the front).");
368
369 static_assert(
370 []() constexpr
371 {
372 for (field f : selected_field_ids::as_array)
373 if (!field_ids::contains(f))
374 return false;
375 return true;
376 }(),
377 "You selected a field that is not valid for SAM files, please refer to the documentation "
378 "of sam_file_input::field_ids for the accepted values.");
379
384
394 using const_reference = void;
396 using size_type = size_t;
400 using iterator = detail::in_file_iterator<sam_file_input>;
402 using const_iterator = void;
404 using sentinel = std::default_sentinel_t;
406
411 sam_file_input() = delete;
421 ~sam_file_input() = default;
422
441 selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
442 primary_stream{new std::ifstream{}, stream_deleter_default}
443 {
444 init_by_filename(std::move(filename));
445 }
446
466 template <input_stream stream_t, sam_file_input_format file_format>
467 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type, stream_char_type>
468 sam_file_input(stream_t & stream,
469 file_format const & SEQAN3_DOXYGEN_ONLY(format_tag),
470 selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
471 primary_stream{&stream, stream_deleter_noop}
472 {
473 init_by_format<file_format>();
474 }
475
477 template <input_stream stream_t, sam_file_input_format file_format>
478 requires std::same_as<typename std::remove_reference_t<stream_t>::char_type, stream_char_type>
479 sam_file_input(stream_t && stream,
480 file_format const & SEQAN3_DOXYGEN_ONLY(format_tag),
481 selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
482 primary_stream{new stream_t{std::move(stream)}, stream_deleter_default}
483 {
484 init_by_format<file_format>();
485 }
486
516 typename traits_type::ref_ids & ref_ids,
517 typename traits_type::ref_sequences & ref_sequences,
518 selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
519 primary_stream{new std::ifstream{}, stream_deleter_default}
520 {
521 // initialize reference information
522 set_references(ref_ids, ref_sequences);
523
524 init_by_filename(std::move(filename));
525 }
526
557 template <input_stream stream_t, sam_file_input_format file_format>
558 sam_file_input(stream_t & stream,
559 typename traits_type::ref_ids & ref_ids,
560 typename traits_type::ref_sequences & ref_sequences,
561 file_format const & SEQAN3_DOXYGEN_ONLY(format_tag),
562 selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
563 primary_stream{&stream, stream_deleter_noop}
564 {
565 // initialize reference information
566 set_references(ref_ids, ref_sequences);
567
568 init_by_format<file_format>();
569 }
570
572 template <input_stream stream_t, sam_file_input_format file_format>
573 sam_file_input(stream_t && stream,
574 typename traits_type::ref_ids & ref_ids,
575 typename traits_type::ref_sequences & ref_sequences,
576 file_format const & SEQAN3_DOXYGEN_ONLY(format_tag),
577 selected_field_ids const & SEQAN3_DOXYGEN_ONLY(fields_tag) = selected_field_ids{}) :
578 primary_stream{new stream_t{std::move(stream)}, stream_deleter_default}
579 {
580 // initialize reference information
581 set_references(ref_ids, ref_sequences);
582
583 init_by_format<file_format>();
584 }
585
587 // explicitly delete rvalues for reference information
589 typename traits_type::ref_ids &&,
590 typename traits_type::ref_sequences &&,
591 selected_field_ids const &) = delete;
592
593 template <input_stream stream_t, sam_file_input_format file_format>
594 sam_file_input(stream_t &&,
595 typename traits_type::ref_ids &&,
596 typename traits_type::ref_sequences &&,
597 file_format const &,
598 selected_field_ids const &) = delete;
601
623 {
624 // buffer first record
625 if (!first_record_was_read)
626 {
627 read_next_record();
628 first_record_was_read = true;
629 }
630
631 return {*this};
632 }
633
647 sentinel end() noexcept
648 {
649 return {};
650 }
651
675 reference front() noexcept
676 {
677 return *begin();
678 }
680
683
697 {
698 // make sure header is read
699 if (!first_record_was_read)
700 {
701 read_next_record();
702 first_record_was_read = true;
703 }
704
705 return *header_ptr;
706 }
707
708protected:
710
712 void init_by_filename(std::filesystem::path filename)
713 {
714 primary_stream->rdbuf()->pubsetbuf(stream_buffer.data(), stream_buffer.size());
715 static_cast<std::basic_ifstream<char> *>(primary_stream.get())
716 ->open(filename, std::ios_base::in | std::ios::binary);
717 // open stream
718 if (!primary_stream->good())
719 throw file_open_error{"Could not open file " + filename.string() + " for reading."};
720
721 secondary_stream = detail::make_secondary_istream(*primary_stream, filename);
722 detail::set_format(format, filename);
723 }
724
726 template <typename format_type>
727 void init_by_format()
728 {
729 static_assert(list_traits::contains<format_type, valid_formats>,
730 "You selected a format that is not in the valid_formats of this file.");
731
732 format = detail::sam_file_input_format_exposer<format_type>{};
733 secondary_stream = detail::make_secondary_istream(*primary_stream);
734 }
735
738
743 record_type record_buffer;
745 std::vector<char> stream_buffer{std::vector<char>(1'000'000)};
747 std::streampos position_buffer{};
749
757 static void stream_deleter_noop(std::basic_istream<stream_char_type> *)
758 {}
760 static void stream_deleter_default(std::basic_istream<stream_char_type> * ptr)
761 {
762 delete ptr;
763 }
764
766 stream_ptr_t primary_stream{nullptr, stream_deleter_noop};
768 stream_ptr_t secondary_stream{nullptr, stream_deleter_noop};
769
771 bool first_record_was_read{false};
773 bool at_end{false};
774
776 using format_type = typename detail::variant_from_tags<valid_formats, detail::sam_file_input_format_exposer>::type;
777
779 format_type format;
781
786 typename traits_type::ref_sequences const * reference_sequences_ptr{nullptr};
787
800 template <std::ranges::forward_range ref_sequences_t>
801 void set_references(typename traits_type::ref_ids & ref_ids, ref_sequences_t && ref_sequences)
802 {
803 assert(std::ranges::distance(ref_ids) == std::ranges::distance(ref_sequences));
804
805 header_ptr = std::unique_ptr<header_type>{std::make_unique<header_type>(ref_ids)};
806 reference_sequences_ptr = &ref_sequences;
807
808 // initialise reference map and ref_dict if ref_ids are non-empty
809 for (int32_t idx = 0; idx < std::ranges::distance(ref_ids); ++idx)
810 {
811 header_ptr->ref_id_info.emplace_back(std::ranges::distance(ref_sequences[idx]), "");
812
813 if constexpr (std::ranges::contiguous_range<std::ranges::range_reference_t<typename traits_type::ref_ids>>
814 && std::ranges::sized_range<std::ranges::range_reference_t<typename traits_type::ref_ids>>
815 && std::ranges::borrowed_range<std::ranges::range_reference_t<typename traits_type::ref_ids>>)
816 {
817 auto && id = header_ptr->ref_ids()[idx];
818 header_ptr->ref_dict[std::span{std::ranges::data(id), std::ranges::size(id)}] = idx;
819 }
820 else
821 {
822 header_ptr->ref_dict[header_ptr->ref_ids()[idx]] = idx;
823 }
824 }
825 }
827
829 void read_next_record()
830 {
831 // clear the record
832 record_buffer.clear();
833 detail::get_or_ignore<field::header_ptr>(record_buffer) = header_ptr.get();
834
835 // at end if we could not read further
836 if (std::istreambuf_iterator<stream_char_type>{*secondary_stream}
838 {
839 at_end = true;
840 return;
841 }
842
843 auto call_read_func = [this](auto & ref_seq_info)
844 {
846 [&](auto & f)
847 {
848 f.read_alignment_record(*secondary_stream,
849 options,
850 ref_seq_info,
851 *header_ptr,
852 position_buffer,
853 detail::get_or_ignore<field::seq>(record_buffer),
854 detail::get_or_ignore<field::qual>(record_buffer),
855 detail::get_or_ignore<field::id>(record_buffer),
856 detail::get_or_ignore<field::ref_seq>(record_buffer),
857 detail::get_or_ignore<field::ref_id>(record_buffer),
858 detail::get_or_ignore<field::ref_offset>(record_buffer),
859 detail::get_or_ignore<field::cigar>(record_buffer),
860 detail::get_or_ignore<field::flag>(record_buffer),
861 detail::get_or_ignore<field::mapq>(record_buffer),
862 detail::get_or_ignore<field::mate>(record_buffer),
863 detail::get_or_ignore<field::tags>(record_buffer),
864 detail::get_or_ignore<field::evalue>(record_buffer),
865 detail::get_or_ignore<field::bit_score>(record_buffer));
866 },
867 format);
868 };
869
870 assert(!format.valueless_by_exception());
871
872 if constexpr (!std::same_as<typename traits_type::ref_sequences, ref_info_not_given>)
873 call_read_func(*reference_sequences_ptr);
874 else
875 call_read_func(std::ignore);
876 }
877
879 friend iterator;
880};
881
887template <input_stream stream_type, sam_file_input_format file_format, detail::fields_specialisation selected_field_ids>
888sam_file_input(stream_type && stream, file_format const &, selected_field_ids const &)
889 -> sam_file_input<typename sam_file_input<>::traits_type, // actually use the default
892
894template <input_stream stream_type, sam_file_input_format file_format, detail::fields_specialisation selected_field_ids>
895sam_file_input(stream_type & stream, file_format const &, selected_field_ids const &)
896 -> sam_file_input<typename sam_file_input<>::traits_type, // actually use the default
899
901template <input_stream stream_type, sam_file_input_format file_format>
902sam_file_input(stream_type && stream, file_format const &)
903 -> sam_file_input<typename sam_file_input<>::traits_type, // actually use the default
904 typename sam_file_input<>::selected_field_ids, // actually use the default
906
908template <input_stream stream_type, sam_file_input_format file_format>
909sam_file_input(stream_type & stream, file_format const &)
910 -> sam_file_input<typename sam_file_input<>::traits_type, // actually use the default
911 typename sam_file_input<>::selected_field_ids, // actually use the default
913
915template <std::ranges::forward_range ref_ids_t,
916 std::ranges::forward_range ref_sequences_t,
917 detail::fields_specialisation selected_field_ids>
918sam_file_input(std::filesystem::path path, ref_ids_t &, ref_sequences_t &, selected_field_ids const &)
922 typename sam_file_input<>::valid_formats>; // actually use the default
923
925template <std::ranges::forward_range ref_ids_t, std::ranges::forward_range ref_sequences_t>
926sam_file_input(std::filesystem::path path, ref_ids_t &, ref_sequences_t &) -> sam_file_input<
928 typename sam_file_input<>::selected_field_ids, // actually use the default
929 typename sam_file_input<>::valid_formats>; // actually use the default
930
932template <input_stream stream_type,
933 std::ranges::forward_range ref_ids_t,
934 std::ranges::forward_range ref_sequences_t,
935 sam_file_input_format file_format,
936 detail::fields_specialisation selected_field_ids>
937sam_file_input(stream_type && stream, ref_ids_t &, ref_sequences_t &, file_format const &, selected_field_ids const &)
942
944template <input_stream stream_type,
945 std::ranges::forward_range ref_ids_t,
946 std::ranges::forward_range ref_sequences_t,
947 sam_file_input_format file_format,
948 detail::fields_specialisation selected_field_ids>
949sam_file_input(stream_type & stream, ref_ids_t &, ref_sequences_t &, file_format const &, selected_field_ids const &)
954
956template <input_stream stream_type,
957 std::ranges::forward_range ref_ids_t,
958 std::ranges::forward_range ref_sequences_t,
959 sam_file_input_format file_format>
960sam_file_input(stream_type && stream, ref_ids_t &, ref_sequences_t &, file_format const &) -> sam_file_input<
962 typename sam_file_input<>::selected_field_ids, // actually use the default
964
966template <input_stream stream_type,
967 std::ranges::forward_range ref_ids_t,
968 std::ranges::forward_range ref_sequences_t,
969 sam_file_input_format file_format>
970sam_file_input(stream_type & stream, ref_ids_t &, ref_sequences_t &, file_format const &) -> sam_file_input<
972 typename sam_file_input<>::selected_field_ids, // actually use the default
975
976} // namespace seqan3
Provides seqan3::aa27, container aliases and string literals.
Provides the seqan3::cigar alphabet.
Provides alphabet adaptations for standard char types.
The 15 letter DNA alphabet, containing all IUPAC smybols minus the gap.
Definition dna15.hpp:48
The five letter DNA alphabet of A,C,G,T and the unknown character N.
Definition dna5.hpp:48
Quality type for traditional Sanger and modern Illumina Phred scores.
Definition phred42.hpp:44
Stores the header information of SAM/BAM files.
Definition header.hpp:46
The generic concept for alignment file input formats.
Definition sam_file/input_format_concept.hpp:146
A class for reading SAM files, both SAM and its binary representation BAM are supported.
Definition sam_file/input.hpp:239
sam_file_input(std::filesystem::path path, ref_ids_t &, ref_sequences_t &) -> sam_file_input< sam_file_input_default_traits< std::remove_reference_t< ref_sequences_t >, std::remove_reference_t< ref_ids_t > >, typename sam_file_input<>::selected_field_ids, typename sam_file_input<>::valid_formats >
Deduce ref_sequences_t and ref_ids_t, default the rest.
sentinel end() noexcept
Returns a sentinel for comparison with iterator.
Definition sam_file/input.hpp:647
size_t size_type
An unsigned integer type, usually std::size_t.
Definition sam_file/input.hpp:396
std::optional< int32_t > ref_id_type
The type of field::ref_id is fixed to std::optional<int32_t>.
Definition sam_file/input.hpp:295
void const_reference
The const_reference type is void because files are not const-iterable.
Definition sam_file/input.hpp:394
sam_file_input(std::filesystem::path path, ref_ids_t &, ref_sequences_t &, selected_field_ids const &) -> sam_file_input< sam_file_input_default_traits< std::remove_reference_t< ref_sequences_t >, std::remove_reference_t< ref_ids_t > >, selected_field_ids, typename sam_file_input<>::valid_formats >
Deduce selected fields, ref_sequences_t and ref_ids_t, default the rest.
valid_formats_ valid_formats
A seqan3::type_list with the possible formats.
Definition sam_file/input.hpp:250
char stream_char_type
Character type of the stream(s).
Definition sam_file/input.hpp:252
detail::in_file_iterator< sam_file_input > iterator
The iterator type of this view (an input iterator).
Definition sam_file/input.hpp:400
sam_file_input(stream_type &&stream, ref_ids_t &, ref_sequences_t &, file_format const &) -> sam_file_input< sam_file_input_default_traits< std::remove_reference_t< ref_sequences_t >, std::remove_reference_t< ref_ids_t > >, typename sam_file_input<>::selected_field_ids, type_list< file_format > >
Deduce ref_sequences_t and ref_ids_t, and file format.
sam_file_input(std::filesystem::path filename, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from filename.
Definition sam_file/input.hpp:440
sam_file_input(stream_type &stream, file_format const &) -> sam_file_input< typename sam_file_input<>::traits_type, typename sam_file_input<>::selected_field_ids, type_list< file_format > >
Deduce file_format, and default the rest.
std::default_sentinel_t sentinel
The type returned by end().
Definition sam_file/input.hpp:404
sam_file_input(stream_t &stream, typename traits_type::ref_ids &ref_ids, typename traits_type::ref_sequences &ref_sequences, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from an existing stream and with specified format.
Definition sam_file/input.hpp:558
typename traits_type::template sequence_container< typename traits_type::sequence_alphabet > sequence_type
The type of field::seq (default std::vector<seqan3::dna5>).
Definition sam_file/input.hpp:276
std::optional< int32_t > ref_offset_type
The type of field::ref_offset is fixed to a std::optional<int32_t>.
Definition sam_file/input.hpp:302
traits_type_ traits_type
A traits type that defines aliases and template for storage of the fields.
Definition sam_file/input.hpp:246
sam_file_input(stream_type &stream, ref_ids_t &, ref_sequences_t &, file_format const &) -> sam_file_input< sam_file_input_default_traits< std::remove_reference_t< ref_sequences_t >, std::remove_reference_t< ref_ids_t > >, typename sam_file_input<>::selected_field_ids, type_list< file_format > >
Deduce selected fields, ref_sequences_t and ref_ids_t, and file format.
sam_file_input_options< typename traits_type::sequence_legal_alphabet > options
The options are public and its members can be set directly.
Definition sam_file/input.hpp:682
sam_file_input(stream_type &&stream, file_format const &) -> sam_file_input< typename sam_file_input<>::traits_type, typename sam_file_input<>::selected_field_ids, type_list< file_format > >
Deduce file_format, and default the rest.
sam_file_input(stream_t &stream, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from an existing stream and with specified format.
Definition sam_file/input.hpp:468
sam_file_header< typename traits_type::ref_ids > header_type
The type of field::header_ptr (default: sam_file_header<typename traits_type::ref_ids>).
Definition sam_file/input.hpp:314
typename traits_type::template id_container< char > id_type
The type of field::id (default std::string by default).
Definition sam_file/input.hpp:278
sam_file_input & operator=(sam_file_input &&)=default
Move assignment is defaulted.
sam_file_input(stream_t &&stream, typename traits_type::ref_ids &ref_ids, typename traits_type::ref_sequences &ref_sequences, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition sam_file/input.hpp:573
sam_record< detail::select_types_with_ids_t< field_types, field_ids, selected_field_ids >, selected_field_ids > record_type
The type of the record, a specialisation of seqan3::record; acts as a tuple of the selected field typ...
Definition sam_file/input.hpp:382
sam_file_input()=delete
Default constructor is explicitly deleted, you need to give a stream or file name.
iterator begin()
Returns an iterator to current position in the file.
Definition sam_file/input.hpp:622
selected_field_ids_ selected_field_ids
A seqan3::fields list with the fields selected for the record.
Definition sam_file/input.hpp:248
sam_file_input(stream_type &stream, ref_ids_t &, ref_sequences_t &, file_format const &, selected_field_ids const &) -> sam_file_input< sam_file_input_default_traits< std::remove_reference_t< ref_sequences_t >, std::remove_reference_t< ref_ids_t > >, selected_field_ids, type_list< file_format > >
Deduce selected fields, ref_sequences_t and ref_ids_t, and file format.
sam_file_input(std::filesystem::path filename, typename traits_type::ref_ids &ref_ids, typename traits_type::ref_sequences &ref_sequences, selected_field_ids const &fields_tag=selected_field_ids{})
Construct from filename and given additional reference information.
Definition sam_file/input.hpp:515
sam_file_input & operator=(sam_file_input const &)=delete
Copy assignment is explicitly deleted because you cannot have multiple access to the same file.
sam_file_input(sam_file_input &&)=default
Move construction is defaulted.
void const_iterator
The const iterator type is void because files are not const-iterable.
Definition sam_file/input.hpp:402
header_type & header()
Access the file's header.
Definition sam_file/input.hpp:696
sam_file_input(sam_file_input const &)=delete
Copy construction is explicitly deleted because you cannot have multiple access to the same file.
uint8_t mapq_type
The type of field::mapq is fixed to uint8_t.
Definition sam_file/input.hpp:304
sam_flag flag_type
The type of field::flag is fixed to seqan3::sam_flag.
Definition sam_file/input.hpp:308
sam_file_input(stream_type &&stream, file_format const &, selected_field_ids const &) -> sam_file_input< typename sam_file_input<>::traits_type, selected_field_ids, type_list< file_format > >
Deduce selected fields, file_format, and default the rest.
sam_file_input(stream_t &&stream, file_format const &format_tag, selected_field_ids const &fields_tag=selected_field_ids{})
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition sam_file/input.hpp:479
sam_file_input(stream_type &&stream, ref_ids_t &, ref_sequences_t &, file_format const &, selected_field_ids const &) -> sam_file_input< sam_file_input_default_traits< std::remove_reference_t< ref_sequences_t >, std::remove_reference_t< ref_ids_t > >, selected_field_ids, type_list< file_format > >
Deduce selected fields, ref_sequences_t and ref_ids_t, and file format.
~sam_file_input()=default
Destructor is defaulted.
std::tuple< ref_id_type, ref_offset_type, int32_t > mate_type
The type of field::mate is fixed to std::tuple<ref_id_type, ref_offset_type, int32_t>).
Definition sam_file/input.hpp:312
reference front() noexcept
Return the record we are currently at in the file.
Definition sam_file/input.hpp:675
typename traits_type::template quality_container< typename traits_type::quality_alphabet > quality_type
The type of field::qual (default std::vector<seqan3::phred42>).
Definition sam_file/input.hpp:306
sam_file_input(stream_type &stream, file_format const &, selected_field_ids const &) -> sam_file_input< typename sam_file_input<>::traits_type, selected_field_ids, type_list< file_format > >
Deduce selected fields, file_format, and default the rest.
The SAM tag dictionary class that stores all optional SAM fields.
Definition sam_tag_dictionary.hpp:327
T data(T... args)
Provides seqan3::dna15, container aliases and string literals.
Provides seqan3::dna5, container aliases and string literals.
Provides the seqan3::format_bam.
Provides the seqan3::format_sam.
T format(T... args)
T get(T... args)
sam_flag
An enum flag that describes the properties of an aligned read (given as a SAM record).
Definition sam_flag.hpp:73
field
An enumerator for the fields used in file formats.
Definition record.hpp:60
@ flag
The alignment flag (bit information), uint16_t value.
@ ref_offset
Sequence (seqan3::field::ref_seq) relative start position (0-based), unsigned value.
@ alignment
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
@ cigar
The cigar vector (std::vector<seqan3::cigar>) representing the alignment in SAM/BAM format.
@ mapq
The mapping quality of the seqan3::field::seq alignment, usually a Phred-scaled score.
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
@ mate
The mate pair information given as a std::tuple of reference name, offset and template length.
@ header_ptr
A pointer to the seqan3::sam_file_header object storing header information.
@ ref_id
The identifier of the (reference) sequence that seqan3::field::seq was aligned to.
@ id
The identifier, usually a string.
@ tags
The optional tags in the SAM format, stored in a dictionary.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
@ qual
The qualities, usually in Phred score notation.
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition slice.hpp:175
constexpr auto repeat_n
A view factory that repeats a given value n times.
Definition repeat_n.hpp:88
Provides the seqan3::detail::in_file_iterator class template.
The generic alphabet concept that covers most data types used in ranges.
Checks whether from can be explicitly converted to to.
The requirements a traits_type for seqan3::sam_file_input must meet.
A more refined container concept than seqan3::container.
Refines seqan3::alphabet and adds assignability.
A concept that indicates whether a writable alphabet represents quality scores.
Provides exceptions used in the I/O module.
Stream concepts.
Provides various utility functions required only for input.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
SeqAn specific customisations in the standard namespace.
Provides seqan3::phred42 quality scores.
Provides quality alphabet composites.
Provides seqan3::views::repeat_n.
Provides seqan3::sam_file_input_format and auxiliary classes.
Provides seqan3::sam_record.
Provides helper data structures for the seqan3::sam_file_output.
T size(T... args)
Provides seqan3::views::slice.
A class template that holds a choice of seqan3::field.
Definition record.hpp:125
Thrown if there is an unspecified filesystem or stream error while opening, e.g. permission problem.
Definition io/exception.hpp:36
The default traits for seqan3::sam_file_input.
Definition sam_file/input.hpp:171
ref_ids_t ref_ids
The type of the reference identifiers is deduced on construction.
Definition sam_file/input.hpp:202
ref_sequences_t ref_sequences
The type of the reference sequences is deduced on construction.
Definition sam_file/input.hpp:199
The options type defines various option members that influence the behaviour of all or some formats.
Definition sam_file/input_options.hpp:26
Type that contains multiple types.
Definition type_list.hpp:26
Provides seqan3::detail::transformation_trait_or.
Provides traits for seqan3::type_list.
Provides seqan3::tuple_like.
T visit(T... args)
Hide me