Debian Codegraph @

jellyfish/histo_main.cc

raw symbols SCIP
1 /* This file is part of Jellyfish.
2
3 Jellyfish is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version.
7
8 Jellyfish is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with Jellyfish. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #include <config.h>cxx . . $ `<file>/config.h`/
18 #include <stdlib.h>
19 #include <stdint.h>
20 #include <string.h>
21 #include <iostream>
22 #include <fstream>
23 #include <vector>
24
25 #include <jellyfish/err.hpp>cxx . . $ `<file>/jellyfish/err.hpp`/
26 #include <jellyfish/misc.hpp>cxx . . $ `<file>/jellyfish/misc.hpp`/
27 #include <jellyfish/mer_counting.hpp>cxx . . $ `<file>/jellyfish/mer_counting.hpp`/
28 #include <jellyfish/compacted_hash.hpp>cxx . . $ `<file>/jellyfish/compacted_hash.hpp`/
29 #include <jellyfish/thread_exec.hpp>cxx . . $ `<file>/jellyfish/thread_exec.hpp`/
30 #include <jellyfish/atomic_gcc.hpp>cxx . . $ `<file>/jellyfish/atomic_gcc.hpp`/
31 #include <jellyfish/counter.hpp>cxx . . $ `<file>/jellyfish/counter.hpp`/
32 #include <jellyfish/histo_main_cmdline.hpp>cxx . . $ `<file>/jellyfish/histo_main_cmdline.hpp`/
33 #include <jellyfish/fstream_default.hpp>cxx . . $ `<file>/jellyfish/fstream_default.hpp`/
34
35 template<typename hash_t>
36 class histogramcxx . . $ histogram# : public thread_execcxx . . $ thread_exec# {
37 const hash_t *hashcxx . . $ histogram#hash.;
38 const uint_tcxx . . $ uint_t# threadscxx . . $ histogram#threads.;
39 const uint64_tcxx . . $ uint64_t# basecxx . . $ histogram#base., ceilcxx . . $ histogram#ceil., inccxx . . $ histogram#inc., nb_bucketscxx . . $ histogram#nb_buckets., nb_slicescxx . . $ histogram#nb_slices.;
40 uint64_tcxx . . $ uint64_t# *datacxx . . $ histogram#data.;
41 counter_tcxx . . $ counter_t# slice_idcxx . . $ histogram#slice_id.;
42
43 public:
44 histogramcxx . . $ histogram#`histogram<hash_t>`(51b50038a4a77ea6).(const hash_t *_hash, uint_tcxx . . $ uint_t# _threads, uint64_tcxx . . $ uint64_t# _base,
45 uint64_tcxx . . $ uint64_t# _ceil, uint64_tcxx . . $ uint64_t# _inc) :
46 hashcxx . . $ histogram#hash.(_hash), threadscxx . . $ histogram#threads.(_threads), basecxx . . $ histogram#base.(_base), ceilcxx . . $ histogram#ceil.(_ceil), inccxx . . $ histogram#inc.(_inc),
47 nb_bucketscxx . . $ histogram#nb_buckets.((ceilcxx . . $ histogram#ceil. + inccxx . . $ histogram#inc. - basecxx . . $ histogram#base.) / inccxx . . $ histogram#inc.), nb_slicescxx . . $ histogram#nb_slices.(threadscxx . . $ histogram#threads. * 100)
48 {
49 datacxx . . $ histogram#data. = new uint64_tcxx . . $ uint64_t#[threadscxx . . $ histogram#threads. * nb_bucketscxx . . $ histogram#nb_buckets.];
50 memset(datacxx . . $ histogram#data., '\0', threadscxx . . $ histogram#threads. * nb_bucketscxx . . $ histogram#nb_buckets. * sizeof(uint64_tcxx . . $ uint64_t#));
51 }
52
53 ~cxx . . $ histogram#`~histogram<hash_t>`(49f6e7a06ebc5aa8).histogram() {
54 if(datacxx . . $ histogram#data.)
55 delete [] datacxx . . $ histogram#data.;
56 }
57
58 void do_itcxx . . $ histogram#do_it(49f6e7a06ebc5aa8).() {
59 exec_joincxx . . $ thread_exec#exec_join(d4f767463ce0a6b3).(threadscxx . . $ histogram#threads.);
60 }
61
62 void startcxx . . $ histogram#start(d4f767463ce0a6b3).(int th_id) {
63 uint64_tcxx . . $ uint64_t# *hist = &datacxx . . $ histogram#data.[th_id * nb_bucketscxx . . $ histogram#nb_buckets.];
64
65 for(size_t i = slice_idcxx . . $ histogram#slice_id.++cxx . . $ counter_t#operator++(c104ebd7d68b2193).; i < nb_slicescxx . . $ histogram#nb_slices.; i = slice_idcxx . . $ histogram#slice_id.++cxx . . $ counter_t#operator++(c104ebd7d68b2193).) {
66 typename hash_t::iterator it = hashcxx . . $ histogram#hash.->iterator_slice(i, nb_slicescxx . . $ histogram#nb_slices.);
67 while(it.next()) {
68 if(it.get_val() < basecxx . . $ histogram#base.)
69 ++hist[0];
70 else if(it.get_val() > ceilcxx . . $ histogram#ceil.)
71 ++hist[nb_bucketscxx . . $ histogram#nb_buckets. - 1];
72 else
73 ++hist[(it.get_val() - basecxx . . $ histogram#base.) / inccxx . . $ histogram#inc.];
74 }
75 }
76 }
77
78 void printcxx . . $ histogram#print(5a3dece3eb9333e2).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &out, bool full) {
79 uint64_tcxx . . $ uint64_t# col = basecxx . . $ histogram#base.;
80 for(uint64_tcxx . . $ uint64_t# i = 0; i < nb_bucketscxx . . $ histogram#nb_buckets.; i++, col += inccxx . . $ histogram#inc.) {
81 uint64_tcxx . . $ uint64_t# count = 0;
82 for(uint_tcxx . . $ uint_t# j = 0; j < threadscxx . . $ histogram#threads.; j++)
83 count += datacxx . . $ histogram#data.[j * nb_bucketscxx . . $ histogram#nb_buckets. + i];
84 if(count > 0 || full)
85 out <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). col <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). count <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n";
86 }
87 }
88 };
89
90 int histo_maincxx . . $ histo_main(afcd3168fc1188a4).(int argc, char *argv[])
91 {
92 histo_argscxx . . $ histo_args# argscxx . . $ histo_args#histo_args(c759356ac01a31e7).(argc, argv);
93
94 if(args.low_argcxx . . $ histo_args#low_arg. < 1)
95 args.errorcxx . . $ histo_args#error(85c52e162fed56f9).("Low count value must be >= 1");
96 if(args.high_argcxx . . $ histo_args#high_arg. < args.low_argcxx . . $ histo_args#low_arg.)
97 args.errorcxx . . $ histo_args#error(85c52e162fed56f9).("High count value must be >= to low count value");
98 ofstream_defaultcxx . . $ ofstream_default# outcxx . . $ fstream_default#fstream_default(44f340de0903ac7f).(args.output_givencxx . . $ histo_args#output_given. ? args.output_argcxx . . $ histo_args#output_arg. : 0, stdcxx . . $ std/::coutcxx . . $ std/cout.);
99 if(!out.goodcxx . . $ std/basic_ios#good(50ce9a9e25b4a850).())
100 diecxx . . $ `jellyfish/err.hpp:138:9`! <<cxx . . $ err/die_t#`operator<<`(f22e16ce67cbf691). "Error opening output file '" <<cxx . . $ err/die_t#`operator<<`(f22e16ce67cbf691). args.output_argcxx . . $ histo_args#output_arg. <<cxx . . $ err/die_t#`operator<<`(f22e16ce67cbf691). "'" <<cxx . . $ err/die_t#`operator<<`(e92b3d85e71c8936). errcxx . . $ err/::nocxx . . $ err/no.;
101
102 const uint64_tcxx . . $ uint64_t# base =
103 args.low_argcxx . . $ histo_args#low_arg. > 1 ? (args.increment_argcxx . . $ histo_args#increment_arg. >= args.low_argcxx . . $ histo_args#low_arg. ? 1 : args.low_argcxx . . $ histo_args#low_arg. - args.increment_argcxx . . $ histo_args#increment_arg.) : 1;
104 const uint64_tcxx . . $ uint64_t# ceil = args.high_argcxx . . $ histo_args#high_arg. + args.increment_argcxx . . $ histo_args#increment_arg.;
105
106 mapped_filecxx . . $ mapped_file# dbfcxx . . $ mapped_file#mapped_file(85c52e162fed56f9).(args.db_argcxx . . $ histo_args#db_arg..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).());
107 dbf.sequentialcxx . . $ mapped_file#sequential(b923b2a887bc4c86).().will_needcxx . . $ mapped_file#will_need(b923b2a887bc4c86).();
108 char type[8];
109 memcpy(type, dbf.basecxx . . $ mapped_file#base(e7e5aa338b9d5147).(), sizeof(type));
110 if(!strncmp(type, jellyfishcxx . . $ jellyfish/::raw_hashcxx . . $ jellyfish/raw_hash/::file_typecxx . . $ jellyfish/raw_hash/file_type., sizeof(type))) {
111 raw_inv_hash_query_tcxx . . $ raw_inv_hash_query_t# hashcxx . . $ jellyfish/raw_hash/query#query(e55f7c6e9effeb0d).(dbf);
112 histogramcxx . . $ histogram#<raw_inv_hash_query_tcxx . . $ raw_inv_hash_query_t#> histocxx . . $ histogram#histogram(51b50038a4a77ea6).(&hash, args.threads_argcxx . . $ histo_args#threads_arg., base, ceil, args.increment_argcxx . . $ histo_args#increment_arg.);
113 histo.do_itcxx . . $ histogram#do_it(49f6e7a06ebc5aa8).();
114 histo.printcxx . . $ histogram#print(5a3dece3eb9333e2).(out, args.full_flagcxx . . $ histo_args#full_flag.);
115 } else if(!strncmp(type, jellyfishcxx . . $ jellyfish/::compacted_hashcxx . . $ jellyfish/compacted_hash/::file_typecxx . . $ jellyfish/compacted_hash/file_type., sizeof(type))) {
116 hash_query_tcxx . . $ hash_query_t# hashcxx . . $ jellyfish/compacted_hash/query#query(e55f7c6e9effeb0d).(dbf);
117 if(args.verbose_flagcxx . . $ histo_args#verbose_flag.)
118 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "mer length = " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). hash.get_mer_lencxx . . $ jellyfish/compacted_hash/query#get_mer_len(fe4d2d262d4164a8).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"
119 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "hash size = " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). hash.get_sizecxx . . $ jellyfish/compacted_hash/query#get_size(fe4d2d262d4164a8).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"
120 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "max reprobe = " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). hash.get_max_reprobecxx . . $ jellyfish/compacted_hash/query#get_max_reprobe(fe4d2d262d4164a8).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"
121 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "matrix = " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). hash.get_hash_matrixcxx . . $ jellyfish/compacted_hash/query#get_hash_matrix(dc810cbe11cd8a39).().xor_sumcxx . . $ SquareBinaryMatrix#xor_sum(fe4d2d262d4164a8).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"
122 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "inv_matrix = " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). hash.get_hash_inverse_matrixcxx . . $ jellyfish/compacted_hash/query#get_hash_inverse_matrix(dc810cbe11cd8a39).().xor_sumcxx . . $ SquareBinaryMatrix#xor_sum(fe4d2d262d4164a8).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n";
123 histogramcxx . . $ histogram#<hash_query_tcxx . . $ hash_query_t#> histocxx . . $ histogram#histogram(51b50038a4a77ea6).(&hash, args.threads_argcxx . . $ histo_args#threads_arg., base, ceil, args.increment_argcxx . . $ histo_args#increment_arg.);
124 histo.do_itcxx . . $ histogram#do_it(49f6e7a06ebc5aa8).();
125 histo.printcxx . . $ histogram#print(5a3dece3eb9333e2).(out, args.full_flagcxx . . $ histo_args#full_flag.);
126 } else {
127 diecxx . . $ `jellyfish/err.hpp:138:9`! <<cxx . . $ err/die_t#`operator<<`(f22e16ce67cbf691). "Invalid file type '" <<cxx . . $ err/die_t#`operator<<`(f22e16ce67cbf691). errcxx . . $ err/substr#substr(7cafb6e0818eff3b).::substrcxx . . $ err/substr#(type, sizeof(type)) <<cxx . . $ err/die_t#`operator<<`(f22e16ce67cbf691). "'.";
128 }
129 out.closecxx . . $ fstream_default#close(49f6e7a06ebc5aa8).();
130
131 return 0;
132 }