SeqAn3 3.3.0-rc.1
The Modern C++ library for sequence analysis.
sam_file/output_format_concept.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 <fstream>
16#include <optional>
17#include <string>
18#include <vector>
19
29
30namespace seqan3::detail
31{
32
45template <typename format_type>
46struct sam_file_output_format_exposer : public format_type
47{
48public:
49 // Can't use `using format_type::write_alignment_record` as it produces a hard failure in the format concept check
50 // for types that do not model the format concept, i.e. don't offer the proper write_alignment_record interface.
52 template <typename... ts>
53 void write_alignment_record(ts &&... args)
54 {
55 format_type::write_alignment_record(std::forward<ts>(args)...);
56 }
57
59 template <typename stream_t, typename header_type>
60 void write_header(stream_t & stream, sam_file_output_options const & options, header_type & header)
61 {
62 format_type::write_header(stream, options, header);
63 }
64};
65
66} // namespace seqan3::detail
67
68namespace seqan3
69{
70
83template <typename t>
84concept sam_file_output_format = requires (detail::sam_file_output_format_exposer<t> & v,
85 std::ofstream & stream,
86 sam_file_output_options & options,
87 sam_file_header<> & header,
88 dna5_vector & seq,
91 dna5_vector & ref_seq,
95 sam_flag & flag,
96 uint8_t & mapq,
98 sam_tag_dictionary & tag_dict,
99 double & e_value,
100 double & bit_score) {
101 t::file_extensions;
102
103 {
104 v.write_alignment_record(stream,
105 options,
106 header,
107 seq,
108 qual,
109 id,
110 ref_seq,
111 ref_id,
112 ref_offset,
113 cigar,
114 flag,
115 mapq,
116 mate,
117 tag_dict,
118 e_value,
119 bit_score)
120 } -> std::same_as<void>;
121 };
123
124// Workaround for https://github.com/doxygen/doxygen/issues/9379
125#if SEQAN3_DOXYGEN_ONLY(1) 0
126template <typename t>
128{};
129#endif
130
191
192} // namespace seqan3
193
194namespace seqan3::detail
195{
196
202template <typename t>
203constexpr bool is_type_list_of_sam_file_output_formats_v = false;
204
210template <typename... ts>
211constexpr bool is_type_list_of_sam_file_output_formats_v<type_list<ts...>> = (sam_file_output_format<ts> && ...);
212
218template <typename t>
219concept type_list_of_sam_file_output_formats = is_type_list_of_sam_file_output_formats_v<t>;
220} // namespace seqan3::detail
Provides aliases for qualified.
Provides the seqan3::cigar alphabet.
The generic concept for alignment file out formats.
Definition: sam_file/output_format_concept.hpp:128
Provides seqan3::dna5, container aliases and string literals.
sam_flag
An enum flag that describes the properties of an aligned read (given as a SAM record).
Definition: sam_flag.hpp:76
@ flag
The alignment flag (bit information), uint16_t value.
@ ref_offset
Sequence (seqan3::field::ref_seq) relative start position (0-based), unsigned value.
@ ref_seq
The (reference) "sequence" information, usually a range of nucleotides or amino acids.
@ cigar
The cigar vector (std::vector<seqan3::cigar>) representing the alignment in SAM/BAM format.
@ mapq
The mapping quality of the seqan3::field::seq alignment, usually a Phred-scaled score.
@ bit_score
The bit score (statistical significance indicator), unsigned value.
@ mate
The mate pair information given as a std::tuple of reference name, offset and template length.
@ ref_id
The identifier of the (reference) sequence that seqan3::field::seq was aligned to.
@ id
The identifier, usually a string.
@ seq
The "sequence", usually a range of nucleotides or amino acids.
@ qual
The qualities, usually in Phred score notation.
Provides the seqan3::sam_file_header class.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides seqan3::phred42 quality scores.
Provides seqan3::sam_file_output_options.
Provides helper data structures for the seqan3::sam_file_output.
Provides the seqan3::sam_tag_dictionary class and auxiliaries.
Provides seqan3::type_list.