Raptor 3.0.0-rc.1
A fast and space-efficient pre-filter for querying very large collections of nucleotide sequences
 
sync_out.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#include <fstream>
17#include <mutex>
18
19#include <seqan3/utility/views/join_with.hpp>
20
22
23namespace raptor
24{
25
27{
28public:
29 sync_out() = default;
30 sync_out(sync_out const &) = default;
31 sync_out & operator=(sync_out const &) = default;
32 sync_out(sync_out &&) = default;
33 sync_out & operator=(sync_out &&) = default;
34 ~sync_out() = default;
35
36 sync_out(search_arguments const & arguments) : file{arguments.out_file}
37 {
38 write_header(arguments);
39 }
40
41 template <typename t>
42 void write(t && data)
43 {
44 std::lock_guard<std::mutex> lock{write_mutex};
45 file << std::forward<t>(data);
46 }
47
48private:
49 void write_header(search_arguments const & arguments)
50 {
51 file << "### Minimiser parameters\n";
52 file << "## Window size = " << arguments.window_size << '\n';
53 file << "## Shape = " << arguments.shape.to_string() << '\n';
54 file << "## Shape size (length) = " << static_cast<uint16_t>(arguments.shape_size) << '\n';
55 file << "## Shape count (number of 1s) = " << static_cast<uint16_t>(arguments.shape_weight) << '\n';
56 file << "### Search parameters\n";
57 file << "## Query file = " << arguments.query_file << '\n';
58 file << "## Pattern size = " << arguments.query_length << '\n';
59 file << "## Output file = " << arguments.out_file << '\n';
60 file << "## Threads = " << static_cast<uint16_t>(arguments.threads) << '\n';
61 file << "## tau = " << arguments.tau << '\n';
62 file << "## p_max = " << arguments.p_max << '\n';
63 file << "## Percentage threshold = " << arguments.threshold << '\n';
64 file << "## Errors = " << static_cast<uint16_t>(arguments.errors) << '\n';
65 file << "## Cache thresholds = " << std::boolalpha << arguments.cache_thresholds << '\n';
66 file << "### Index parameters\n";
67 file << "## Index = " << arguments.index_file << '\n';
68 file << "## Index parts = " << static_cast<uint16_t>(arguments.parts) << '\n';
69 file << "## False positive rate = " << arguments.fpr << '\n';
70 file << "## Index is compressed = " << std::boolalpha << arguments.compressed << '\n';
71 file << "## Index is HIBF = " << std::boolalpha << arguments.is_hibf << '\n';
72
73 size_t user_bin_id{};
74 for (auto const & file_list : arguments.bin_path)
75 {
76 file << '#' << user_bin_id << '\t';
77 for (auto const elem : seqan3::views::join_with(file_list, ','))
78 file << elem;
79 file << '\n';
80 ++user_bin_id;
81 }
82
83 file << "#QUERY_NAME\tUSER_BINS\n";
84 }
85
86 std::ofstream file;
87 std::mutex write_mutex;
88};
89
90} // namespace raptor
T boolalpha(T... args)
Definition: sync_out.hpp:27
Provides raptor::search_arguments.
Definition: search_arguments.hpp:28