SeqAn3 3.4.0
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
sam_file/input_format_concept.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
9
10#pragma once
11
12#include <fstream>
13#include <optional>
14#include <string>
15#include <vector>
16
28
29namespace seqan3::detail
30{
31
42template <typename format_type>
43struct sam_file_input_format_exposer : public format_type
44{
45public:
46 // Can't use `using format_type::read_alignment_record` as it produces a hard failure in the format concept check
47 // for types that do not model the format concept, i.e. don't offer the proper read_alignment_record interface.
49 template <typename... ts>
50 void read_alignment_record(ts &&... args)
51 {
52 format_type::read_alignment_record(std::forward<ts>(args)...);
53 }
54};
55
56} // namespace seqan3::detail
57
58namespace seqan3
59{
60
74template <typename t>
75concept sam_file_input_format = requires (detail::sam_file_input_format_exposer<t> & v,
76 std::ifstream & stream,
78 std::vector<dna5_vector> & ref_sequences,
79 sam_file_header<> & header,
80 std::streampos & position_buffer,
81 dna5_vector & seq,
82 std::vector<phred42> & qual,
83 std::string & id,
84 dna5_vector & ref_seq,
85 std::optional<int32_t> & ref_id,
86 std::optional<int32_t> & ref_offset,
87 std::vector<cigar> & cigar,
88 sam_flag & flag,
89 uint8_t & mapq,
90 std::tuple<std::optional<int32_t>, std::optional<int32_t>, int32_t> & mate,
91 sam_tag_dictionary & tag_dict,
92 double & e_value,
93 double & bit_score) {
94 t::file_extensions;
95 // std::same_as<decltype(t::file_extensions), std::vector<std::string>>;
96
97 {
98 v.read_alignment_record(stream,
99 options,
100 ref_sequences,
101 header,
102 position_buffer,
103 seq,
104 qual,
105 id,
106 ref_seq,
107 ref_id,
109 cigar,
110 flag,
111 mapq,
112 mate,
113 tag_dict,
114 e_value,
115 bit_score)
116 };
117
118 {
119 v.read_alignment_record(stream,
120 options,
121 std::ignore,
122 header,
123 position_buffer,
124 std::ignore,
125 std::ignore,
126 std::ignore,
127 std::ignore,
128 std::ignore,
129 std::ignore,
130 std::ignore,
131 std::ignore,
132 std::ignore,
133 std::ignore,
134 std::ignore,
135 std::ignore,
136 std::ignore,
137 std::ignore)
138 };
139};
141
142// Workaround for https://github.com/doxygen/doxygen/issues/9379
143#if SEQAN3_DOXYGEN_ONLY(1) 0
144template <typename t>
147#endif
148
154
222
223} // namespace seqan3
224
225namespace seqan3::detail
226{
227
233template <typename t>
234constexpr bool is_type_list_of_sam_file_input_formats_v = false;
235
241template <typename... ts>
242constexpr bool is_type_list_of_sam_file_input_formats_v<type_list<ts...>> = (sam_file_input_format<ts> && ...);
243
249template <typename t>
250concept type_list_of_sam_file_input_formats = is_type_list_of_sam_file_input_formats_v<t>;
251
252} // namespace seqan3::detail
Provides aliases for qualified.
Provides the seqan3::cigar alphabet.
The seqan3::cigar semialphabet pairs a counter with a seqan3::cigar::operation letter.
Definition alphabet/cigar/cigar.hpp:57
Stores the header information of SAM/BAM files.
Definition header.hpp:47
The generic concept for alignment file input formats.
Definition sam_file/input_format_concept.hpp:146
The SAM tag dictionary class that stores all optional SAM fields.
Definition sam_tag_dictionary.hpp:327
Provides seqan3::dna4, container aliases and string literals.
Provides seqan3::dna5, container aliases and string literals.
T forward(T... args)
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:73
@ flag
The alignment flag (bit information), uint16_t value.
Definition record.hpp:84
@ ref_offset
Sequence (seqan3::field::ref_seq) relative start position (0-based), unsigned value.
Definition record.hpp:81
@ ref_seq
The (reference) "sequence" information, usually a range of nucleotides or amino acids.
Definition record.hpp:80
@ mapq
The mapping quality of the seqan3::field::seq alignment, usually a Phred-scaled score.
Definition record.hpp:86
@ bit_score
The bit score (statistical significance indicator), unsigned value.
Definition record.hpp:90
@ mate
The mate pair information given as a std::tuple of reference name, offset and template length.
Definition record.hpp:85
@ ref_id
The identifier of the (reference) sequence that seqan3::field::seq was aligned to.
Definition record.hpp:79
@ id
The identifier, usually a string.
Definition record.hpp:63
@ seq
The "sequence", usually a range of nucleotides or amino acids.
Definition record.hpp:62
@ qual
The qualities, usually in Phred score notation.
Definition record.hpp:64
Provides the seqan3::sam_file_header class.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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.
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::type_list.
Hide me