SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
concept.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, 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 
21 #include <seqan3/range/concept.hpp>
23 
24 namespace seqan3::detail
25 {
26 
31  // ============================================================================
32  // SdslIndex
33  // ============================================================================
34 
38 template <typename t>
40 SEQAN3_CONCEPT SdslIndex = requires (t sdsl_index)
41 {
42  typename t::size_type;
43 
44  { sdsl_index.size() } -> typename t::size_type;
45  { sdsl_index[0] }; // suffix array access
46  { sdsl_index.comp2char[0] } -> uint8_t;
47  { sdsl_index.char2comp[0] } -> uint8_t;
48  { sdsl_index.sigma };
49  { sdsl_index.C[0] };
50 
51  requires requires (t sdsl_index, typename t::char_type const c, typename t::size_type const lb,
52  typename t::size_type const rb, sdsl::int_vector<8> const text)
53  {
54  { sdsl_index.bwt.rank(lb, c) };
55  { sdsl_index.wavelet_tree.lex_count(lb, rb, c) };
56  { sdsl::construct_im(sdsl_index, text, 0) };
57  };
58 };
60 
70 
72 } // namespace seqan3::detail
73 
74 namespace seqan3
75 {
76 
81 // ============================================================================
82 // FmIndex
83 // ============================================================================
84 
90 template <typename t>
92 SEQAN3_CONCEPT FmIndex = std::Semiregular<t> && requires (t index)
93 {
94  typename t::size_type;
95  // typename t::cursor_type;
96 
97  // NOTE: circular dependency
98  // requires FmIndexCursor<typename t::cursor_type>;
99  requires requires (t index, std::conditional_t<t::is_collection_,
101  std::vector<dna4>> const text)
102  {
103  { t(text) };
104  { index.construct(text) } -> void;
105  };
106 
107  { index.begin() } -> typename t::cursor_type;
108 
109  { index.size() } -> typename t::size_type;
110  { index.empty() } -> bool;
111 };
113 
132 // ============================================================================
133 // FmIndexCursor
134 // ============================================================================
135 
141 template <typename t>
143 SEQAN3_CONCEPT FmIndexCursor = std::Semiregular<t> && requires (t cur)
144 {
145  typename t::index_type;
146  typename t::size_type;
147 
148  requires FmIndex<typename t::index_type>;
149 
150  requires requires (typename t::index_type const index) { { t(index) } };
151 
152  requires requires (t cur, dna4 const c, std::vector<dna4> const seq,
153  std::conditional_t<t::index_type::is_collection_,
155  std::vector<dna4>> const text)
156  {
157  { cur.extend_right() } -> bool;
158  { cur.extend_right(c) } -> bool;
159  { cur.extend_right(seq) } -> bool;
160  { cur.cycle_back() } -> bool;
161  { cur.path_label(text) } -> auto;
162  };
163 
164  { cur.last_rank() } -> typename t::size_type;
165  { cur.query_length() } -> typename t::size_type;
166  { cur.count() } -> typename t::size_type;
167  { cur.locate() } -> std::conditional_t<t::index_type::is_collection_,
170  { cur.lazy_locate() } -> auto;
171 };
173 
186 // ============================================================================
187 // BiFmIndex
188 // ============================================================================
189 
195 template <typename t>
197 SEQAN3_CONCEPT BiFmIndex = FmIndex<t> && requires (t index)
198 {
199  typename t::cursor_type; // already required by FmIndex but has a different documentation
200  typename t::fwd_cursor_type;
201  typename t::rev_cursor_type;
202 
203  // NOTE: circular dependency
204  // requires BiFmIndexCursor<typename t::cursor_type>;
205 
206  { index.fwd_begin() } -> typename t::fwd_cursor_type;
207  { index.rev_begin() } -> typename t::rev_cursor_type;
208 };
210 
226 // ============================================================================
227 // BiFmIndexCursor
228 // ============================================================================
229 
235 template <typename t>
237 SEQAN3_CONCEPT BiFmIndexCursor = FmIndexCursor<t> && requires (t cur)
238 {
239  requires BiFmIndex<typename t::index_type>;
240 
241  requires requires (typename t::index_type const index) { { t(index) } };
242 
243  requires requires (t cur, dna4 const c, std::vector<dna4> const seq)
244  {
245  { cur.extend_left() } -> bool;
246  { cur.extend_left(c) } -> bool;
247  { cur.extend_left(seq) } -> bool;
248  { cur.cycle_front() } -> bool;
249  };
250 
251 };
253 
267 
269 } // namespace seqan3
constexpr sequenced_policy seq
Global execution policy object for sequenced execution policy.
Definition: execution.hpp:54
The main SeqAn3 namespace.
Additional non-standard concepts for ranges.
Definition: aligned_sequence_concept.hpp:35
Subsumes std::Copyable and std::DefaultConstructible.
Provides various transformation traits used by the range module.
Provides seqan3::dna4, container aliases and string literals.
Adaptations of concepts from the standard library.