SeqAn3  3.2.0
The Modern C++ library for sequence analysis.
sequence_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 <string>
17 #include <vector>
18 
24 
25 namespace seqan3::detail
26 {
27 
40 template <typename format_type>
41 struct sequence_file_output_format_exposer : public format_type
42 {
43 public:
44  // Can't use `using format_type::write_sequence_record` as it produces a hard failure in the format concept check
45  // for types that do not model the format concept, i.e. don't offer the proper write_sequence_record interface.
47  template <typename... ts>
48  void write_sequence_record(ts &&... args)
49  {
50  format_type::write_sequence_record(std::forward<ts>(args)...);
51  }
52 };
53 
54 } // namespace seqan3::detail
55 
56 namespace seqan3
57 {
58 
70 template <typename t>
71 concept sequence_file_output_format = requires (detail::sequence_file_output_format_exposer<t> & v,
72  std::ofstream & f,
73  sequence_file_output_options & options,
74  dna5_vector & seq,
75  std::string & id,
76  std::vector<phred42> & qual,
77  std::vector<dna5q> & seq_qual) {
78  t::file_extensions;
79 
80  {
81  v.write_sequence_record(f, options, seq, id, qual)
82  } -> std::same_as<void>;
83  {
84  v.write_sequence_record(f, options, std::ignore, id, std::ignore)
85  } -> std::same_as<void>;
86  {
87  v.write_sequence_record(f, options, std::ignore, std::ignore, std::ignore)
88  } -> std::same_as<void>;
89  // the last is required to be compile time valid, but should always throw at run-time.
90  };
92 
127 
128 } // namespace seqan3
129 
130 namespace seqan3::detail
131 {
132 
138 template <typename t>
139 constexpr bool is_type_list_of_sequence_file_output_formats_v = false;
140 
146 template <typename... ts>
147 constexpr bool is_type_list_of_sequence_file_output_formats_v<type_list<ts...>> =
149 
155 template <typename t>
156 concept type_list_of_sequence_file_output_formats = is_type_list_of_sequence_file_output_formats_v<t>;
157 } // namespace seqan3::detail
Provides aliases for qualified.
Provides seqan3::dna5, container aliases and string literals.
requires requires
The rank_type of the semi-alphabet; defined as the return type of seqan3::to_rank....
Definition: alphabet/concept.hpp:164
The generic concept for sequence file out formats.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides seqan3::phred42 quality scores.
Provides seqan3::sequence_file_output_options.
Provides seqan3::type_list.