SeqAn3  3.2.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 
30 
31 namespace seqan3::detail
32 {
33 
46 template <typename format_type>
47 struct sam_file_output_format_exposer : public format_type
48 {
49 public:
50  // Can't use `using format_type::write_alignment_record` as it produces a hard failure in the format concept check
51  // for types that do not model the format concept, i.e. don't offer the proper write_alignment_record interface.
53  template <typename... ts>
54  void write_alignment_record(ts &&... args)
55  {
56  format_type::write_alignment_record(std::forward<ts>(args)...);
57  }
58 };
59 
60 } // namespace seqan3::detail
61 
62 namespace seqan3
63 {
64 
77 template <typename t>
78 concept sam_file_output_format = requires (detail::sam_file_output_format_exposer<t> & v,
79  std::ofstream & stream,
80  sam_file_output_options & options,
81  sam_file_header<> & header,
82  dna5_vector & seq,
83  std::vector<phred42> & qual,
84  std::string & id,
85  int32_t & offset,
86  dna5_vector & ref_seq,
87  std::optional<int32_t> & ref_id,
88  std::optional<int32_t> & ref_offset,
89  std::pair<std::vector<gapped<dna4>>, std::vector<gapped<dna4>>> & align,
90  std::vector<cigar> & cigar,
91  sam_flag & flag,
92  uint8_t & mapq,
94  sam_tag_dictionary & tag_dict,
95  double & e_value,
96  double & bit_score) {
97  t::file_extensions;
98 
99  {
100  v.write_alignment_record(stream,
101  options,
102  header,
103  seq,
104  qual,
105  id,
106  offset,
107  ref_seq,
108  ref_id,
109  ref_offset,
110  align,
111  cigar,
112  flag,
113  mapq,
114  mate,
115  tag_dict,
116  e_value,
117  bit_score)
118  } -> std::same_as<void>;
119  };
121 
188 
189 } // namespace seqan3
190 
191 namespace seqan3::detail
192 {
193 
199 template <typename t>
200 constexpr bool is_type_list_of_sam_file_output_formats_v = false;
201 
207 template <typename... ts>
208 constexpr bool is_type_list_of_sam_file_output_formats_v<type_list<ts...>> = (sam_file_output_format<ts> && ...);
209 
215 template <typename t>
216 concept type_list_of_sam_file_output_formats = is_type_list_of_sam_file_output_formats_v<t>;
217 } // namespace seqan3::detail
Provides aliases for qualified.
Provides the seqan3::cigar alphabet.
Provides seqan3::dna5, container aliases and string literals.
Provides seqan3::gapped.
requires requires
The rank_type of the semi-alphabet; defined as the return type of seqan3::to_rank....
Definition: alphabet/concept.hpp:164
sam_flag
An enum flag that describes the properties of an aligned read (given as a SAM record).
Definition: sam_flag.hpp:76
Provides the seqan3::sam_file_header class.
The generic concept for alignment file out formats.
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.