SeqAn3 3.1.0-rc.2
The Modern C++ library for sequence analysis.
record.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, 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{
25template <typename field_types, typename field_ids>
26class sam_record : public record<field_types, field_ids>
27{
30
32 using tuple_base_t = typename base_t::base_type;
33
35 template <field f>
36 using field_constant = typename base_t::template field_constant<f>;
37
38 using base_t::get_impl;
39public:
43 sam_record() = default;
44 sam_record(sam_record const &) = default;
45 sam_record & operator=(sam_record const &) = default;
46 sam_record(sam_record &&) = default;
48 ~sam_record() = default;
49
51 using base_t::base_t;
53
57 decltype(auto) id() &&
58 {
59 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t &&>(*this));
60 }
62 decltype(auto) id() const &&
63 {
64 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t const &&>(*this));
65 }
67 decltype(auto) id() &
68 {
69 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t &>(*this));
70 }
72 decltype(auto) id() const &
73 {
74 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t const &>(*this));
75 }
76
80 decltype(auto) sequence() &&
81 {
82 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t &&>(*this));
83 }
85 decltype(auto) sequence() const &&
86 {
87 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t const &&>(*this));
88 }
90 decltype(auto) sequence() &
91 {
92 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t &>(*this));
93 }
95 decltype(auto) sequence() const &
96 {
97 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t const &>(*this));
98 }
99
103 decltype(auto) base_qualities() &&
104 {
105 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t &&>(*this));
106 }
108 decltype(auto) base_qualities() const &&
109 {
110 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t const &&>(*this));
111 }
113 decltype(auto) base_qualities() &
114 {
115 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t &>(*this));
116 }
118 decltype(auto) base_qualities() const &
119 {
120 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t const &>(*this));
121 }
122
132 decltype(auto) sequence_position() &&
133 {
134 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t &&>(*this));
135 }
137 decltype(auto) sequence_position() const &&
138 {
139 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t const &&>(*this));
140 }
142 decltype(auto) sequence_position() &
143 {
144 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t &>(*this));
145 }
147 decltype(auto) sequence_position() const &
148 {
149 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t const &>(*this));
150 }
151
155 decltype(auto) alignment() &&
156 {
157 return get_impl(field_constant<seqan3::field::alignment>{}, static_cast<tuple_base_t &&>(*this));
158 }
160 decltype(auto) alignment() const &&
161 {
162 return get_impl(field_constant<seqan3::field::alignment>{}, static_cast<tuple_base_t const &&>(*this));
163 }
165 decltype(auto) alignment() &
166 {
167 return get_impl(field_constant<seqan3::field::alignment>{}, static_cast<tuple_base_t &>(*this));
168 }
170 decltype(auto) alignment() const &
171 {
172 return get_impl(field_constant<seqan3::field::alignment>{}, static_cast<tuple_base_t const &>(*this));
173 }
174
179 decltype(auto) reference_id() &&
180 {
181 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t &&>(*this));
182 }
184 decltype(auto) reference_id() const &&
185 {
186 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t const &&>(*this));
187 }
189 decltype(auto) reference_id() &
190 {
191 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t &>(*this));
192 }
194 decltype(auto) reference_id() const &
195 {
196 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t const &>(*this));
197 }
198
202 decltype(auto) reference_sequence() = delete;
203
208 decltype(auto) reference_position() &&
209 {
210 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t &&>(*this));
211 }
213 decltype(auto) reference_position() const &&
214 {
215 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t const &&>(*this));
216 }
218 decltype(auto) reference_position() &
219 {
220 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t &>(*this));
221 }
223 decltype(auto) reference_position() const &
224 {
225 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t const &>(*this));
226 }
227
233 decltype(auto) header_ptr() &&
234 {
235 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t &&>(*this));
236 }
238 decltype(auto) header_ptr() const &&
239 {
240 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t const &&>(*this));
241 }
243 decltype(auto) header_ptr() &
244 {
245 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t &>(*this));
246 }
248 decltype(auto) header_ptr() const &
249 {
250 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t const &>(*this));
251 }
252
256 decltype(auto) flag() &&
257 {
258 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t &&>(*this));
259 }
261 decltype(auto) flag() const &&
262 {
263 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t const &&>(*this));
264 }
266 decltype(auto) flag() &
267 {
268 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t &>(*this));
269 }
271 decltype(auto) flag() const &
272 {
273 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t const &>(*this));
274 }
275
283 decltype(auto) mate_reference_id() &&
284 {
285 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
286 }
288 decltype(auto) mate_reference_id() const &&
289 {
290 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
291 }
293 decltype(auto) mate_reference_id() &
294 {
295 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
296 }
298 decltype(auto) mate_reference_id() const &
299 {
300 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
301 }
302
306 decltype(auto) mate_position() &&
307 {
308 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
309 }
311 decltype(auto) mate_position() const &&
312 {
313 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
314 }
316 decltype(auto) mate_position() &
317 {
318 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
319 }
321 decltype(auto) mate_position() const &
322 {
323 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
324 }
325
329 decltype(auto) template_length() &&
330 {
331 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
332 }
334 decltype(auto) template_length() const &&
335 {
336 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
337 }
339 decltype(auto) template_length() &
340 {
341 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
342 }
344 decltype(auto) template_length() const &
345 {
346 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
347 }
348
352 decltype(auto) mapping_quality() &&
353 {
354 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t &&>(*this));
355 }
357 decltype(auto) mapping_quality() const &&
358 {
359 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t const &&>(*this));
360 }
362 decltype(auto) mapping_quality() &
363 {
364 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t &>(*this));
365 }
367 decltype(auto) mapping_quality() const &
368 {
369 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t const &>(*this));
370 }
371
375 decltype(auto) cigar_sequence() &&
376 {
377 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t &&>(*this));
378 }
380 decltype(auto) cigar_sequence() const &&
381 {
382 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t const &&>(*this));
383 }
385 decltype(auto) cigar_sequence() &
386 {
387 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t &>(*this));
388 }
390 decltype(auto) cigar_sequence() const &
391 {
392 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t const &>(*this));
393 }
394
398 decltype(auto) tags() &&
399 {
400 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t &&>(*this));
401 }
403 decltype(auto) tags() const &&
404 {
405 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t const &&>(*this));
406 }
408 decltype(auto) tags() &
409 {
410 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t &>(*this));
411 }
413 decltype(auto) tags() const &
414 {
415 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t const &>(*this));
416 }
417};
418} // namespace seqan3
419
420namespace std
421{
422
428template <typename field_types, typename field_ids>
429struct tuple_size<seqan3::sam_record<field_types, field_ids>>
430 : tuple_size<typename seqan3::sam_record<field_types, field_ids>::base_type>
431{};
432
438template <size_t elem_no, typename field_types, typename field_ids>
439struct tuple_element<elem_no, seqan3::sam_record<field_types, field_ids>>
440 : tuple_element<elem_no, typename seqan3::sam_record<field_types, field_ids>::base_type>
441{};
442
443} // namespace std
The record type of seqan3::alignment_file_input.
Definition: record.hpp:27
decltype(auto) reference_position() const &
(Reference) Sequence (seqan3::sam_record::reference_sequence) relative start position (0-based),...
Definition: record.hpp:223
decltype(auto) header_ptr() const &&
A pointer to the seqan3::sam_file_header object storing header information.
Definition: record.hpp:238
decltype(auto) flag() const &
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: record.hpp:271
decltype(auto) cigar_sequence() &
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: record.hpp:385
decltype(auto) mate_reference_id() &&
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: record.hpp:283
decltype(auto) sequence_position() const &
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: record.hpp:147
decltype(auto) cigar_sequence() &&
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: record.hpp:375
decltype(auto) reference_id() const &&
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: record.hpp:184
decltype(auto) sequence_position() &&
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: record.hpp:132
decltype(auto) base_qualities() const &
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: record.hpp:118
decltype(auto) header_ptr() &&
A pointer to the seqan3::sam_file_header object storing header information.
Definition: record.hpp:233
decltype(auto) base_qualities() const &&
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: record.hpp:108
decltype(auto) template_length() const &
The observed template length. (SAM Column ID: TLEN)
Definition: record.hpp:344
decltype(auto) mate_reference_id() const &&
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: record.hpp:288
decltype(auto) sequence() &
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: record.hpp:90
decltype(auto) mapping_quality() &&
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: record.hpp:352
decltype(auto) reference_id() &
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: record.hpp:189
decltype(auto) sequence() const &&
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: record.hpp:85
decltype(auto) reference_position() &&
(Reference) Sequence (seqan3::sam_record::reference_sequence) relative start position (0-based),...
Definition: record.hpp:208
sam_record & operator=(sam_record &&)=default
Defaulted.
decltype(auto) template_length() const &&
The observed template length. (SAM Column ID: TLEN)
Definition: record.hpp:334
decltype(auto) mate_position() &
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: record.hpp:316
sam_record(sam_record const &)=default
Defaulted.
decltype(auto) tags() const &
The optional tags in the SAM format.
Definition: record.hpp:413
decltype(auto) reference_id() &&
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: record.hpp:179
decltype(auto) flag() &&
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: record.hpp:256
decltype(auto) tags() &
The optional tags in the SAM format.
Definition: record.hpp:408
decltype(auto) flag() const &&
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: record.hpp:261
decltype(auto) header_ptr() const &
A pointer to the seqan3::sam_file_header object storing header information.
Definition: record.hpp:248
decltype(auto) base_qualities() &&
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: record.hpp:103
decltype(auto) mapping_quality() &
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: record.hpp:362
decltype(auto) template_length() &
The observed template length. (SAM Column ID: TLEN)
Definition: record.hpp:339
decltype(auto) tags() const &&
The optional tags in the SAM format.
Definition: record.hpp:403
decltype(auto) tags() &&
The optional tags in the SAM format.
Definition: record.hpp:398
decltype(auto) flag() &
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: record.hpp:266
decltype(auto) sequence_position() const &&
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: record.hpp:137
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: record.hpp:218
decltype(auto) cigar_sequence() const &
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: record.hpp:390
decltype(auto) reference_id() const &
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: record.hpp:194
decltype(auto) alignment() const &&
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
Definition: record.hpp:160
decltype(auto) mate_position() &&
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: record.hpp:306
decltype(auto) reference_sequence()=delete
The (reference) "sequence" information, usually a range of nucleotides or amino acids....
decltype(auto) alignment() &
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
Definition: record.hpp:165
sam_record & operator=(sam_record const &)=default
Defaulted.
decltype(auto) cigar_sequence() const &&
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: record.hpp:380
decltype(auto) sequence() const &
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: record.hpp:95
decltype(auto) mate_position() const &
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: record.hpp:321
~sam_record()=default
Defaulted.
decltype(auto) header_ptr() &
A pointer to the seqan3::sam_file_header object storing header information.
Definition: record.hpp:243
decltype(auto) mate_position() const &&
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: record.hpp:311
decltype(auto) mapping_quality() const &
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: record.hpp:367
decltype(auto) alignment() const &
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
Definition: record.hpp:170
decltype(auto) mate_reference_id() &
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: record.hpp:293
decltype(auto) alignment() &&
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
Definition: record.hpp:155
decltype(auto) mapping_quality() const &&
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: record.hpp:357
decltype(auto) sequence() &&
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: record.hpp:80
decltype(auto) sequence_position() &
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: record.hpp:142
decltype(auto) reference_position() const &&
(Reference) Sequence (seqan3::sam_record::reference_sequence) relative start position (0-based),...
Definition: record.hpp:213
decltype(auto) base_qualities() &
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: record.hpp:113
decltype(auto) template_length() &&
The observed template length. (SAM Column ID: TLEN)
Definition: record.hpp:329
decltype(auto) mate_reference_id() const &
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: record.hpp:298
The main SeqAn3 namespace.
Definition: cigar_operation_table.hpp:2
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 an std::tuple.
Definition: record.hpp:191
detail::transfer_template_args_onto_t< field_types, std::tuple > base_type
A specialisation of std::tuple.
Definition: record.hpp:215