SeqAn3 3.2.0
The Modern C++ library for sequence analysis.
input_format_concept.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
13#pragma once
14
15#include <fstream>
16#include <optional>
17#include <string>
18#include <vector>
19
31
32namespace seqan3::detail
33{
34
45template <typename format_type>
46struct sam_file_input_format_exposer : public format_type
47{
48public:
49 // Can't use `using format_type::read_alignment_record` as it produces a hard failure in the format concept check
50 // for types that do not model the format concept, i.e. don't offer the proper read_alignment_record interface.
52 template <typename... ts>
53 void read_alignment_record(ts &&... args)
54 {
55 format_type::read_alignment_record(std::forward<ts>(args)...);
56 }
57};
58
59} // namespace seqan3::detail
60
61namespace seqan3
62{
63
77template <typename t>
78concept sam_file_input_format = requires (detail::sam_file_input_format_exposer<t> & v,
79 std::ifstream & stream,
80 sam_file_input_options<dna5> & options,
81 std::vector<dna5_vector> & ref_sequences,
82 sam_file_header<> & header,
83 std::streampos & position_buffer,
84 dna5_vector & seq,
87 int32_t & offset,
88 dna5_vector & ref_seq,
93 sam_flag & flag,
94 uint8_t & mapq,
96 sam_tag_dictionary & tag_dict,
97 double & e_value,
98 double & bit_score) {
99 t::file_extensions;
100 // std::same_as<decltype(t::file_extensions), std::vector<std::string>>;
101
102 {
103 v.read_alignment_record(stream,
104 options,
105 ref_sequences,
106 header,
107 position_buffer,
108 seq,
109 qual,
110 id,
111 offset,
112 ref_seq,
113 ref_id,
114 ref_offset,
115 align,
116 cigar,
117 flag,
118 mapq,
119 mate,
120 tag_dict,
121 e_value,
122 bit_score)
123 };
124
125 {
126 v.read_alignment_record(stream,
127 options,
128 std::ignore,
129 header,
130 position_buffer,
131 std::ignore,
132 std::ignore,
133 std::ignore,
134 std::ignore,
135 std::ignore,
136 std::ignore,
137 std::ignore,
138 std::ignore,
139 std::ignore,
140 std::ignore,
141 std::ignore,
142 std::ignore,
143 std::ignore,
144 std::ignore,
145 std::ignore)
146 };
147 };
149
229
230} // namespace seqan3
231
232namespace seqan3::detail
233{
234
240template <typename t>
241constexpr bool is_type_list_of_sam_file_input_formats_v = false;
242
248template <typename... ts>
249constexpr bool is_type_list_of_sam_file_input_formats_v<type_list<ts...>> = (sam_file_input_format<ts> && ...);
250
256template <typename t>
257concept type_list_of_sam_file_input_formats = is_type_list_of_sam_file_input_formats_v<t>;
258
259} // namespace seqan3::detail
Provides aliases for qualified.
T align(T... args)
Provides the seqan3::cigar alphabet.
Provides seqan3::dna4, container aliases and string literals.
Provides seqan3::dna5, container aliases and string literals.
Provides seqan3::gapped.
sam_flag
An enum flag that describes the properties of an aligned read (given as a SAM record).
Definition: sam_flag.hpp:76
@ flag
The alignment flag (bit information), uint16_t value.
@ ref_offset
Sequence (seqan3::field::ref_seq) relative start position (0-based), unsigned value.
@ ref_seq
The (reference) "sequence" information, usually a range of nucleotides or amino acids.
@ 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.
@ bit_score
The bit score (statistical significance indicator), unsigned value.
@ 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.
@ ref_id
The identifier of the (reference) sequence that seqan3::field::seq was aligned to.
@ id
The identifier, usually a string.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
@ qual
The qualities, usually in Phred score notation.
Provides the seqan3::sam_file_header class.
The generic concept for alignment file input formats.
void read_alignment_record(stream_type &stream, sam_file_input_options< seq_legal_alph_type > const &options, ref_seqs_type &ref_seqs, header_type &header, stream_pos_type &position_buffer, seq_type &seq, qual_type &qual, id_type &id, offset_type &offset, ref_seq_type &ref_seq, ref_id_type &ref_id, ref_offset_type &ref_offset, align_type &align, cigar_type &cigar_vector, flag_type &flag, mapq_type &mapq, mate_type &mate, tag_dict_type &tag_dict, e_value_type &e_value, bit_score_type &bit_score)
Read from the specified stream and back-insert into the given field buffers.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides seqan3::phred42 quality scores.
Provides seqan3::sam_file_input_options.
Provides helper data structures for the seqan3::sam_file_output.
Provides the seqan3::sam_tag_dictionary class and auxiliaries.
Provides seqan3::type_list.