SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
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 <type_traits>
16 
17 #include <sdsl/suffix_arrays.hpp>
18 
20 #include <seqan3/range/concept.hpp>
22 
23 namespace seqan3::detail
24 {
25 
30  // ============================================================================
31  // sdsl_index
32  // ============================================================================
33 
38 template <typename t>
39 SEQAN3_CONCEPT sdsl_index = requires (t sdsl_index)
40 {
41  typename t::size_type;
42 
43  SEQAN3_RETURN_TYPE_CONSTRAINT(sdsl_index.size(), std::same_as, typename t::size_type);
44  { sdsl_index[0] }; // suffix array access
45  SEQAN3_RETURN_TYPE_CONSTRAINT(sdsl_index.comp2char[0], std::same_as, uint8_t);
46  SEQAN3_RETURN_TYPE_CONSTRAINT(sdsl_index.char2comp[0], std::same_as, uint8_t);
47  { sdsl_index.sigma };
48  { sdsl_index.C[0] };
49 
50  requires requires (t sdsl_index, typename t::char_type const c, typename t::size_type const lb,
51  typename t::size_type const rb, sdsl::int_vector<8> const text)
52  {
53  { sdsl_index.bwt.rank(lb, c) };
54  { sdsl_index.wavelet_tree.lex_count(lb, rb, c) };
55  { sdsl::construct_im(sdsl_index, text, 0) };
56  };
57 };
59 
70 
71 } // namespace seqan3::detail
72 
73 namespace seqan3
74 {
75 
81 enum text_layout : bool
82 {
87 };
88 
89 #ifdef SEQAN3_DEPRECATED_310
90 // ============================================================================
91 // fm_index_specialisation
92 // ============================================================================
93 
103 namespace deprecated
104 {
105 template <typename t>
106 SEQAN3_CONCEPT fm_index_specialisation_concept = std::semiregular<t> && requires (t index)
107 {
108  typename t::alphabet_type;
109  typename t::size_type;
110  typename t::cursor_type;
111 
112  // NOTE: circular dependency
113  // requires detail::template_specialisation_of<typename t::cursor_type, fm_index_cursor>;
114  requires requires (t index, std::conditional_t<t::text_layout_mode == text_layout::collection,
117  {
118  { t(text) };
119  };
120 
121  SEQAN3_RETURN_TYPE_CONSTRAINT(index.cursor(), std::same_as, typename t::cursor_type);
122 
123  SEQAN3_RETURN_TYPE_CONSTRAINT(index.size(), std::same_as, typename t::size_type);
124  SEQAN3_RETURN_TYPE_CONSTRAINT(index.empty(), std::same_as, bool);
125 };
126 } // namespace seqan3::deprecated
127 
128 template <typename t>
129 SEQAN3_DEPRECATED_310 constexpr bool fm_index_specialisation = deprecated::fm_index_specialisation_concept<t>;
130 
132 
159 namespace deprecated
160 {
161 template <typename t>
162 SEQAN3_CONCEPT fm_index_cursor_specialisation_concept = std::semiregular<t> && requires (t cur)
163 {
164  typename t::index_type;
165  typename t::size_type;
166 
168 
169  requires requires (typename t::index_type const index) { { t(index) }; };
170 
171  requires requires (t cur,
172  typename t::index_type::alphabet_type const c,
174  std::conditional_t<t::index_type::text_layout_mode == text_layout::collection,
177  {
178  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_right(), std::same_as, bool);
179  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_right(c), std::same_as, bool);
180  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_right(seq), std::same_as, bool);
181  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.cycle_back(), std::same_as, bool);
182  { cur.path_label(text) };
183  };
184 
185  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.last_rank(), std::same_as, typename t::size_type);
186  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.query_length(), std::same_as, typename t::size_type);
187  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.count(), std::same_as, typename t::size_type);
188  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.locate(),
190  { cur.lazy_locate() };
191 };
192 } // namespace seqan3::deprecated
193 
194 template <typename t>
195 SEQAN3_DEPRECATED_310 constexpr bool fm_index_cursor_specialisation = deprecated::fm_index_cursor_specialisation_concept<t>;
197 
210 // ============================================================================
211 // bi_fm_index_specialisation
212 // ============================================================================
213 
223 namespace deprecated
224 {
225 template <typename t>
226 SEQAN3_CONCEPT bi_fm_index_specialisation_concept = fm_index_specialisation<t> && requires (t index)
227 {
228  typename t::cursor_type; // already required by fm_index_specialisation but has a different documentation
229  typename t::fwd_cursor_type;
230 
231  // NOTE: circular dependency
232  // requires detail::template_specialisation_of<typename t::cursor_type, bi_fm_index_cursor>;
233 
234  SEQAN3_RETURN_TYPE_CONSTRAINT(index.fwd_cursor(), std::same_as, typename t::fwd_cursor_type);
235 };
236 } // namespace seqan3::deprecated
237 
238 template <typename t>
239 SEQAN3_DEPRECATED_310 constexpr bool bi_fm_index_specialisation = deprecated::bi_fm_index_specialisation_concept<t>;
240 
242 
255 // ============================================================================
256 // bi_fm_index_cursor_specialisation
257 // ============================================================================
258 
267 namespace deprecated
268 {
269 template <typename t>
270 SEQAN3_CONCEPT bi_fm_index_cursor_specialisation_concept = fm_index_cursor_specialisation<t> && requires (t cur)
271 {
273 
274  requires requires (typename t::index_type const index) { { t(index) }; };
275 
276  requires requires (t cur,
277  typename t::index_type::alphabet_type const c,
279  {
280  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_left(), std::same_as, bool);
281  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_left(c), std::same_as, bool);
282  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_left(seq), std::same_as, bool);
283  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.cycle_front(), std::same_as, bool);
284  };
285 
286 };
287 } // namespace seqan3::deprecated
288 
289 template <typename t>
291  = deprecated::bi_fm_index_cursor_specialisation_concept<t>;
292 
294 
309 #endif // SEQAN3_DEPRECATED_310
310 
311 } // namespace seqan3
Provides various transformation traits used by the range module.
text_layout
The possible text layouts (single, collection) the seqan3::fm_index and seqan3::bi_fm_index can suppo...
Definition: concept.hpp:82
@ single
The text is a single range.
Definition: concept.hpp:84
@ collection
The text is a range of ranges.
Definition: concept.hpp:86
Concept for bidirectional FM index cursors.
Concept for bidirectional FM indices.
Concept for unidirectional FM index cursors.
Concept for unidirectional FM indices.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
#define SEQAN3_DEPRECATED_310
Deprecation message for SeqAn 3.1.0 release.
Definition: platform.hpp:202
#define SEQAN3_RETURN_TYPE_CONSTRAINT(expression, concept_name,...)
Same as writing {expression} -> concept_name<type1[, ...]> in a concept definition.
Definition: platform.hpp:57
Additional non-standard concepts for ranges.
Adaptations of concepts from the standard library.