SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
output_format_concept.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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 
38 template <typename format_type>
39 struct sequence_file_output_format_exposer : public format_type
40 {
41 public:
42 
43  // Can't use `using format_type::write_sequence_record` as it produces a hard failure in the format concept check
44  // for types that do not model the format concept, i.e. don't offer the proper write_sequence_record interface.
46  template <typename ...ts>
47  void write_sequence_record(ts && ...args)
48  {
49  format_type::write_sequence_record(std::forward<ts>(args)...);
50  }
51 };
52 
53 } // namespace seqan3::detail
54 
55 namespace seqan3
56 {
57 
68 template <typename t>
70 SEQAN3_CONCEPT sequence_file_output_format = requires (detail::sequence_file_output_format_exposer<t> & v,
71  std::ofstream & f,
72  sequence_file_output_options & options,
73  dna5_vector & seq,
74  std::string & id,
75  std::vector<phred42> & qual,
76  std::vector<dna5q> & seq_qual)
77 {
78  t::file_extensions;
79 
80  { v.write_sequence_record(f, options, seq, id, qual) } -> void;
81  { v.write_sequence_record(f, options, std::ignore, id, std::ignore) } -> void;
82  { v.write_sequence_record(f, options, std::ignore, std::ignore, std::ignore) } -> void;
83  // the last is required to be compile time valid, but should always throw at run-time.
84 };
86 
122 
124 } // namespace seqan3
125 
126 namespace seqan3::detail
127 {
128 
134 template <typename t>
135 constexpr bool is_type_list_of_sequence_file_output_formats_v = false;
136 
142 template <typename ...ts>
143 constexpr bool is_type_list_of_sequence_file_output_formats_v<type_list<ts...>> =
145 
150 template <typename t>
151 SEQAN3_CONCEPT type_list_of_sequence_file_output_formats = is_type_list_of_sequence_file_output_formats_v<t>;
152 } // namespace seqan3::detail
fstream
std::string
seqan3::type_list
meta::list< types... > type_list
Type that contains multiple types, an alias for meta::list.
Definition: type_list.hpp:31
vector
seqan3::seq
constexpr sequenced_policy seq
Global execution policy object for sequenced execution policy.
Definition: execution.hpp:54
sequence_file_output_format::write_sequence_record
void write_sequence_record(stream_type &stream, seqan3::sequence_file_output_options const &options, seq_type &&sequence, id_type &&id, qual_type &&qualities)
Write the given fields to the specified stream.
std::ofstream
dna5.hpp
Provides seqan3::dna5, container aliases and string literals.
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
output_options.hpp
Provides seqan3::sequence_file_output_options.
sequence_file_output_format
The generic concept for sequence file out formats.
aliases.hpp
Provides aliases for qualified.
phred42.hpp
Provides seqan3::phred42 quality scores.
type_list.hpp
Provides seqan3::type_list.
string