SeqAn3  3.0.1
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 
37 template <typename t>
39 SEQAN3_CONCEPT sdsl_index = requires (t sdsl_index)
40 {
41  typename t::size_type;
42 
43  { sdsl_index.size() } -> typename t::size_type;
44  { sdsl_index[0] }; // suffix array access
45  { sdsl_index.comp2char[0] } -> uint8_t;
46  { sdsl_index.char2comp[0] } -> 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 
69 
71 } // namespace seqan3::detail
72 
73 namespace seqan3
74 {
75 
80 enum text_layout : bool
82 {
87 };
88 
89 // ============================================================================
90 // fm_index_specialisation
91 // ============================================================================
92 
98 template <typename t>
100 SEQAN3_CONCEPT fm_index_specialisation = std::semiregular<t> && requires (t index)
101 {
102  typename t::alphabet_type;
103  typename t::size_type;
104  typename t::cursor_type;
105 
106  // NOTE: circular dependency
107  // requires fm_index_cursor_specialisation<typename t::cursor_type>;
108  requires requires (t index, std::conditional_t<t::text_layout_mode == text_layout::collection,
111  {
112  { t(text) };
113  };
114 
115  { index.begin() } -> typename t::cursor_type;
116 
117  { index.size() } -> typename t::size_type;
118  { index.empty() } -> bool;
119 };
121 
140 // ============================================================================
141 // fm_index_cursor_specialisation
142 // ============================================================================
143 
149 template <typename t>
151 SEQAN3_CONCEPT fm_index_cursor_specialisation = std::semiregular<t> && requires (t cur)
152 {
153  typename t::index_type;
154  typename t::size_type;
155 
157 
158  requires requires (typename t::index_type const index) { { t(index) } };
159 
160  requires requires (t cur,
161  typename t::index_type::alphabet_type const c,
163  std::conditional_t<t::index_type::text_layout_mode == text_layout::collection,
166  {
167  { cur.extend_right() } -> bool;
168  { cur.extend_right(c) } -> bool;
169  { cur.extend_right(seq) } -> bool;
170  { cur.cycle_back() } -> bool;
171  { cur.path_label(text) } -> auto;
172  };
173 
174  { cur.last_rank() } -> typename t::size_type;
175  { cur.query_length() } -> typename t::size_type;
176  { cur.count() } -> typename t::size_type;
177  { cur.locate() } -> std::conditional_t<t::index_type::text_layout_mode == text_layout::collection,
180  { cur.lazy_locate() } -> auto;
181 };
183 
196 // ============================================================================
197 // bi_fm_index_specialisation
198 // ============================================================================
199 
205 template <typename t>
207 SEQAN3_CONCEPT bi_fm_index_specialisation = fm_index_specialisation<t> && requires (t index)
208 {
209  typename t::cursor_type; // already required by fm_index_specialisation but has a different documentation
210  typename t::fwd_cursor_type;
211  typename t::rev_cursor_type;
212 
213  // NOTE: circular dependency
214  // requires bi_fm_index_cursor_specialisation<typename t::cursor_type>;
215 
216  { index.fwd_begin() } -> typename t::fwd_cursor_type;
217  { index.rev_begin() } -> typename t::rev_cursor_type;
218 };
220 
236 // ============================================================================
237 // bi_fm_index_cursor_specialisation
238 // ============================================================================
239 
245 template <typename t>
247 SEQAN3_CONCEPT bi_fm_index_cursor_specialisation = fm_index_cursor_specialisation<t> && requires (t cur)
248 {
250 
251  requires requires (typename t::index_type const index) { { t(index) } };
252 
253  requires requires (t cur,
254  typename t::index_type::alphabet_type const c,
256  {
257  { cur.extend_left() } -> bool;
258  { cur.extend_left(c) } -> bool;
259  { cur.extend_left(seq) } -> bool;
260  { cur.cycle_front() } -> bool;
261  };
262 
263 };
265 
279 
281 } // namespace seqan3
seqan3::single
The text is a single range.
Definition: concept.hpp:84
semiregular
Subsumes std::copyable and std::default_constructible.
std::vector
concept.hpp
Adaptations of concepts from the standard library.
bi_fm_index_cursor_specialisation
Concept for bidirectional FM index cursors.
concept.hpp
Additional non-standard concepts for ranges.
seqan3::seq
constexpr sequenced_policy seq
Global execution policy object for sequenced execution policy.
Definition: execution.hpp:54
seqan3::text_layout
text_layout
The possible text layouts (single, collection) the seqan3::fm_index and seqan3::bi_fm_index can suppo...
Definition: concept.hpp:81
seqan3::collection
The text is a range of ranges.
Definition: concept.hpp:86
range.hpp
Provides various transformation traits used by the range module.
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
bi_fm_index_specialisation
Concept for bidirectional FM indices.
std::conditional_t
fm_index_specialisation
Concept for unidirectional FM indices.
fm_index_cursor_specialisation
Concept for unidirectional FM index cursors.