SeqAn3 3.2.0
The Modern C++ library for sequence analysis.
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
25namespace seqan3::detail
26{
27
40template <typename format_type>
41struct sequence_file_output_format_exposer : public format_type
42{
43public:
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
56namespace seqan3
57{
58
70template <typename t>
71concept 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,
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
130namespace seqan3::detail
131{
132
138template <typename t>
139constexpr bool is_type_list_of_sequence_file_output_formats_v = false;
140
146template <typename... ts>
147constexpr bool is_type_list_of_sequence_file_output_formats_v<type_list<ts...>> =
149
155template <typename t>
156concept 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.
@ 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.
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 main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides seqan3::phred42 quality scores.
Provides seqan3::sequence_file_output_options.
Provides seqan3::type_list.