SeqAn3 3.2.0-rc.1
The Modern C++ library for sequence analysis.
output_format_concept.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, 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
25namespace seqan3::detail
26{
27
40template <typename format_type>
41struct sequence_file_output_format_exposer : public format_type
42{
43public:
44
45 // Can't use `using format_type::write_sequence_record` as it produces a hard failure in the format concept check
46 // for types that do not model the format concept, i.e. don't offer the proper write_sequence_record interface.
48 template <typename ...ts>
49 void write_sequence_record(ts && ...args)
50 {
51 format_type::write_sequence_record(std::forward<ts>(args)...);
52 }
53};
54
55} // namespace seqan3::detail
56
57namespace seqan3
58{
59
71template <typename t>
72concept sequence_file_output_format = requires (detail::sequence_file_output_format_exposer<t> & v,
73 std::ofstream & f,
74 sequence_file_output_options & options,
75 dna5_vector & seq,
76 std::string & id,
78 std::vector<dna5q> & seq_qual)
79{
80 t::file_extensions;
81
82 {v.write_sequence_record(f, options, seq, id, qual)} -> std::same_as<void>;
83 {v.write_sequence_record(f, options, std::ignore, id, std::ignore)} -> std::same_as<void>;
84 {v.write_sequence_record(f, options, std::ignore, std::ignore, std::ignore)} -> std::same_as<void>;
85 // the last is required to be compile time valid, but should always throw at run-time.
86};
88
123
124} // namespace seqan3
125
126namespace seqan3::detail
127{
128
134template <typename t>
136
142template <typename ...ts>
145
151template <typename t>
152concept type_list_of_sequence_file_output_formats = is_type_list_of_sequence_file_output_formats_v<t>;
153} // namespace seqan3::detail
Provides aliases for qualified.
Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::sequen...
Definition: output_format_concept.hpp:152
Provides seqan3::dna5, container aliases and string literals.
constexpr bool is_type_list_of_sequence_file_output_formats_v
Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqa...
Definition: output_format_concept.hpp:135
The generic concept for sequence file out formats.
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.
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides seqan3::phred42 quality scores.
Provides seqan3::sequence_file_output_options.
Internal class used to expose the actual format interface to write sequence records into the file.
Definition: output_format_concept.hpp:42
void write_sequence_record(ts &&...args)
Forwards to the seqan3::sequence_file_output_format::write_sequence_record interface.
Definition: output_format_concept.hpp:49
Type that contains multiple types.
Definition: type_list.hpp:29
Provides seqan3::type_list.