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-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 <seqan3/std/concepts>
16 #include <type_traits>
17 
18 #include <sdsl/suffix_arrays.hpp>
19 
20 #include <seqan3/core/platform.hpp>
21 
22 namespace seqan3::detail
23 {
24 
29  // ============================================================================
30  // sdsl_index
31  // ============================================================================
32 
37 template <typename t>
38 SEQAN3_CONCEPT sdsl_index = requires (t sdsl_index)
39 {
40  typename t::size_type;
41 
42  SEQAN3_RETURN_TYPE_CONSTRAINT(sdsl_index.size(), std::same_as, typename t::size_type);
43  { sdsl_index[0] }; // suffix array access
44  SEQAN3_RETURN_TYPE_CONSTRAINT(sdsl_index.comp2char[0], std::same_as, uint8_t);
45  SEQAN3_RETURN_TYPE_CONSTRAINT(sdsl_index.char2comp[0], std::same_as, uint8_t);
46  { sdsl_index.sigma };
47  { sdsl_index.C[0] };
48 
49  requires requires (t sdsl_index, typename t::char_type const c, typename t::size_type const lb,
50  typename t::size_type const rb, sdsl::int_vector<8> const text)
51  {
52  { sdsl_index.bwt.rank(lb, c) };
53  { sdsl_index.wavelet_tree.lex_count(lb, rb, c) };
54  { sdsl::construct_im(sdsl_index, text, 0) };
55  };
56 };
58 
69 
70 } // namespace seqan3::detail
71 
72 namespace seqan3
73 {
74 
80 enum text_layout : bool
81 {
86 };
87 
88 #ifdef SEQAN3_DEPRECATED_310
89 // ============================================================================
90 // fm_index_specialisation
91 // ============================================================================
92 
102 namespace deprecated
103 {
104 template <typename t>
105 SEQAN3_CONCEPT fm_index_specialisation_concept = std::semiregular<t> && requires (t index)
106 {
107  typename t::alphabet_type;
108  typename t::size_type;
109  typename t::cursor_type;
110 
111  // NOTE: circular dependency
112  // requires detail::template_specialisation_of<typename t::cursor_type, fm_index_cursor>;
113  requires requires (t index, std::conditional_t<t::text_layout_mode == text_layout::collection,
116  {
117  { t(text) };
118  };
119 
120  SEQAN3_RETURN_TYPE_CONSTRAINT(index.cursor(), std::same_as, typename t::cursor_type);
121 
122  SEQAN3_RETURN_TYPE_CONSTRAINT(index.size(), std::same_as, typename t::size_type);
123  SEQAN3_RETURN_TYPE_CONSTRAINT(index.empty(), std::same_as, bool);
124 };
125 } // namespace seqan3::deprecated
126 
127 template <typename t>
128 SEQAN3_DEPRECATED_310 constexpr bool fm_index_specialisation = deprecated::fm_index_specialisation_concept<t>;
129 
131 
158 namespace deprecated
159 {
160 template <typename t>
161 SEQAN3_CONCEPT fm_index_cursor_specialisation_concept = std::semiregular<t> && requires (t cur)
162 {
163  typename t::index_type;
164  typename t::size_type;
165 
167 
168  requires requires (typename t::index_type const index) { { t(index) }; };
169 
170  requires requires (t cur,
171  typename t::index_type::alphabet_type const c,
173  std::conditional_t<t::index_type::text_layout_mode == text_layout::collection,
176  {
177  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_right(), std::same_as, bool);
178  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_right(c), std::same_as, bool);
179  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_right(seq), std::same_as, bool);
180  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.cycle_back(), std::same_as, bool);
181  { cur.path_label(text) };
182  };
183 
184  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.last_rank(), std::same_as, typename t::size_type);
185  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.query_length(), std::same_as, typename t::size_type);
186  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.count(), std::same_as, typename t::size_type);
187  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.locate(),
189  { cur.lazy_locate() };
190 };
191 } // namespace seqan3::deprecated
192 
193 template <typename t>
194 SEQAN3_DEPRECATED_310 constexpr bool fm_index_cursor_specialisation = deprecated::fm_index_cursor_specialisation_concept<t>;
196 
209 // ============================================================================
210 // bi_fm_index_specialisation
211 // ============================================================================
212 
222 namespace deprecated
223 {
224 template <typename t>
225 SEQAN3_CONCEPT bi_fm_index_specialisation_concept = fm_index_specialisation<t> && requires (t index)
226 {
227  typename t::cursor_type; // already required by fm_index_specialisation but has a different documentation
228  typename t::fwd_cursor_type;
229 
230  // NOTE: circular dependency
231  // requires detail::template_specialisation_of<typename t::cursor_type, bi_fm_index_cursor>;
232 
233  SEQAN3_RETURN_TYPE_CONSTRAINT(index.fwd_cursor(), std::same_as, typename t::fwd_cursor_type);
234 };
235 } // namespace seqan3::deprecated
236 
237 template <typename t>
238 SEQAN3_DEPRECATED_310 constexpr bool bi_fm_index_specialisation = deprecated::bi_fm_index_specialisation_concept<t>;
239 
241 
254 // ============================================================================
255 // bi_fm_index_cursor_specialisation
256 // ============================================================================
257 
266 namespace deprecated
267 {
268 template <typename t>
269 SEQAN3_CONCEPT bi_fm_index_cursor_specialisation_concept = fm_index_cursor_specialisation<t> && requires (t cur)
270 {
272 
273  requires requires (typename t::index_type const index) { { t(index) }; };
274 
275  requires requires (t cur,
276  typename t::index_type::alphabet_type const c,
278  {
279  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_left(), std::same_as, bool);
280  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_left(c), std::same_as, bool);
281  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.extend_left(seq), std::same_as, bool);
282  SEQAN3_RETURN_TYPE_CONSTRAINT(cur.cycle_front(), std::same_as, bool);
283  };
284 
285 };
286 } // namespace seqan3::deprecated
287 
288 template <typename t>
290  = deprecated::bi_fm_index_cursor_specialisation_concept<t>;
291 
293 
308 #endif // SEQAN3_DEPRECATED_310
309 
310 } // namespace seqan3
The Concepts library.
text_layout
The possible text layouts (single, collection) the seqan3::fm_index and seqan3::bi_fm_index can suppo...
Definition: concept.hpp:81
@ single
The text is a single range.
Definition: concept.hpp:83
@ collection
The text is a range of ranges.
Definition: concept.hpp:85
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
Provides platform and dependency checks.
#define SEQAN3_DEPRECATED_310
Deprecation message for SeqAn 3.1.0 release.
Definition: platform.hpp:203
#define SEQAN3_RETURN_TYPE_CONSTRAINT(expression, concept_name,...)
Same as writing {expression} -> concept_name<type1[, ...]> in a concept definition.
Definition: platform.hpp:57