SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
input_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 <set>
17 #include <string>
18 #include <utility>
19 #include <vector>
20 
26 
27 namespace seqan3::detail
28 {
29 
40 template <typename format_type>
41 struct structure_file_input_format_exposer : public format_type
42 {
43 public:
44  // Can't use `using format_type::read_structure_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 read_structure_record interface.
47  template <typename ...ts>
48  void read_structure_record(ts && ...args)
49  {
50  format_type::read_structure_record(std::forward<ts>(args)...);
51  }
52 };
53 
54 } // namespace seqan3::detail
55 
56 namespace seqan3
57 {
58 
70 template <typename t>
71 SEQAN3_CONCEPT structure_file_input_format = requires(detail::structure_file_input_format_exposer<t> & v,
72  std::ifstream & f,
73  structure_file_input_options<rna5, false> & options,
74  rna5_vector & seq,
75  std::string & id,
77  std::vector<wuss51> & structure,
78  std::vector<structured_rna<rna5, wuss51>> & structured_seq,
79  double energy,
80  double react,
81  double react_err,
82  std::string & comment,
83  size_t offset)
84 {
85  t::file_extensions;
86 
87  SEQAN3_RETURN_TYPE_CONSTRAINT(v.read_structure_record(f,
88  options,
89  seq,
90  id,
91  bpp,
92  structure,
93  energy,
94  react,
95  react_err,
96  comment,
97  offset),
98  std::same_as, void);
99  SEQAN3_RETURN_TYPE_CONSTRAINT(v.read_structure_record(f,
100  options,
101  seq,
102  id,
103  bpp,
104  std::ignore,
105  std::ignore,
106  std::ignore,
107  std::ignore,
108  std::ignore,
109  std::ignore),
110  std::same_as, void);
111  SEQAN3_RETURN_TYPE_CONSTRAINT(v.read_structure_record(f,
112  options,
113  structured_seq,
114  id,
115  std::ignore,
116  structured_seq,
117  energy,
118  std::ignore,
119  std::ignore,
120  std::ignore,
121  std::ignore),
122  std::same_as, void);
123  SEQAN3_RETURN_TYPE_CONSTRAINT(v.read_structure_record(f,
124  options,
125  std::ignore,
126  std::ignore,
127  std::ignore,
128  std::ignore,
129  std::ignore,
130  std::ignore,
131  std::ignore,
132  std::ignore,
133  std::ignore),
134  std::same_as, void);
135  // the last is required to be compile time valid, but should always throw at run-time.
136 };
138 
199 
200 } // namespace seqan3
201 
202 namespace seqan3::detail
203 {
204 
210 template <typename t>
211 constexpr bool is_type_list_of_structure_file_input_formats_v = false;
212 
218 template <typename ...ts>
219 constexpr bool is_type_list_of_structure_file_input_formats_v<type_list<ts...>>
221 
227 template <typename t>
228 SEQAN3_CONCEPT type_list_of_structure_file_input_formats = is_type_list_of_structure_file_input_formats_v<t>;
229 } // namespace seqan3::detail
The generic concept for structure file in formats.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
#define SEQAN3_RETURN_TYPE_CONSTRAINT(expression, concept_name,...)
Same as writing {expression} -> concept_name<type1[, ...]> in a concept definition.
Definition: platform.hpp:57
Provides seqan3::rna5, container aliases and string literals.
Provides seqan3::structure_file_input_options.
Provides the composite of nucleotide with structure alphabets.
Provides seqan3::type_list.
Provides the WUSS format for RNA structure.