SeqAn3 3.1.0
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{
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;
41public:
45 sam_record() = default;
46 sam_record(sam_record const &) = default;
47 sam_record & operator=(sam_record const &) = default;
48 sam_record(sam_record &&) = default;
50 ~sam_record() = default;
51
53 using base_t::base_t;
55
59 decltype(auto) id() &&
60 {
61 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t &&>(*this));
62 }
64 decltype(auto) id() const &&
65 {
66 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t const &&>(*this));
67 }
69 decltype(auto) id() &
70 {
71 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t &>(*this));
72 }
74 decltype(auto) id() const &
75 {
76 return get_impl(field_constant<seqan3::field::id>{}, static_cast<tuple_base_t const &>(*this));
77 }
78
82 decltype(auto) sequence() &&
83 {
84 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t &&>(*this));
85 }
87 decltype(auto) sequence() const &&
88 {
89 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t const &&>(*this));
90 }
92 decltype(auto) sequence() &
93 {
94 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t &>(*this));
95 }
97 decltype(auto) sequence() const &
98 {
99 return get_impl(field_constant<seqan3::field::seq>{}, static_cast<tuple_base_t const &>(*this));
100 }
101
105 decltype(auto) base_qualities() &&
106 {
107 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t &&>(*this));
108 }
110 decltype(auto) base_qualities() const &&
111 {
112 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t const &&>(*this));
113 }
115 decltype(auto) base_qualities() &
116 {
117 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t &>(*this));
118 }
120 decltype(auto) base_qualities() const &
121 {
122 return get_impl(field_constant<seqan3::field::qual>{}, static_cast<tuple_base_t const &>(*this));
123 }
124
134 decltype(auto) sequence_position() &&
135 {
136 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t &&>(*this));
137 }
139 decltype(auto) sequence_position() const &&
140 {
141 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t const &&>(*this));
142 }
144 decltype(auto) sequence_position() &
145 {
146 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t &>(*this));
147 }
149 decltype(auto) sequence_position() const &
150 {
151 return get_impl(field_constant<seqan3::field::offset>{}, static_cast<tuple_base_t const &>(*this));
152 }
153
157 decltype(auto) alignment() &&
158 {
159 return get_impl(field_constant<seqan3::field::alignment>{}, static_cast<tuple_base_t &&>(*this));
160 }
162 decltype(auto) alignment() const &&
163 {
164 return get_impl(field_constant<seqan3::field::alignment>{}, static_cast<tuple_base_t const &&>(*this));
165 }
167 decltype(auto) alignment() &
168 {
169 return get_impl(field_constant<seqan3::field::alignment>{}, static_cast<tuple_base_t &>(*this));
170 }
172 decltype(auto) alignment() const &
173 {
174 return get_impl(field_constant<seqan3::field::alignment>{}, static_cast<tuple_base_t const &>(*this));
175 }
176
181 decltype(auto) reference_id() &&
182 {
183 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t &&>(*this));
184 }
186 decltype(auto) reference_id() const &&
187 {
188 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t const &&>(*this));
189 }
191 decltype(auto) reference_id() &
192 {
193 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t &>(*this));
194 }
196 decltype(auto) reference_id() const &
197 {
198 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t const &>(*this));
199 }
200
204 decltype(auto) reference_sequence() = delete;
205
210 decltype(auto) reference_position() &&
211 {
212 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t &&>(*this));
213 }
215 decltype(auto) reference_position() const &&
216 {
217 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t const &&>(*this));
218 }
220 decltype(auto) reference_position() &
221 {
222 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t &>(*this));
223 }
225 decltype(auto) reference_position() const &
226 {
227 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t const &>(*this));
228 }
229
235 decltype(auto) header_ptr() &&
236 {
237 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t &&>(*this));
238 }
240 decltype(auto) header_ptr() const &&
241 {
242 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t const &&>(*this));
243 }
245 decltype(auto) header_ptr() &
246 {
247 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t &>(*this));
248 }
250 decltype(auto) header_ptr() const &
251 {
252 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t const &>(*this));
253 }
254
258 decltype(auto) flag() &&
259 {
260 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t &&>(*this));
261 }
263 decltype(auto) flag() const &&
264 {
265 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t const &&>(*this));
266 }
268 decltype(auto) flag() &
269 {
270 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t &>(*this));
271 }
273 decltype(auto) flag() const &
274 {
275 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t const &>(*this));
276 }
277
285 decltype(auto) mate_reference_id() &&
286 {
287 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
288 }
290 decltype(auto) mate_reference_id() const &&
291 {
292 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
293 }
295 decltype(auto) mate_reference_id() &
296 {
297 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
298 }
300 decltype(auto) mate_reference_id() const &
301 {
302 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
303 }
304
308 decltype(auto) mate_position() &&
309 {
310 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
311 }
313 decltype(auto) mate_position() const &&
314 {
315 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
316 }
318 decltype(auto) mate_position() &
319 {
320 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
321 }
323 decltype(auto) mate_position() const &
324 {
325 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
326 }
327
331 decltype(auto) template_length() &&
332 {
333 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
334 }
336 decltype(auto) template_length() const &&
337 {
338 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
339 }
341 decltype(auto) template_length() &
342 {
343 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
344 }
346 decltype(auto) template_length() const &
347 {
348 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
349 }
350
354 decltype(auto) mapping_quality() &&
355 {
356 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t &&>(*this));
357 }
359 decltype(auto) mapping_quality() const &&
360 {
361 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t const &&>(*this));
362 }
364 decltype(auto) mapping_quality() &
365 {
366 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t &>(*this));
367 }
369 decltype(auto) mapping_quality() const &
370 {
371 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t const &>(*this));
372 }
373
377 decltype(auto) cigar_sequence() &&
378 {
379 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t &&>(*this));
380 }
382 decltype(auto) cigar_sequence() const &&
383 {
384 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t const &&>(*this));
385 }
387 decltype(auto) cigar_sequence() &
388 {
389 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t &>(*this));
390 }
392 decltype(auto) cigar_sequence() const &
393 {
394 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t const &>(*this));
395 }
396
400 decltype(auto) tags() &&
401 {
402 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t &&>(*this));
403 }
405 decltype(auto) tags() const &&
406 {
407 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t const &&>(*this));
408 }
410 decltype(auto) tags() &
411 {
412 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t &>(*this));
413 }
415 decltype(auto) tags() const &
416 {
417 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t const &>(*this));
418 }
419};
420} // namespace seqan3
421
422namespace std
423{
424
430template <typename field_types, typename field_ids>
431struct tuple_size<seqan3::sam_record<field_types, field_ids>>
432 : tuple_size<typename seqan3::sam_record<field_types, field_ids>::base_type>
433{};
434
440template <size_t elem_no, typename field_types, typename field_ids>
441struct tuple_element<elem_no, seqan3::sam_record<field_types, field_ids>>
442 : tuple_element<elem_no, typename seqan3::sam_record<field_types, field_ids>::base_type>
443{};
444
445} // namespace std
The record type of seqan3::sam_file_input.
Definition: record.hpp:29
decltype(auto) reference_position() const &
(Reference) Sequence (seqan3::sam_record::reference_sequence) relative start position (0-based),...
Definition: record.hpp:225
decltype(auto) header_ptr() const &&
A pointer to the seqan3::sam_file_header object storing header information.
Definition: record.hpp:240
decltype(auto) flag() const &
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: record.hpp:273
decltype(auto) cigar_sequence() &
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: record.hpp:387
decltype(auto) mate_reference_id() &&
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: record.hpp:285
decltype(auto) sequence_position() const &
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: record.hpp:149
decltype(auto) cigar_sequence() &&
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: record.hpp:377
decltype(auto) reference_id() const &&
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: record.hpp:186
decltype(auto) sequence_position() &&
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: record.hpp:134
decltype(auto) base_qualities() const &
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: record.hpp:120
decltype(auto) header_ptr() &&
A pointer to the seqan3::sam_file_header object storing header information.
Definition: record.hpp:235
decltype(auto) base_qualities() const &&
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: record.hpp:110
decltype(auto) template_length() const &
The observed template length. (SAM Column ID: TLEN)
Definition: record.hpp:346
decltype(auto) mate_reference_id() const &&
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: record.hpp:290
decltype(auto) sequence() &
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: record.hpp:92
decltype(auto) mapping_quality() &&
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: record.hpp:354
decltype(auto) reference_id() &
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: record.hpp:191
decltype(auto) sequence() const &&
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: record.hpp:87
decltype(auto) reference_position() &&
(Reference) Sequence (seqan3::sam_record::reference_sequence) relative start position (0-based),...
Definition: record.hpp:210
sam_record & operator=(sam_record &&)=default
Defaulted.
decltype(auto) template_length() const &&
The observed template length. (SAM Column ID: TLEN)
Definition: record.hpp:336
decltype(auto) mate_position() &
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: record.hpp:318
sam_record(sam_record const &)=default
Defaulted.
decltype(auto) tags() const &
The optional tags in the SAM format.
Definition: record.hpp:415
decltype(auto) reference_id() &&
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: record.hpp:181
decltype(auto) flag() &&
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: record.hpp:258
decltype(auto) tags() &
The optional tags in the SAM format.
Definition: record.hpp:410
decltype(auto) flag() const &&
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: record.hpp:263
decltype(auto) header_ptr() const &
A pointer to the seqan3::sam_file_header object storing header information.
Definition: record.hpp:250
decltype(auto) base_qualities() &&
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: record.hpp:105
decltype(auto) mapping_quality() &
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: record.hpp:364
decltype(auto) template_length() &
The observed template length. (SAM Column ID: TLEN)
Definition: record.hpp:341
decltype(auto) tags() const &&
The optional tags in the SAM format.
Definition: record.hpp:405
decltype(auto) tags() &&
The optional tags in the SAM format.
Definition: record.hpp:400
decltype(auto) flag() &
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: record.hpp:268
decltype(auto) sequence_position() const &&
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: record.hpp:139
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:220
decltype(auto) cigar_sequence() const &
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: record.hpp:392
decltype(auto) reference_id() const &
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: record.hpp:196
decltype(auto) alignment() const &&
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
Definition: record.hpp:162
decltype(auto) mate_position() &&
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: record.hpp:308
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:167
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:382
decltype(auto) sequence() const &
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: record.hpp:97
decltype(auto) mate_position() const &
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: record.hpp:323
~sam_record()=default
Defaulted.
decltype(auto) header_ptr() &
A pointer to the seqan3::sam_file_header object storing header information.
Definition: record.hpp:245
decltype(auto) mate_position() const &&
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: record.hpp:313
decltype(auto) mapping_quality() const &
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: record.hpp:369
decltype(auto) alignment() const &
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
Definition: record.hpp:172
decltype(auto) mate_reference_id() &
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: record.hpp:295
decltype(auto) alignment() &&
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
Definition: record.hpp:157
decltype(auto) mapping_quality() const &&
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: record.hpp:359
decltype(auto) sequence() &&
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: record.hpp:82
decltype(auto) sequence_position() &
Sequence (seqan3::sam_record::sequence) relative start position (0-based), unsigned value....
Definition: record.hpp:144
decltype(auto) reference_position() const &&
(Reference) Sequence (seqan3::sam_record::reference_sequence) relative start position (0-based),...
Definition: record.hpp:215
decltype(auto) base_qualities() &
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: record.hpp:115
decltype(auto) template_length() &&
The observed template length. (SAM Column ID: TLEN)
Definition: record.hpp:331
decltype(auto) mate_reference_id() const &
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: record.hpp:300
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 a 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