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
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
160 {}
162 SEQAN3_DEPRECATED_340 decltype(auto) alignment() const &&
163 {}
166 {}
168 SEQAN3_DEPRECATED_340 decltype(auto) alignment() const &
169 {}
170
175 decltype(auto) reference_id() &&
176 {
177 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t &&>(*this));
178 }
180 decltype(auto) reference_id() const &&
181 {
182 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t const &&>(*this));
183 }
185 decltype(auto) reference_id() &
186 {
187 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t &>(*this));
188 }
190 decltype(auto) reference_id() const &
191 {
192 return get_impl(field_constant<seqan3::field::ref_id>{}, static_cast<tuple_base_t const &>(*this));
193 }
194
198 decltype(auto) reference_sequence() = delete;
199
204 decltype(auto) reference_position() &&
205 {
206 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t &&>(*this));
207 }
209 decltype(auto) reference_position() const &&
210 {
211 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t const &&>(*this));
212 }
214 decltype(auto) reference_position() &
215 {
216 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t &>(*this));
217 }
219 decltype(auto) reference_position() const &
220 {
221 return get_impl(field_constant<seqan3::field::ref_offset>{}, static_cast<tuple_base_t const &>(*this));
222 }
223
229 decltype(auto) header_ptr() &&
230 {
231 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t &&>(*this));
232 }
234 decltype(auto) header_ptr() const &&
235 {
236 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t const &&>(*this));
237 }
239 decltype(auto) header_ptr() &
240 {
241 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t &>(*this));
242 }
244 decltype(auto) header_ptr() const &
245 {
246 return get_impl(field_constant<seqan3::field::header_ptr>{}, static_cast<tuple_base_t const &>(*this));
247 }
248
252 decltype(auto) flag() &&
253 {
254 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t &&>(*this));
255 }
257 decltype(auto) flag() const &&
258 {
259 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t const &&>(*this));
260 }
262 decltype(auto) flag() &
263 {
264 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t &>(*this));
265 }
267 decltype(auto) flag() const &
268 {
269 return get_impl(field_constant<seqan3::field::flag>{}, static_cast<tuple_base_t const &>(*this));
270 }
271
279 decltype(auto) mate_reference_id() &&
280 {
281 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
282 }
284 decltype(auto) mate_reference_id() const &&
285 {
286 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
287 }
289 decltype(auto) mate_reference_id() &
290 {
291 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
292 }
294 decltype(auto) mate_reference_id() const &
295 {
296 return std::get<0>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
297 }
298
302 decltype(auto) mate_position() &&
303 {
304 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
305 }
307 decltype(auto) mate_position() const &&
308 {
309 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
310 }
312 decltype(auto) mate_position() &
313 {
314 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
315 }
317 decltype(auto) mate_position() const &
318 {
319 return std::get<1>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
320 }
321
325 decltype(auto) template_length() &&
326 {
327 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &&>(*this)));
328 }
330 decltype(auto) template_length() const &&
331 {
332 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &&>(*this)));
333 }
335 decltype(auto) template_length() &
336 {
337 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t &>(*this)));
338 }
340 decltype(auto) template_length() const &
341 {
342 return std::get<2>(get_impl(field_constant<seqan3::field::mate>{}, static_cast<tuple_base_t const &>(*this)));
343 }
344
348 decltype(auto) mapping_quality() &&
349 {
350 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t &&>(*this));
351 }
353 decltype(auto) mapping_quality() const &&
354 {
355 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t const &&>(*this));
356 }
358 decltype(auto) mapping_quality() &
359 {
360 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t &>(*this));
361 }
363 decltype(auto) mapping_quality() const &
364 {
365 return get_impl(field_constant<seqan3::field::mapq>{}, static_cast<tuple_base_t const &>(*this));
366 }
367
371 decltype(auto) cigar_sequence() &&
372 {
373 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t &&>(*this));
374 }
376 decltype(auto) cigar_sequence() const &&
377 {
378 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t const &&>(*this));
379 }
381 decltype(auto) cigar_sequence() &
382 {
383 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t &>(*this));
384 }
386 decltype(auto) cigar_sequence() const &
387 {
388 return get_impl(field_constant<seqan3::field::cigar>{}, static_cast<tuple_base_t const &>(*this));
389 }
390
394 decltype(auto) tags() &&
395 {
396 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t &&>(*this));
397 }
399 decltype(auto) tags() const &&
400 {
401 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t const &&>(*this));
402 }
404 decltype(auto) tags() &
405 {
406 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t &>(*this));
407 }
409 decltype(auto) tags() const &
410 {
411 return get_impl(field_constant<seqan3::field::tags>{}, static_cast<tuple_base_t const &>(*this));
412 }
413};
414} // namespace seqan3
415
416namespace std
417{
418
424template <typename field_types, typename field_ids>
425struct tuple_size<seqan3::sam_record<field_types, field_ids>> :
426 tuple_size<typename seqan3::sam_record<field_types, field_ids>::base_type>
427{};
428
434template <size_t elem_no, typename field_types, typename field_ids>
435struct tuple_element<elem_no, seqan3::sam_record<field_types, field_ids>> :
436 tuple_element<elem_no, typename seqan3::sam_record<field_types, field_ids>::base_type>
437{};
438
439} // 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:219
decltype(auto) header_ptr() const &&
A pointer to the seqan3::sam_file_header object storing header information.
Definition: sam_file/record.hpp:234
decltype(auto) flag() const &
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: sam_file/record.hpp:267
SEQAN3_DEPRECATED_340 decltype(auto) alignment() &
[DEPRECATED] The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignm...
Definition: sam_file/record.hpp:165
decltype(auto) cigar_sequence() &
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: sam_file/record.hpp:381
decltype(auto) mate_reference_id() &&
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: sam_file/record.hpp:279
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:371
decltype(auto) reference_id() const &&
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: sam_file/record.hpp:180
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:229
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:340
decltype(auto) mate_reference_id() const &&
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: sam_file/record.hpp:284
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:348
decltype(auto) reference_id() &
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: sam_file/record.hpp:185
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:204
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:330
decltype(auto) mate_position() &
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: sam_file/record.hpp:312
sam_record(sam_record const &)=default
Defaulted.
decltype(auto) tags() const &
The optional tags in the SAM format.
Definition: sam_file/record.hpp:409
decltype(auto) reference_id() &&
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: sam_file/record.hpp:175
decltype(auto) flag() &&
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: sam_file/record.hpp:252
decltype(auto) tags() &
The optional tags in the SAM format.
Definition: sam_file/record.hpp:404
decltype(auto) flag() const &&
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: sam_file/record.hpp:257
decltype(auto) header_ptr() const &
A pointer to the seqan3::sam_file_header object storing header information.
Definition: sam_file/record.hpp:244
decltype(auto) base_qualities() &&
The qualities, usually in Phred score notation. (SAM Column ID: QUAL)
Definition: sam_file/record.hpp:106
typename base_t::base_type tuple_base_t
The underlying std::tuple class.
Definition: sam_file/record.hpp:34
decltype(auto) mapping_quality() &
The mapping quality of the alignment, usually a Phred-scaled score. (SAM Column ID: MAPQ)
Definition: sam_file/record.hpp:358
SEQAN3_DEPRECATED_340 decltype(auto) alignment() &&
[DEPRECATED] The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignm...
Definition: sam_file/record.hpp:159
decltype(auto) template_length() &
The observed template length. (SAM Column ID: TLEN)
Definition: sam_file/record.hpp:335
decltype(auto) tags() const &&
The optional tags in the SAM format.
Definition: sam_file/record.hpp:399
decltype(auto) tags() &&
The optional tags in the SAM format.
Definition: sam_file/record.hpp:394
decltype(auto) flag() &
The alignment flag (bit information), uint16_t value. (SAM Column ID: FLAG)
Definition: sam_file/record.hpp:262
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:214
decltype(auto) cigar_sequence() const &
The cigar vector representing the alignment. (SAM Column ID: CIGAR)
Definition: sam_file/record.hpp:386
decltype(auto) reference_id() const &
The identifier of the (reference) sequence that seqan3::sam_record::sequence was aligned to....
Definition: sam_file/record.hpp:190
decltype(auto) mate_position() &&
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: sam_file/record.hpp:302
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:376
decltype(auto) sequence() const &
The "sequence", usually a range of nucleotides or amino acids. (SAM Column ID: SEQ)
Definition: sam_file/record.hpp:98
SEQAN3_DEPRECATED_340 decltype(auto) alignment() const &
[DEPRECATED] The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignm...
Definition: sam_file/record.hpp:168
SEQAN3_DEPRECATED_340 decltype(auto) alignment() const &&
[DEPRECATED] The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignm...
Definition: sam_file/record.hpp:162
decltype(auto) mate_position() const &
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: sam_file/record.hpp:317
~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:239
decltype(auto) mate_position() const &&
(Reference) Sequence relative start position (0-based) of the mate. (SAM Column ID: PNEXT)
Definition: sam_file/record.hpp:307
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:363
decltype(auto) mate_reference_id() &
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: sam_file/record.hpp:289
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:353
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:209
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:325
decltype(auto) mate_reference_id() const &
The identifier of the (reference) sequence of the mate. (SAM Column ID: RNEXT)
Definition: sam_file/record.hpp:294
Subconcept definition for seqan3::tuple_like to test for std::tuple_size-interface.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
SeqAn specific customisations in the standard namespace.
#define SEQAN3_DEPRECATED_340
Deprecation message for SeqAn 3.4.0 release.
Definition: platform.hpp:194
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
static decltype(auto) get_impl(field_constant< f >, tuple_t &&record_as_tuple)
This is basically the seqan3::get<f>(static_cast<tuple>(record)) implementation.
Definition: record.hpp:251
detail::transfer_template_args_onto_t< field_types, std::tuple > base_type
A specialisation of std::tuple.
Definition: record.hpp:217