SeqAn3 3.3.0-rc.1
The Modern C++ library for sequence analysis.
sam_file/record.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 <seqan3/io/record.hpp>
16
17namespace seqan3
18{
27template <typename field_types, typename field_ids>
28class sam_record : public record<field_types, field_ids>
29{
32
34 using tuple_base_t = typename base_t::base_type;
35
37 template <field f>
38 using field_constant = typename base_t::template field_constant<f>;
39
40 using base_t::get_impl;
41
42public:
46 sam_record() = default;
47 sam_record(sam_record const &) = default;
48 sam_record & operator=(sam_record const &) = default;
49 sam_record(sam_record &&) = default;
51 ~sam_record() = default;
52
54 using base_t::base_t;
56
60 decltype(auto) id() &&
61 {
62 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t &&>(*this));
63 }
65 decltype(auto) id() const &&
66 {
67 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t const &&>(*this));
68 }
70 decltype(auto) id() &
71 {
72 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t &>(*this));
73 }
75 decltype(auto) id() const &
76 {
77 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t const &>(*this));
78 }
79
83 decltype(auto) sequence() &&
84 {
85 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t &&>(*this));
86 }
88 decltype(auto) sequence() const &&
89 {
90 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t const &&>(*this));
91 }
93 decltype(auto) sequence() &
94 {
95 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t &>(*this));
96 }
98 decltype(auto) sequence() const &
99 {
100 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t const &>(*this));
101 }
102
106 decltype(auto) base_qualities() &&
107 {
108 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t &&>(*this));
109 }
111 decltype(auto) base_qualities() const &&
112 {
113 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t const &&>(*this));
114 }
116 decltype(auto) base_qualities() &
117 {
118 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t &>(*this));
119 }
121 decltype(auto) base_qualities() const &
122 {
123 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t const &>(*this));
124 }
125
135 decltype(auto) sequence_position() &&
136 {
137 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t &&>(*this));
138 }
140 decltype(auto) sequence_position() const &&
141 {
142 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t const &&>(*this));
143 }
145 decltype(auto) sequence_position() &
146 {
147 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t &>(*this));
148 }
150 decltype(auto) sequence_position() const &
151 {
152 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t const &>(*this));
153 }
154
159 decltype(auto) reference_id() &&
160 {
161 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t &&>(*this));
162 }
164 decltype(auto) reference_id() const &&
165 {
166 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t const &&>(*this));
167 }
169 decltype(auto) reference_id() &
170 {
171 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t &>(*this));
172 }
174 decltype(auto) reference_id() const &
175 {
176 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t const &>(*this));
177 }
178
182 decltype(auto) reference_sequence() = delete;
183
188 decltype(auto) reference_position() &&
189 {
190 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t &&>(*this));
191 }
193 decltype(auto) reference_position() const &&
194 {
195 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t const &&>(*this));
196 }
198 decltype(auto) reference_position() &
199 {
200 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t &>(*this));
201 }
203 decltype(auto) reference_position() const &
204 {
205 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t const &>(*this));
206 }
207
213 decltype(auto) header_ptr() &&
214 {
215 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t &&>(*this));
216 }
218 decltype(auto) header_ptr() const &&
219 {
220 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t const &&>(*this));
221 }
223 decltype(auto) header_ptr() &
224 {
225 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t &>(*this));
226 }
228 decltype(auto) header_ptr() const &
229 {
230 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t const &>(*this));
231 }
232
236 decltype(auto) flag() &&
237 {
238 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t &&>(*this));
239 }
241 decltype(auto) flag() const &&
242 {
243 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t const &&>(*this));
244 }
246 decltype(auto) flag() &
247 {
248 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t &>(*this));
249 }
251 decltype(auto) flag() const &
252 {
253 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t const &>(*this));
254 }
255
263 decltype(auto) mate_reference_id() &&
264 {
265 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
266 }
268 decltype(auto) mate_reference_id() const &&
269 {
270 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
271 }
273 decltype(auto) mate_reference_id() &
274 {
275 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
276 }
278 decltype(auto) mate_reference_id() const &
279 {
280 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
281 }
282
286 decltype(auto) mate_position() &&
287 {
288 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
289 }
291 decltype(auto) mate_position() const &&
292 {
293 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
294 }
296 decltype(auto) mate_position() &
297 {
298 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
299 }
301 decltype(auto) mate_position() const &
302 {
303 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
304 }
305
309 decltype(auto) template_length() &&
310 {
311 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
312 }
314 decltype(auto) template_length() const &&
315 {
316 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
317 }
319 decltype(auto) template_length() &
320 {
321 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
322 }
324 decltype(auto) template_length() const &
325 {
326 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
327 }
328
332 decltype(auto) mapping_quality() &&
333 {
334 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t &&>(*this));
335 }
337 decltype(auto) mapping_quality() const &&
338 {
339 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t const &&>(*this));
340 }
342 decltype(auto) mapping_quality() &
343 {
344 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t &>(*this));
345 }
347 decltype(auto) mapping_quality() const &
348 {
349 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t const &>(*this));
350 }
351
355 decltype(auto) cigar_sequence() &&
356 {
357 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t &&>(*this));
358 }
360 decltype(auto) cigar_sequence() const &&
361 {
362 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t const &&>(*this));
363 }
365 decltype(auto) cigar_sequence() &
366 {
367 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t &>(*this));
368 }
370 decltype(auto) cigar_sequence() const &
371 {
372 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t const &>(*this));
373 }
374
378 decltype(auto) tags() &&
379 {
380 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t &&>(*this));
381 }
383 decltype(auto) tags() const &&
384 {
385 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t const &&>(*this));
386 }
388 decltype(auto) tags() &
389 {
390 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t &>(*this));
391 }
393 decltype(auto) tags() const &
394 {
395 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t const &>(*this));
396 }
397};
398} // namespace seqan3
399
400namespace std
401{
402
408template <typename field_types, typename field_ids>
409struct tuple_size<seqan3::sam_record<field_types, field_ids>> :
410 tuple_size<typename seqan3::sam_record<field_types, field_ids>::base_type>
411{};
412
418template <size_t elem_no, typename field_types, typename field_ids>
419struct tuple_element<elem_no, seqan3::sam_record<field_types, field_ids>> :
420 tuple_element<elem_no, typename seqan3::sam_record<field_types, field_ids>::base_type>
421{};
422
423} // namespace std
The record type of seqan3::sam_file_input.
Definition: sam_file/record.hpp:29
decltype(auto) reference_position() const &
(Reference) Sequence (seqan3::sam_record::reference_sequence) relative start position (0-based),...
Definition: sam_file/record.hpp:203
decltype(auto) header_ptr() const &&
A pointer to the seqan3::sam_file_header object storing header information.
Definition: sam_file/record.hpp:218
decltype(auto) flag() const &
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: sam_file/record.hpp:251
decltype(auto) cigar_sequence() &
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: sam_file/record.hpp:365
decltype(auto) mate_reference_id() &&
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: sam_file/record.hpp:263
decltype(auto) sequence_position() const &
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: sam_file/record.hpp:150
decltype(auto) cigar_sequence() &&
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: sam_file/record.hpp:355
decltype(auto) reference_id() const &&
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: sam_file/record.hpp:164
decltype(auto) sequence_position() &&
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: sam_file/record.hpp:135
decltype(auto) base_qualities() const &
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: sam_file/record.hpp:121
decltype(auto) header_ptr() &&
A pointer to the seqan3::sam_file_header object storing header information.
Definition: sam_file/record.hpp:213
decltype(auto) base_qualities() const &&
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: sam_file/record.hpp:111
decltype(auto) template_length() const &
The observed template length. (SAM Column ID: TLEN)
Definition: sam_file/record.hpp:324
decltype(auto) mate_reference_id() const &&
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: sam_file/record.hpp:268
decltype(auto) sequence() &
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: sam_file/record.hpp:93
decltype(auto) mapping_quality() &&
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: sam_file/record.hpp:332
decltype(auto) reference_id() &
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: sam_file/record.hpp:169
decltype(auto) sequence() const &&
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: sam_file/record.hpp:88
decltype(auto) reference_position() &&
(Reference) Sequence (seqan3::sam_record::reference_sequence) relative start position (0-based),...
Definition: sam_file/record.hpp:188
sam_record & operator=(sam_record &&)=default
Defaulted.
decltype(auto) template_length() const &&
The observed template length. (SAM Column ID: TLEN)
Definition: sam_file/record.hpp:314
decltype(auto) mate_position() &
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: sam_file/record.hpp:296
sam_record(sam_record const &)=default
Defaulted.
decltype(auto) tags() const &
The optional tags in the SAM format.
Definition: sam_file/record.hpp:393
decltype(auto) reference_id() &&
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: sam_file/record.hpp:159
decltype(auto) flag() &&
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: sam_file/record.hpp:236
decltype(auto) tags() &
The optional tags in the SAM format.
Definition: sam_file/record.hpp:388
decltype(auto) flag() const &&
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: sam_file/record.hpp:241
decltype(auto) header_ptr() const &
A pointer to the seqan3::sam_file_header object storing header information.
Definition: sam_file/record.hpp:228
decltype(auto) base_qualities() &&
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: sam_file/record.hpp:106
decltype(auto) mapping_quality() &
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: sam_file/record.hpp:342
decltype(auto) template_length() &
The observed template length. (SAM Column ID: TLEN)
Definition: sam_file/record.hpp:319
decltype(auto) tags() const &&
The optional tags in the SAM format.
Definition: sam_file/record.hpp:383
decltype(auto) tags() &&
The optional tags in the SAM format.
Definition: sam_file/record.hpp:378
decltype(auto) flag() &
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: sam_file/record.hpp:246
decltype(auto) sequence_position() const &&
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: sam_file/record.hpp:140
sam_record()=default
Defaulted.
sam_record(sam_record &&)=default
Defaulted.
decltype(auto) reference_position() &
(Reference) Sequence (seqan3::sam_record::reference_sequence) relative start position (0-based),...
Definition: sam_file/record.hpp:198
decltype(auto) cigar_sequence() const &
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: sam_file/record.hpp:370
decltype(auto) reference_id() const &
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: sam_file/record.hpp:174
decltype(auto) mate_position() &&
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: sam_file/record.hpp:286
decltype(auto) reference_sequence()=delete
The (reference) "sequence" information, usually a range of nucleotides or amino acids....
sam_record & operator=(sam_record const &)=default
Defaulted.
decltype(auto) cigar_sequence() const &&
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: sam_file/record.hpp:360
decltype(auto) sequence() const &
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: sam_file/record.hpp:98
decltype(auto) mate_position() const &
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: sam_file/record.hpp:301
~sam_record()=default
Defaulted.
decltype(auto) header_ptr() &
A pointer to the seqan3::sam_file_header object storing header information.
Definition: sam_file/record.hpp:223
decltype(auto) mate_position() const &&
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: sam_file/record.hpp:291
decltype(auto) mapping_quality() const &
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: sam_file/record.hpp:347
decltype(auto) mate_reference_id() &
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: sam_file/record.hpp:273
decltype(auto) mapping_quality() const &&
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: sam_file/record.hpp:337
decltype(auto) sequence() &&
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: sam_file/record.hpp:83
decltype(auto) sequence_position() &
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: sam_file/record.hpp:145
decltype(auto) reference_position() const &&
(Reference) Sequence (seqan3::sam_record::reference_sequence) relative start position (0-based),...
Definition: sam_file/record.hpp:193
decltype(auto) base_qualities() &
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: sam_file/record.hpp:116
decltype(auto) template_length() &&
The observed template length. (SAM Column ID: TLEN)
Definition: sam_file/record.hpp:309
decltype(auto) mate_reference_id() const &
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: sam_file/record.hpp:278
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
SeqAn specific customisations in the standard namespace.
Provides the seqan3::record template and the seqan3::field enum.
The class template that file records are based on; behaves like a std::tuple.
Definition: record.hpp:192
detail::transfer_template_args_onto_t< field_types, std::tuple > base_type
A specialisation of std::tuple.
Definition: record.hpp:217