Raptor 3.0.0-rc.1
A fast and space-efficient pre-filter for querying very large collections of nucleotide sequences
 
store_index.hpp
Go to the documentation of this file.
1// --------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2023, 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/raptor/blob/main/LICENSE.md
6// --------------------------------------------------------------------------------------------------
7
13#pragma once
14
15#include <filesystem>
16
17#include <seqan3/search/dream_index/interleaved_bloom_filter.hpp>
18
19#include <raptor/index.hpp>
21
22namespace raptor
23{
24
25// Compresion handled in chopper_build
26template <index_structure::is_hibf data_t, typename arguments_t>
27static inline void store_index(std::filesystem::path const & path, raptor_index<data_t> && index, arguments_t const &)
28{
29 std::ofstream os{path, std::ios::binary};
30 cereal::BinaryOutputArchive oarchive{os};
31 oarchive(index);
32}
33
34template <index_structure::is_ibf data_t, typename arguments_t>
35static inline void
36store_index(std::filesystem::path const & path, raptor_index<data_t> && index, arguments_t const & arguments)
37{
38 if (!arguments.compressed)
39 {
40 std::ofstream os{path, std::ios::binary};
41 cereal::BinaryOutputArchive oarchive{os};
42 oarchive(index);
43 }
44 else
45 {
46 raptor_index<index_structure::ibf_compressed> compressed_index{std::move(index)};
47 std::ofstream os{path, std::ios::binary};
48 cereal::BinaryOutputArchive oarchive{os};
49 oarchive(compressed_index);
50 }
51}
52
53template <seqan3::data_layout layout, typename arguments_t>
54static inline void store_index(std::filesystem::path const & path,
55 seqan3::interleaved_bloom_filter<layout> && ibf,
56 arguments_t const & arguments)
57{
58 raptor_index<seqan3::interleaved_bloom_filter<layout>> index{window{arguments.window_size},
59 arguments.shape,
60 arguments.parts,
61 arguments.compressed,
62 arguments.bin_path,
63 arguments.fpr,
64 std::move(ibf)};
65
66 std::ofstream os{path, std::ios::binary};
67 cereal::BinaryOutputArchive oarchive{os};
68 oarchive(index);
69}
70
71} // namespace raptor
Provides raptor::raptor_index.
Provides raptor::window.