Loading...
Searching...
No Matches
shared.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <robin_hood.h>
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/io/sequence_file/input.hpp>
#include <seqan3/search/dream_index/interleaved_bloom_filter.hpp>
#include <seqan3/search/kmer_index/shape.hpp>
#include <seqan3/search/views/minimiser_hash.hpp>
static inline constexpr uint64_t adjust_seed(uint8_t const kmer_size,
uint64_t const seed = 0x8F'3F'73'B5'CF'1C'9A'DEULL) noexcept
{
return seed >> (64u - 2u * kmer_size);
}
struct all_arguments
{
std::filesystem::path path_out{"./"};
uint8_t threads{1};
};
struct min_arguments : all_arguments
{
uint8_t k{20};
seqan3::seed s{0x8F'3F'73'B5'CF'1C'9A'DEULL};
seqan3::shape shape = seqan3::ungapped{k};
seqan3::window_size w_size{60};
};
struct estimate_ibf_arguments : min_arguments
{
bool compressed = false;
std::vector<uint16_t> expression_thresholds{}; // Expression levels which should be created
uint8_t number_expression_thresholds{}; // If set, the expression levels are determined by the program.
bool samplewise{false};
template <class Archive>
void save(Archive & archive) const
{
archive(k);
archive(w_size.get());
archive(s.get());
archive(shape);
archive(compressed);
archive(number_expression_thresholds);
archive(expression_thresholds);
archive(samplewise);
}
template <class Archive>
void load(Archive & archive)
{
archive(k);
archive(w_size.get());
archive(s.get());
archive(shape);
archive(compressed);
archive(number_expression_thresholds);
archive(expression_thresholds);
archive(samplewise);
}
};
[[maybe_unused]] static void load_args(estimate_ibf_arguments & args, std::filesystem::path ipath)
{
std::ifstream is{ipath, std::ios::binary};
cereal::BinaryInputArchive iarchive{is};
iarchive(args);
}
[[maybe_unused]] static void store_args(estimate_ibf_arguments const & args, std::filesystem::path opath)
{
std::ofstream os{opath, std::ios::binary};
cereal::BinaryOutputArchive oarchive{os};
oarchive(args);
}
struct my_traits : seqan3::sequence_file_input_default_traits_dna
{
using sequence_alphabet = seqan3::dna4;
//TODO: Should I use a bitcompressed_vector to save memory but with the disadvantage of losing speed?
//template <typename alph>
//using sequence_container = seqan3::bitcompressed_vector<alph>;
};
template <class IBFType>
void load_ibf(IBFType & ibf, std::filesystem::path ipath)
{
std::ifstream is{ipath, std::ios::binary};
cereal::BinaryInputArchive iarchive{is};
iarchive(ibf);
}
template <class IBFType>
void store_ibf(IBFType const & ibf, std::filesystem::path opath)
{
std::ofstream os{opath, std::ios::binary};
cereal::BinaryOutputArchive oarchive{os};
oarchive(ibf);
}
ibf
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
load_ibf
void load_ibf(IBFType &ibf, std::filesystem::path ipath)
Function, loading compressed and uncompressed ibfs.
Definition shared.hpp:108
store_ibf
void store_ibf(IBFType const &ibf, std::filesystem::path opath)
Function, which stored compressed and uncompressed ibfs.
Definition shared.hpp:120
all_arguments
arguments used for all tools
Definition shared.hpp:23
all_arguments::threads
uint8_t threads
Definition shared.hpp:25
all_arguments::path_out
std::filesystem::path path_out
Definition shared.hpp:24
estimate_ibf_arguments
arguments used for estimate, ibf, ibfmin
Definition shared.hpp:39
estimate_ibf_arguments::load
void load(Archive &archive)
Definition shared.hpp:59
estimate_ibf_arguments::expression_thresholds
std::vector< uint16_t > expression_thresholds
Definition shared.hpp:41
estimate_ibf_arguments::number_expression_thresholds
uint8_t number_expression_thresholds
Definition shared.hpp:42
estimate_ibf_arguments::compressed
bool compressed
Definition shared.hpp:40
estimate_ibf_arguments::samplewise
bool samplewise
Definition shared.hpp:43
estimate_ibf_arguments::save
void save(Archive &archive) const
Definition shared.hpp:46
min_arguments
arguments used for estimate, ibf, minimiser
Definition shared.hpp:30
min_arguments::k
uint8_t k
Definition shared.hpp:31
min_arguments::shape
seqan3::shape shape
Definition shared.hpp:33
min_arguments::w_size
seqan3::window_size w_size
Definition shared.hpp:34
min_arguments::s
seqan3::seed s
Definition shared.hpp:32
my_traits
Use dna4 instead of default dna5.
Definition shared.hpp:96
my_traits::sequence_alphabet
seqan3::dna4 sequence_alphabet
Definition shared.hpp:97