Needle
An application for fast and efficient searches of NGS data.
Loading...
Searching...
No Matches
shared.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
5#pragma once
6
7#include <robin_hood.h>
8
9#include <seqan3/alphabet/nucleotide/dna4.hpp>
10#include <seqan3/io/sequence_file/input.hpp>
11#include <seqan3/search/dream_index/interleaved_bloom_filter.hpp>
12#include <seqan3/search/kmer_index/shape.hpp>
13#include <seqan3/search/views/minimiser_hash.hpp>
14
15static inline constexpr uint64_t adjust_seed(uint8_t const kmer_size,
16 uint64_t const seed = 0x8F'3F'73'B5'CF'1C'9A'DEULL) noexcept
17{
18 return seed >> (64u - 2u * kmer_size);
19}
20
23{
24 std::filesystem::path path_out{"./"};
25 uint8_t threads{1};
26};
27
30{
31 uint8_t k{20};
32 seqan3::seed s{0x8F'3F'73'B5'CF'1C'9A'DEULL};
33 seqan3::shape shape = seqan3::ungapped{k};
34 seqan3::window_size w_size{60};
35};
36
39{
40 bool compressed = false;
41 std::vector<uint16_t> expression_thresholds{}; // Expression levels which should be created
42 uint8_t number_expression_thresholds{}; // If set, the expression levels are determined by the program.
43 bool samplewise{false};
44
45 template <class Archive>
46 void save(Archive & archive) const
47 {
48 archive(k);
49 archive(w_size.get());
50 archive(s.get());
51 archive(shape);
52 archive(compressed);
54 archive(expression_thresholds);
55 archive(samplewise);
56 }
57
58 template <class Archive>
59 void load(Archive & archive)
60 {
61 archive(k);
62 archive(w_size.get());
63 archive(s.get());
64 archive(shape);
65 archive(compressed);
67 archive(expression_thresholds);
68 archive(samplewise);
69 }
70};
71
76[[maybe_unused]] static void load_args(estimate_ibf_arguments & args, std::filesystem::path ipath)
77{
78 std::ifstream is{ipath, std::ios::binary};
79 cereal::BinaryInputArchive iarchive{is};
80 iarchive(args);
81}
82
87[[maybe_unused]] static void store_args(estimate_ibf_arguments const & args, std::filesystem::path opath)
88{
89 std::ofstream os{opath, std::ios::binary};
90 cereal::BinaryOutputArchive oarchive{os};
91 oarchive(args);
92}
93
95struct my_traits : seqan3::sequence_file_input_default_traits_dna
96{
97 using sequence_alphabet = seqan3::dna4;
98 //TODO: Should I use a bitcompressed_vector to save memory but with the disadvantage of losing speed?
99 //template <typename alph>
100 //using sequence_container = seqan3::bitcompressed_vector<alph>;
101};
102
107template <class IBFType>
108void load_ibf(IBFType & ibf, std::filesystem::path ipath)
109{
110 std::ifstream is{ipath, std::ios::binary};
111 cereal::BinaryInputArchive iarchive{is};
112 iarchive(ibf);
113}
114
119template <class IBFType>
120void store_ibf(IBFType const & ibf, std::filesystem::path opath)
121{
122 std::ofstream os{opath, std::ios::binary};
123 cereal::BinaryOutputArchive oarchive{os};
124 oarchive(ibf);
125}
std::vector< uint16_t > ibf(std::vector< std::filesystem::path > const &sequence_files, estimate_ibf_arguments &ibf_args, minimiser_arguments &minimiser_args, std::vector< double > &fpr, std::vector< uint8_t > &cutoffs, std::filesystem::path const expression_by_genome_file="", size_t num_hash=1)
Creates IBFs.
Definition ibf.cpp:1025
void load_ibf(IBFType &ibf, std::filesystem::path ipath)
Function, loading compressed and uncompressed ibfs.
Definition shared.hpp:108
void store_ibf(IBFType const &ibf, std::filesystem::path opath)
Function, which stored compressed and uncompressed ibfs.
Definition shared.hpp:120
arguments used for all tools
Definition shared.hpp:23
uint8_t threads
Definition shared.hpp:25
std::filesystem::path path_out
Definition shared.hpp:24
arguments used for estimate, ibf, ibfmin
Definition shared.hpp:39
void load(Archive &archive)
Definition shared.hpp:59
std::vector< uint16_t > expression_thresholds
Definition shared.hpp:41
uint8_t number_expression_thresholds
Definition shared.hpp:42
bool compressed
Definition shared.hpp:40
bool samplewise
Definition shared.hpp:43
void save(Archive &archive) const
Definition shared.hpp:46
arguments used for estimate, ibf, minimiser
Definition shared.hpp:30
uint8_t k
Definition shared.hpp:31
seqan3::shape shape
Definition shared.hpp:33
seqan3::window_size w_size
Definition shared.hpp:34
seqan3::seed s
Definition shared.hpp:32
Use dna4 instead of default dna5.
Definition shared.hpp:96
seqan3::dna4 sequence_alphabet
Definition shared.hpp:97