15#include <sharg/exceptions.hpp>
24namespace index_structure
27using ibf = seqan3::interleaved_bloom_filter<seqan3::data_layout::uncompressed>;
28using ibf_compressed = seqan3::interleaved_bloom_filter<seqan3::data_layout::compressed>;
29using hibf = hierarchical_interleaved_bloom_filter<seqan3::data_layout::uncompressed>;
30using hibf_compressed = hierarchical_interleaved_bloom_filter<seqan3::data_layout::compressed>;
32template <
typename return_t,
typename input_t>
33concept compressible_from = (std::same_as<return_t, ibf_compressed> && std::same_as<input_t, ibf>)
34 || (std::same_as<return_t, hibf_compressed> && std::same_as<input_t, hibf>);
36template <
typename index_t>
37concept is_ibf = std::same_as<index_t, index_structure::ibf> || std::same_as<index_t, index_structure::ibf_compressed>;
39template <
typename index_t>
41 std::same_as<index_t, index_structure::hibf> || std::same_as<index_t, index_structure::hibf_compressed>;
43template <
typename index_t>
45 std::same_as<index_t, index_structure::ibf_compressed> || std::same_as<index_t, index_structure::hibf_compressed>;
49template <seqan3::data_layout data_layout_mode_>
52template <
typename data_t = index_structure::ibf>
56 template <
typename friend_data_t>
59 uint64_t window_size_{};
60 seqan3::shape shape_{};
69 static constexpr seqan3::data_layout data_layout_mode = data_t::data_layout_mode;
70 static constexpr uint32_t version{2u};
80 seqan3::shape
const shape,
82 bool const compressed,
86 window_size_{window_size.v},
89 compressed_{compressed},
96 window_size_{arguments.window_size},
97 shape_{arguments.shape},
98 parts_{arguments.parts},
99 compressed_{arguments.compressed},
100 bin_path_{arguments.bin_path},
102 ibf_{seqan3::bin_count{arguments.bins},
103 seqan3::bin_size{arguments.bits / arguments.parts},
104 seqan3::hash_function_count{arguments.hash}}
106 static_assert(data_layout_mode == seqan3::data_layout::uncompressed);
109 template <
typename other_data_t>
113 window_size_ = other.window_size_;
114 shape_ = other.shape_;
115 parts_ = other.parts_;
117 bin_path_ = other.bin_path_;
118 ibf_ = data_t{other.ibf_};
122 template <
typename other_data_t>
126 window_size_ = std::move(other.window_size_);
127 shape_ = std::move(other.shape_);
128 parts_ = std::move(other.parts_);
130 bin_path_ = std::move(other.bin_path_);
131 fpr_ = std::move(other.fpr_);
132 ibf_ = std::move(data_t{std::move(other.ibf_)});
135 uint64_t window_size()
const
140 seqan3::shape shape()
const
145 uint8_t parts()
const
150 bool compressed()
const
175 data_t
const & ibf()
const
188 template <seqan3::cereal_archive archive_t>
189 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
192 archive(parsed_version);
197 archive(window_size_);
200 bool const type_is_compressed{compressed_};
201 archive(compressed_);
202 if (type_is_compressed != compressed_)
203 throw sharg::parser_error{
"Data layouts of serialised and specified index differ."};
211 throw sharg::parser_error{
"Cannot read index: " +
std::string{e.
what()}};
216 throw sharg::parser_error{
"Unsupported index version. Check raptor upgrade."};
228 template <seqan3::cereal_input_archive archive_t>
229 void load_parameters(archive_t & archive)
231 uint32_t parsed_version{};
232 archive(parsed_version);
233 if (parsed_version == version)
237 archive(window_size_);
240 archive(compressed_);
248 throw sharg::parser_error{
"Cannot read index: " +
std::string{e.
what()}};
254 throw sharg::parser_error{
"Unsupported index version. Check raptor upgrade."};
259 template <seqan3::cereal_input_archive archive_t>
262 uint32_t parsed_version{};
263 archive(parsed_version);
264 if (parsed_version == 1u)
268 archive(window_size_);
271 archive(compressed_);
277 throw sharg::parser_error{
"Cannot read index: " +
std::string{e.
what()}};
283 throw sharg::parser_error{
"Unsupported index version. Use Raptor 2.0's upgrade first."};
289 template <seqan3::data_layout data_layout_mode_>
294 template <seqan3::cereal_archive archive_t>
297 uint32_t parsed_version{};
298 archive(parsed_version);
299 if (parsed_version == 1u)
303 archive(window_size_);
306 archive(compressed_);
313 throw sharg::parser_error{
"Cannot read index: " +
std::string{e.
what()}};
319 throw sharg::parser_error{
"Unsupported index version. Use Raptor 2.0's upgrade first."};
Provides raptor::build_arguments.
Definition: index_upgrader.hpp:23
void load_old_parameters(archive_t &archive)
Load parameters from old index format for use with raptor upgrade.
Definition: index.hpp:260
void load_old_index(archive_t &archive)
Load old index format for use with raptor upgrade.
Definition: index.hpp:295
Provides raptor::hierarchical_interleaved_bloom_filter.
Definition: build_arguments.hpp:28
Strong type for passing the window size.
Definition: strong_types.hpp:22