fastq_to_fasta
A template for creation of SeqAn3 apps, with a FASTQ to FASTA example app.
build_data.hpp
Go to the documentation of this file.
1// --------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, 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
8#pragma once
9
10#include <atomic>
11#include <seqan3/std/new>
12
15
16namespace raptor::hibf
17{
18
19template <seqan3::data_layout data_layout_mode>
21{
22 alignas(std::hardware_destructive_interference_size) std::atomic<size_t> ibf_number{};
23 alignas(std::hardware_destructive_interference_size) std::atomic<size_t> user_bin_number{};
24
27
28 lemon::ListDigraph ibf_graph{};
29 lemon::ListDigraph::NodeMap<node_data> node_map{ibf_graph};
30
32 std::vector<double> fp_correction{};
33
35 {
36 return std::atomic_fetch_add(&ibf_number, 1u);
37 }
38
40 {
41 return std::atomic_fetch_add(&user_bin_number, 1u);
42 }
43
44 void resize()
45 {
47 hibf.user_bins.set_ibf_count(number_of_ibfs);
48 hibf.user_bins.set_user_bin_count(number_of_user_bins);
50 }
51
52 void compute_fp_correction(size_t const tmax, size_t const hash, double const fpr)
53 {
54 fp_correction.resize(tmax + 1, 1.0);
55
56 double const denominator = std::log(1 - std::exp(std::log(fpr) / hash));
57
58 for (size_t i = 2; i <= tmax; ++i)
59 {
60 double const tmp = 1.0 - std::pow(1 - fpr, static_cast<double>(i));
61 fp_correction[i] = std::log(1 - std::exp(std::log(tmp) / hash)) / denominator;
62 assert(fp_correction[i] >= 1.0);
63 }
64 }
65};
66
67} // namespace raptor::hibf
std::vector< ibf_t > ibf_vector
The individual interleaved Bloom filters.
Definition: hierarchical_interleaved_bloom_filter.hpp:113
std::vector< std::vector< int64_t > > next_ibf_id
Stores for each bin in each IBF of the HIBF the ID of the next IBF.
Definition: hierarchical_interleaved_bloom_filter.hpp:122
user_bins user_bins
The underlying user bins.
Definition: hierarchical_interleaved_bloom_filter.hpp:125
Must be first include.
Definition: bin_prefixes.hpp:13
Definition: build_data.hpp:21
std::atomic< size_t > ibf_number
Definition: build_data.hpp:22
size_t number_of_user_bins
Definition: build_data.hpp:25
lemon::ListDigraph ibf_graph
Definition: build_data.hpp:28
std::atomic< size_t > user_bin_number
Definition: build_data.hpp:23
size_t request_ibf_idx()
Definition: build_data.hpp:34
void compute_fp_correction(size_t const tmax, size_t const hash, double const fpr)
Definition: build_data.hpp:52
size_t request_user_bin_idx()
Definition: build_data.hpp:39
lemon::ListDigraph::NodeMap< node_data > node_map
Definition: build_data.hpp:29
size_t number_of_ibfs
Definition: build_data.hpp:26
hierarchical_interleaved_bloom_filter< data_layout_mode > hibf
Definition: build_data.hpp:31
void resize()
Definition: build_data.hpp:44
std::vector< double > fp_correction
Definition: build_data.hpp:32