Debian Codegraph @

jellyfish/mer_counter.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 <pthread.h>
19 #include <fstream>
20 #include <exception>
21 #include <memory>
22 #include <errno.h>
23 #include <string.h>
24 #include <stdlib.h>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <fcntl.h>
28 #include <unistd.h>
29 #include <sys/mman.h>
30 #include <stdint.h>
31 #include <inttypes.h>
32
33 #include <jellyfish/err.hpp>cxx . . $ `<file>/jellyfish/err.hpp`/
34 #include <jellyfish/dbg.hpp>cxx . . $ `<file>/jellyfish/dbg.hpp`/
35 #include <jellyfish/backtrace.hpp>cxx . . $ `<file>/jellyfish/backtrace.hpp`/
36 #include <jellyfish/misc.hpp>cxx . . $ `<file>/jellyfish/misc.hpp`/
37 #include <jellyfish/time.hpp>cxx . . $ `<file>/jellyfish/time.hpp`/
38 #include <jellyfish/mer_counting.hpp>cxx . . $ `<file>/jellyfish/mer_counting.hpp`/
39 #include <jellyfish/locks_pthread.hpp>cxx . . $ `<file>/jellyfish/locks_pthread.hpp`/
40 #include <jellyfish/thread_exec.hpp>cxx . . $ `<file>/jellyfish/thread_exec.hpp`/
41 #include <jellyfish/square_binary_matrix.hpp>cxx . . $ `<file>/jellyfish/square_binary_matrix.hpp`/
42 #include <jellyfish/count_main_cmdline.hpp>cxx . . $ `<file>/jellyfish/count_main_cmdline.hpp`/
43 #include <jellyfish/noop_dumper.hpp>cxx . . $ `<file>/jellyfish/noop_dumper.hpp`/
44
45 // Temporary
46 //#include <jellyfish/measure_dumper.hpp>
47
48 void die_on_errorcxx . . $ die_on_error(80d0450aec2fd74).(stdcxx . . $ std/::stringcxx . . $ std/string#& err) {
49 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Error: " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). err <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
50 exit(1);
51 }
52
53 void warn_on_errorcxx . . $ warn_on_error(80d0450aec2fd74).(stdcxx . . $ std/::stringcxx . . $ std/string#& err) {
54 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Warn: " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). err <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
55 }
56
57
58 // TODO: This mer_counting_base stuff has become wild. Lots of code
59 // duplication and slightly different behavior for each (e.g. setup of
60 // the hashing matrix). Refactor!
61 class mer_counting_basecxx . . $ mer_counting_base# {
62 public:
63 virtual ~cxx . . $ mer_counting_base#`~mer_counting_base`(ced63f7c635d850d).mer_counting_basecxx . . $ mer_counting_base#() {}
64 virtual void countcxx . . $ mer_counting_base#count(49f6e7a06ebc5aa8).() = 0;
65 virtual Timecxx . . $ Time# get_writing_timecxx . . $ mer_counting_base#get_writing_time(3a9c327c3081e598).() const = 0;
66 virtual uint64_tcxx . . $ uint64_t# get_distinctcxx . . $ mer_counting_base#get_distinct(fe4d2d262d4164a8).() const = 0;
67 virtual uint64_tcxx . . $ uint64_t# get_totalcxx . . $ mer_counting_base#get_total(fe4d2d262d4164a8).() const = 0;
68 };
69
70 template <typename parser_t, typename hash_t>
71 class mer_countingcxx . . $ mer_counting# : public mer_counting_basecxx . . $ mer_counting_base#, public thread_execcxx . . $ thread_exec# {
72 protected:
73 count_argscxx . . $ count_args# *argscxx . . $ mer_counting#args.;
74 lockscxx . . $ locks/::pthreadcxx . . $ locks/pthread/::barriercxx . . $ locks/pthread/barrier# sync_barriercxx . . $ mer_counting#sync_barrier.;
75 parser_t *parsercxx . . $ mer_counting#parser.;
76 typename hash_t::storage_t *arycxx . . $ mer_counting#ary.;
77 hash_t *hashcxx . . $ mer_counting#hash.;
78 jellyfishcxx . . $ jellyfish/::dumper_tcxx . . $ jellyfish/dumper_t# *dumpercxx . . $ mer_counting#dumper.;
79 uint64_tcxx . . $ uint64_t# distinctcxx . . $ mer_counting#distinct., totalcxx . . $ mer_counting#total.;
80
81 public:
82 explicit mer_countingcxx . . $ mer_counting#`mer_counting<parser_t, hash_t>`(8bdc77118e417c57).(count_argscxx . . $ count_args# &_args) :
83 argscxx . . $ mer_counting#args.(&_args), sync_barriercxx . . $ mer_counting#sync_barrier.(argscxx . . $ mer_counting#args.->threads_argcxx . . $ count_args#threads_arg.),
84 distinctcxx . . $ mer_counting#distinct.(0), totalcxx . . $ mer_counting#total.(0) {}
85
86 ~cxx . . $ mer_counting#`~mer_counting<parser_t, hash_t>`(49f6e7a06ebc5aa8).mer_counting() {
87 if(dumpercxx . . $ mer_counting#dumper.)
88 delete dumpercxx . . $ mer_counting#dumper.;
89 if(hashcxx . . $ mer_counting#hash.)
90 delete hashcxx . . $ mer_counting#hash.;
91 if(arycxx . . $ mer_counting#ary.)
92 delete arycxx . . $ mer_counting#ary.;
93 if(parsercxx . . $ mer_counting#parser.)
94 delete parsercxx . . $ mer_counting#parser.;
95 }
96
97 void startcxx . . $ mer_counting#start(d4f767463ce0a6b3).(int id) {
98 sync_barriercxx . . $ mer_counting#sync_barrier..waitcxx . . $ locks/pthread/barrier#wait(b126dc7c1de90089).();
99
100 typename parser_t::thread mer_stream(parsercxx . . $ mer_counting#parser.->new_thread());
101 typename hash_t::thread_ptr_t counter(hashcxx . . $ mer_counting#hash.->new_thread());
102
103 if(argscxx . . $ mer_counting#args.->invalid_char_argcxx . . $ count_args#invalid_char_arg. != count_argscxx . . $ count_args#::invalid_charcxx . . $ count_args#invalid_char#::ignorecxx . . $ count_args#invalid_char#ignore.) {
104 if(argscxx . . $ mer_counting#args.->invalid_char_argcxx . . $ count_args#invalid_char_arg. == count_argscxx . . $ count_args#::invalid_charcxx . . $ count_args#invalid_char#::warncxx . . $ count_args#invalid_char#warn.)
105 mer_stream.set_error_reporter(warn_on_errorcxx . . $ warn_on_error(80d0450aec2fd74).);
106 else
107 mer_stream.set_error_reporter(die_on_errorcxx . . $ die_on_error(80d0450aec2fd74).);
108 }
109
110 mer_stream.parse(counter);
111
112 bool is_serial = sync_barriercxx . . $ mer_counting#sync_barrier..waitcxx . . $ locks/pthread/barrier#wait(b126dc7c1de90089).() == PTHREAD_BARRIER_SERIAL_THREADcxx . . $ `<external>/14712363683955484316/pthread.h:193:10`!;
113 if(is_serial) {
114 hashcxx . . $ mer_counting#hash.->dump();
115 }
116
117 atomiccxx . . $ atomic/::gcccxx . . $ atomic/gcc#::fetch_addcxx . . $ atomic/gcc#fetch_add(5d0b15b8e1502815).(&distinctcxx . . $ mer_counting#distinct., mer_stream.get_distinct());
118 atomiccxx . . $ atomic/::gcccxx . . $ atomic/gcc#::fetch_addcxx . . $ atomic/gcc#fetch_add(5d0b15b8e1502815).(&totalcxx . . $ mer_counting#total., mer_stream.get_total());
119 }
120
121 void countcxx . . $ mer_counting#count(49f6e7a06ebc5aa8).() {
122 exec_joincxx . . $ thread_exec#exec_join(d4f767463ce0a6b3).(argscxx . . $ mer_counting#args.->threads_argcxx . . $ count_args#threads_arg.);
123 }
124
125 virtual Timecxx . . $ Time# get_writing_timecxx . . $ mer_counting#get_writing_time(3a9c327c3081e598).() const { return hashcxx . . $ mer_counting#hash.->get_writing_time(); }
126 virtual uint64_tcxx . . $ uint64_t# get_distinctcxx . . $ mer_counting#get_distinct(fe4d2d262d4164a8).() const { return distinctcxx . . $ mer_counting#distinct.; }
127 virtual uint64_tcxx . . $ uint64_t# get_totalcxx . . $ mer_counting#get_total(fe4d2d262d4164a8).() const { return totalcxx . . $ mer_counting#total.; }
128 };
129
130 class mer_counting_fasta_hashcxx . . $ mer_counting_fasta_hash# : public mer_countingcxx . . $ mer_counting#<jellyfishcxx . . $ jellyfish/::parse_dnacxx . . $ jellyfish/parse_dna#, inv_hash_tcxx . . $ inv_hash_t#> {
131 public:
132 mer_counting_fasta_hashcxx . . $ mer_counting_fasta_hash#mer_counting_fasta_hash(25ae2d073e50eb45).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> &files,
133 count_argscxx . . $ count_args# &_args) :
134 mer_countingcxx . . $ mer_counting#<jellyfishcxx . . $ jellyfish/::parse_dnacxx . . $ jellyfish/parse_dna#, inv_hash_tcxx . . $ inv_hash_t#>(_args)
135 {
136 parsercxx . . $ mer_counting#parser. = new jellyfishcxx . . $ jellyfish/::parse_dnacxx . . $ jellyfish/parse_dna#(files.begincxx . . $ std/vector#begin(d1e1699016b9d7e6).(), files.endcxx . . $ std/vector#end(d1e1699016b9d7e6).(),
137 argscxx . . $ mer_counting#args.->mer_len_argcxx . . $ count_args#mer_len_arg., argscxx . . $ mer_counting#args.->buffers_argcxx . . $ count_args#buffers_arg.,
138 argscxx . . $ mer_counting#args.->buffer_size_argcxx . . $ count_args#buffer_size_arg.);
139 arycxx . . $ mer_counting#ary. = new inv_hash_tcxx . . $ inv_hash_t#::storage_tcxx . . $ jellyfish/hash#storage_t#(argscxx . . $ mer_counting#args.->size_argcxx . . $ count_args#size_arg., 2*argscxx . . $ mer_counting#args.->mer_len_argcxx . . $ count_args#mer_len_arg.,
140 argscxx . . $ mer_counting#args.->counter_len_argcxx . . $ count_args#counter_len_arg.,
141 argscxx . . $ mer_counting#args.->reprobes_argcxx . . $ count_args#reprobes_arg.,
142 jellyfishcxx . . $ jellyfish/::quadratic_reprobescxx . . $ jellyfish/quadratic_reprobes.);
143 if(argscxx . . $ mer_counting#args.->matrix_givencxx . . $ count_args#matrix_given.) {
144 stdcxx . . $ std/::ifstreamcxx . . $ std/ifstream# fdcxx . . $ std/basic_ifstream#basic_ifstream(49f6e7a06ebc5aa8).;
145 fd.exceptionscxx . . $ std/basic_ios#exceptions(3e5fb2eb616d497d).(stdcxx . . $ std/::ifstreamcxx . . $ std/ifstream#::eofbitcxx . . $ std/ios_base#eofbit.|cxx . . $ std/`operator|`(c5b5c7d100a244bc).stdcxx . . $ std/::ifstreamcxx . . $ std/ifstream#::failbitcxx . . $ std/ios_base#failbit.|cxx . . $ std/`operator|`(c5b5c7d100a244bc).stdcxx . . $ std/::ifstreamcxx . . $ std/ifstream#::badbitcxx . . $ std/ios_base#badbit.);
146 fd.opencxx . . $ std/basic_ifstream#open(b8cd37071ce335df).(argscxx . . $ mer_counting#args.->matrix_argcxx . . $ count_args#matrix_arg..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).());
147 SquareBinaryMatrixcxx . . $ SquareBinaryMatrix# mcxx . . $ SquareBinaryMatrix#SquareBinaryMatrix(6a35a7fc14119650).(&fd);
148 fd.closecxx . . $ std/basic_ifstream#close(49f6e7a06ebc5aa8).();
149 arycxx . . $ mer_counting#ary.->set_matrixcxx . . $ jellyfish/invertible_hash/array#set_matrix(fcc8cfd4906a90f5).(m);
150 }
151 hashcxx . . $ mer_counting#hash. = new inv_hash_tcxx . . $ inv_hash_t#(arycxx . . $ mer_counting#ary.);
152
153 if(argscxx . . $ mer_counting#args.->no_write_flagcxx . . $ count_args#no_write_flag.) {
154 dumpercxx . . $ mer_counting#dumper. = new jellyfishcxx . . $ jellyfish/::noop_dumpercxx . . $ jellyfish/noop_dumper#();
155 } else {
156 // if(args->measure) {
157 // dumper = new jellyfish::measure_dumper<inv_hash_t::storage_t>(ary);
158 // } else
159 if(argscxx . . $ mer_counting#args.->raw_flagcxx . . $ count_args#raw_flag.) {
160 dumpercxx . . $ mer_counting#dumper. = new raw_inv_hash_dumper_tcxx . . $ raw_inv_hash_dumper_t#((uint_tcxx . . $ uint_t#)4, argscxx . . $ mer_counting#args.->output_argcxx . . $ count_args#output_arg..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(),
161 argscxx . . $ mer_counting#args.->out_buffer_size_argcxx . . $ count_args#out_buffer_size_arg., arycxx . . $ mer_counting#ary.);
162 } else {
163 inv_hash_dumper_tcxx . . $ inv_hash_dumper_t# *_dumper =
164 new inv_hash_dumper_tcxx . . $ inv_hash_dumper_t#(argscxx . . $ mer_counting#args.->threads_argcxx . . $ count_args#threads_arg., argscxx . . $ mer_counting#args.->output_argcxx . . $ count_args#output_arg..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(),
165 argscxx . . $ mer_counting#args.->out_buffer_size_argcxx . . $ count_args#out_buffer_size_arg.,
166 8*argscxx . . $ mer_counting#args.->out_counter_len_argcxx . . $ count_args#out_counter_len_arg., arycxx . . $ mer_counting#ary.);
167 _dumper->set_one_filecxx . . $ jellyfish/sorted_dumper#set_one_file(b45ddcbc8423892c).(argscxx . . $ mer_counting#args.->O_flagcxx . . $ count_args#O_flag.);
168 if(argscxx . . $ mer_counting#args.->lower_count_givencxx . . $ count_args#lower_count_given.)
169 _dumper->set_lower_countcxx . . $ jellyfish/sorted_dumper#set_lower_count(2c44cd906ae4e829).(argscxx . . $ mer_counting#args.->lower_count_argcxx . . $ count_args#lower_count_arg.);
170 if(argscxx . . $ mer_counting#args.->upper_count_givencxx . . $ count_args#upper_count_given.)
171 _dumper->set_upper_countcxx . . $ jellyfish/sorted_dumper#set_upper_count(2c44cd906ae4e829).(argscxx . . $ mer_counting#args.->upper_count_argcxx . . $ count_args#upper_count_arg.);
172 dumpercxx . . $ mer_counting#dumper. = _dumper;
173 }
174 }
175 hashcxx . . $ mer_counting#hash.->set_dumpercxx . . $ jellyfish/hash#set_dumper(3f9e1fcd3f2131d5).(dumpercxx . . $ mer_counting#dumper.);
176 parsercxx . . $ mer_counting#parser.->set_canonicalcxx . . $ jellyfish/parse_dna#set_canonical(b45ddcbc8423892c).(argscxx . . $ mer_counting#args.->both_strands_flagcxx . . $ count_args#both_strands_flag.);
177 }
178 };
179
180 class mer_counting_qual_fasta_hashcxx . . $ mer_counting_qual_fasta_hash# : public mer_countingcxx . . $ mer_counting#<jellyfishcxx . . $ jellyfish/::parse_qual_dnacxx . . $ jellyfish/parse_qual_dna#, inv_hash_tcxx . . $ inv_hash_t#> {
181 public:
182 mer_counting_qual_fasta_hashcxx . . $ mer_counting_qual_fasta_hash#mer_counting_qual_fasta_hash(25ae2d073e50eb45).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> &files,
183 count_argscxx . . $ count_args# &_args) :
184 mer_countingcxx . . $ mer_counting#<jellyfishcxx . . $ jellyfish/::parse_qual_dnacxx . . $ jellyfish/parse_qual_dna#, inv_hash_tcxx . . $ inv_hash_t#>(_args)
185 {
186 parsercxx . . $ mer_counting#parser. = new jellyfishcxx . . $ jellyfish/::parse_qual_dnacxx . . $ jellyfish/parse_qual_dna#(files,
187 argscxx . . $ mer_counting#args.->mer_len_argcxx . . $ count_args#mer_len_arg., argscxx . . $ mer_counting#args.->buffers_argcxx . . $ count_args#buffers_arg.,
188 argscxx . . $ mer_counting#args.->buffer_size_argcxx . . $ count_args#buffer_size_arg., argscxx . . $ mer_counting#args.->quality_start_argcxx . . $ count_args#quality_start_arg.,
189 argscxx . . $ mer_counting#args.->min_quality_argcxx . . $ count_args#min_quality_arg.);
190 arycxx . . $ mer_counting#ary. = new inv_hash_tcxx . . $ inv_hash_t#::storage_tcxx . . $ jellyfish/hash#storage_t#(argscxx . . $ mer_counting#args.->size_argcxx . . $ count_args#size_arg., 2*argscxx . . $ mer_counting#args.->mer_len_argcxx . . $ count_args#mer_len_arg.,
191 argscxx . . $ mer_counting#args.->counter_len_argcxx . . $ count_args#counter_len_arg.,
192 argscxx . . $ mer_counting#args.->reprobes_argcxx . . $ count_args#reprobes_arg.,
193 jellyfishcxx . . $ jellyfish/::quadratic_reprobescxx . . $ jellyfish/quadratic_reprobes.);
194 if(argscxx . . $ mer_counting#args.->matrix_givencxx . . $ count_args#matrix_given.) {
195 stdcxx . . $ std/::ifstreamcxx . . $ std/ifstream# fdcxx . . $ std/basic_ifstream#basic_ifstream(49f6e7a06ebc5aa8).;
196 fd.exceptionscxx . . $ std/basic_ios#exceptions(3e5fb2eb616d497d).(stdcxx . . $ std/::ifstreamcxx . . $ std/ifstream#::eofbitcxx . . $ std/ios_base#eofbit.|cxx . . $ std/`operator|`(c5b5c7d100a244bc).stdcxx . . $ std/::ifstreamcxx . . $ std/ifstream#::failbitcxx . . $ std/ios_base#failbit.|cxx . . $ std/`operator|`(c5b5c7d100a244bc).stdcxx . . $ std/::ifstreamcxx . . $ std/ifstream#::badbitcxx . . $ std/ios_base#badbit.);
197 fd.opencxx . . $ std/basic_ifstream#open(b8cd37071ce335df).(argscxx . . $ mer_counting#args.->matrix_argcxx . . $ count_args#matrix_arg..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).());
198 SquareBinaryMatrixcxx . . $ SquareBinaryMatrix# mcxx . . $ SquareBinaryMatrix#SquareBinaryMatrix(6a35a7fc14119650).(&fd);
199 fd.closecxx . . $ std/basic_ifstream#close(49f6e7a06ebc5aa8).();
200 arycxx . . $ mer_counting#ary.->set_matrixcxx . . $ jellyfish/invertible_hash/array#set_matrix(fcc8cfd4906a90f5).(m);
201 }
202 hashcxx . . $ mer_counting#hash. = new inv_hash_tcxx . . $ inv_hash_t#(arycxx . . $ mer_counting#ary.);
203
204 if(argscxx . . $ mer_counting#args.->no_write_flagcxx . . $ count_args#no_write_flag.) {
205 dumpercxx . . $ mer_counting#dumper. = new jellyfishcxx . . $ jellyfish/::noop_dumpercxx . . $ jellyfish/noop_dumper#();
206 } else {
207 if(argscxx . . $ mer_counting#args.->raw_flagcxx . . $ count_args#raw_flag.) {
208 dumpercxx . . $ mer_counting#dumper. = new raw_inv_hash_dumper_tcxx . . $ raw_inv_hash_dumper_t#((uint_tcxx . . $ uint_t#)4, argscxx . . $ mer_counting#args.->output_argcxx . . $ count_args#output_arg..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(),
209 argscxx . . $ mer_counting#args.->out_buffer_size_argcxx . . $ count_args#out_buffer_size_arg., arycxx . . $ mer_counting#ary.);
210 } else {
211 inv_hash_dumper_tcxx . . $ inv_hash_dumper_t# *_dumper =
212 new inv_hash_dumper_tcxx . . $ inv_hash_dumper_t#(argscxx . . $ mer_counting#args.->threads_argcxx . . $ count_args#threads_arg., argscxx . . $ mer_counting#args.->output_argcxx . . $ count_args#output_arg..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(),
213 argscxx . . $ mer_counting#args.->out_buffer_size_argcxx . . $ count_args#out_buffer_size_arg.,
214 8*argscxx . . $ mer_counting#args.->out_counter_len_argcxx . . $ count_args#out_counter_len_arg., arycxx . . $ mer_counting#ary.);
215 _dumper->set_one_filecxx . . $ jellyfish/sorted_dumper#set_one_file(b45ddcbc8423892c).(argscxx . . $ mer_counting#args.->O_flagcxx . . $ count_args#O_flag.);
216 if(argscxx . . $ mer_counting#args.->lower_count_givencxx . . $ count_args#lower_count_given.)
217 _dumper->set_lower_countcxx . . $ jellyfish/sorted_dumper#set_lower_count(2c44cd906ae4e829).(argscxx . . $ mer_counting#args.->lower_count_argcxx . . $ count_args#lower_count_arg.);
218 if(argscxx . . $ mer_counting#args.->upper_count_givencxx . . $ count_args#upper_count_given.)
219 _dumper->set_upper_countcxx . . $ jellyfish/sorted_dumper#set_upper_count(2c44cd906ae4e829).(argscxx . . $ mer_counting#args.->upper_count_argcxx . . $ count_args#upper_count_arg.);
220 dumpercxx . . $ mer_counting#dumper. = _dumper;
221 }
222 }
223 hashcxx . . $ mer_counting#hash.->set_dumpercxx . . $ jellyfish/hash#set_dumper(3f9e1fcd3f2131d5).(dumpercxx . . $ mer_counting#dumper.);
224 parsercxx . . $ mer_counting#parser.->set_canonicalcxx . . $ jellyfish/parse_qual_dna#set_canonical(b45ddcbc8423892c).(argscxx . . $ mer_counting#args.->both_strands_flagcxx . . $ count_args#both_strands_flag.);
225 }
226 };
227
228
229 class mer_counting_fasta_directcxx . . $ mer_counting_fasta_direct# : public mer_countingcxx . . $ mer_counting#<jellyfishcxx . . $ jellyfish/::parse_dnacxx . . $ jellyfish/parse_dna#, direct_index_tcxx . . $ direct_index_t#> {
230 public:
231 mer_counting_fasta_directcxx . . $ mer_counting_fasta_direct#mer_counting_fasta_direct(25ae2d073e50eb45).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> &files,
232 count_argscxx . . $ count_args# &_args) :
233 mer_countingcxx . . $ mer_counting#<jellyfishcxx . . $ jellyfish/::parse_dnacxx . . $ jellyfish/parse_dna#, direct_index_tcxx . . $ direct_index_t#>(_args)
234 {
235 parsercxx . . $ mer_counting#parser. = new jellyfishcxx . . $ jellyfish/::parse_dnacxx . . $ jellyfish/parse_dna#(files.begincxx . . $ std/vector#begin(d1e1699016b9d7e6).(), files.endcxx . . $ std/vector#end(d1e1699016b9d7e6).(),
236 argscxx . . $ mer_counting#args.->mer_len_argcxx . . $ count_args#mer_len_arg., argscxx . . $ mer_counting#args.->buffers_argcxx . . $ count_args#buffers_arg.,
237 argscxx . . $ mer_counting#args.->buffer_size_argcxx . . $ count_args#buffer_size_arg.);
238 arycxx . . $ mer_counting#ary. = new direct_index_tcxx . . $ direct_index_t#::storage_tcxx . . $ jellyfish/hash#storage_t#(2 * argscxx . . $ mer_counting#args.->mer_len_argcxx . . $ count_args#mer_len_arg.);
239 hashcxx . . $ mer_counting#hash. = new direct_index_tcxx . . $ direct_index_t#(arycxx . . $ mer_counting#ary.);
240 if(argscxx . . $ mer_counting#args.->no_write_flagcxx . . $ count_args#no_write_flag.) {
241 dumpercxx . . $ mer_counting#dumper. = new jellyfishcxx . . $ jellyfish/::noop_dumpercxx . . $ jellyfish/noop_dumper#();
242 } else {
243 if(argscxx . . $ mer_counting#args.->raw_flagcxx . . $ count_args#raw_flag.)
244 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Switch --raw not (yet) supported with direct indexing. Ignoring." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
245 direct_index_dumper_tcxx . . $ direct_index_dumper_t# *_dumper =
246 new direct_index_dumper_tcxx . . $ direct_index_dumper_t#(argscxx . . $ mer_counting#args.->threads_argcxx . . $ count_args#threads_arg., argscxx . . $ mer_counting#args.->output_argcxx . . $ count_args#output_arg..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(),
247 argscxx . . $ mer_counting#args.->out_buffer_size_argcxx . . $ count_args#out_buffer_size_arg.,
248 8*argscxx . . $ mer_counting#args.->out_counter_len_argcxx . . $ count_args#out_counter_len_arg.,
249 arycxx . . $ mer_counting#ary.);
250 _dumper->set_one_filecxx . . $ jellyfish/direct_sorted_dumper#set_one_file(b45ddcbc8423892c).(argscxx . . $ mer_counting#args.->O_flagcxx . . $ count_args#O_flag.);
251 if(argscxx . . $ mer_counting#args.->lower_count_givencxx . . $ count_args#lower_count_given.)
252 _dumper->set_lower_countcxx . . $ jellyfish/direct_sorted_dumper#set_lower_count(2c44cd906ae4e829).(argscxx . . $ mer_counting#args.->lower_count_argcxx . . $ count_args#lower_count_arg.);
253 if(argscxx . . $ mer_counting#args.->upper_count_givencxx . . $ count_args#upper_count_given.)
254 _dumper->set_upper_countcxx . . $ jellyfish/direct_sorted_dumper#set_upper_count(2c44cd906ae4e829).(argscxx . . $ mer_counting#args.->upper_count_argcxx . . $ count_args#upper_count_arg.);
255 dumpercxx . . $ mer_counting#dumper. = _dumper;
256 }
257 hashcxx . . $ mer_counting#hash.->set_dumpercxx . . $ jellyfish/hash#set_dumper(3f9e1fcd3f2131d5).(dumpercxx . . $ mer_counting#dumper.);
258 parsercxx . . $ mer_counting#parser.->set_canonicalcxx . . $ jellyfish/parse_dna#set_canonical(b45ddcbc8423892c).(argscxx . . $ mer_counting#args.->both_strands_flagcxx . . $ count_args#both_strands_flag.);
259 }
260 };
261
262 class mer_counting_qual_fasta_directcxx . . $ mer_counting_qual_fasta_direct# : public mer_countingcxx . . $ mer_counting#<jellyfishcxx . . $ jellyfish/::parse_qual_dnacxx . . $ jellyfish/parse_qual_dna#, direct_index_tcxx . . $ direct_index_t#> {
263 public:
264 mer_counting_qual_fasta_directcxx . . $ mer_counting_qual_fasta_direct#mer_counting_qual_fasta_direct(25ae2d073e50eb45).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *> &files,
265 count_argscxx . . $ count_args# &_args) :
266 mer_countingcxx . . $ mer_counting#<jellyfishcxx . . $ jellyfish/::parse_qual_dnacxx . . $ jellyfish/parse_qual_dna#, direct_index_tcxx . . $ direct_index_t#>(_args)
267 {
268 parsercxx . . $ mer_counting#parser. = new jellyfishcxx . . $ jellyfish/::parse_qual_dnacxx . . $ jellyfish/parse_qual_dna#(files,
269 argscxx . . $ mer_counting#args.->mer_len_argcxx . . $ count_args#mer_len_arg., argscxx . . $ mer_counting#args.->buffers_argcxx . . $ count_args#buffers_arg.,
270 argscxx . . $ mer_counting#args.->buffer_size_argcxx . . $ count_args#buffer_size_arg., argscxx . . $ mer_counting#args.->quality_start_argcxx . . $ count_args#quality_start_arg.,
271 argscxx . . $ mer_counting#args.->min_quality_argcxx . . $ count_args#min_quality_arg.);
272 arycxx . . $ mer_counting#ary. = new direct_index_tcxx . . $ direct_index_t#::storage_tcxx . . $ jellyfish/hash#storage_t#(2 * argscxx . . $ mer_counting#args.->mer_len_argcxx . . $ count_args#mer_len_arg.);
273 hashcxx . . $ mer_counting#hash. = new direct_index_tcxx . . $ direct_index_t#(arycxx . . $ mer_counting#ary.);
274 if(argscxx . . $ mer_counting#args.->no_write_flagcxx . . $ count_args#no_write_flag.) {
275 dumpercxx . . $ mer_counting#dumper. = new jellyfishcxx . . $ jellyfish/::noop_dumpercxx . . $ jellyfish/noop_dumper#();
276 } else {
277 if(argscxx . . $ mer_counting#args.->raw_flagcxx . . $ count_args#raw_flag.)
278 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Switch --raw not (yet) supported with direct indexing. Ignoring." <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
279 direct_index_dumper_tcxx . . $ direct_index_dumper_t# *_dumper =
280 new direct_index_dumper_tcxx . . $ direct_index_dumper_t#(argscxx . . $ mer_counting#args.->threads_argcxx . . $ count_args#threads_arg., argscxx . . $ mer_counting#args.->output_argcxx . . $ count_args#output_arg..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(),
281 argscxx . . $ mer_counting#args.->out_buffer_size_argcxx . . $ count_args#out_buffer_size_arg.,
282 8*argscxx . . $ mer_counting#args.->out_counter_len_argcxx . . $ count_args#out_counter_len_arg.,
283 arycxx . . $ mer_counting#ary.);
284 _dumper->set_one_filecxx . . $ jellyfish/direct_sorted_dumper#set_one_file(b45ddcbc8423892c).(argscxx . . $ mer_counting#args.->O_flagcxx . . $ count_args#O_flag.);
285 if(argscxx . . $ mer_counting#args.->lower_count_givencxx . . $ count_args#lower_count_given.)
286 _dumper->set_lower_countcxx . . $ jellyfish/direct_sorted_dumper#set_lower_count(2c44cd906ae4e829).(argscxx . . $ mer_counting#args.->lower_count_argcxx . . $ count_args#lower_count_arg.);
287 if(argscxx . . $ mer_counting#args.->upper_count_givencxx . . $ count_args#upper_count_given.)
288 _dumper->set_upper_countcxx . . $ jellyfish/direct_sorted_dumper#set_upper_count(2c44cd906ae4e829).(argscxx . . $ mer_counting#args.->upper_count_argcxx . . $ count_args#upper_count_arg.);
289 dumpercxx . . $ mer_counting#dumper. = _dumper;
290 }
291 hashcxx . . $ mer_counting#hash.->set_dumpercxx . . $ jellyfish/hash#set_dumper(3f9e1fcd3f2131d5).(dumpercxx . . $ mer_counting#dumper.);
292 parsercxx . . $ mer_counting#parser.->set_canonicalcxx . . $ jellyfish/parse_qual_dna#set_canonical(b45ddcbc8423892c).(argscxx . . $ mer_counting#args.->both_strands_flagcxx . . $ count_args#both_strands_flag.);
293 }
294 };
295
296 class mer_counting_quakecxx . . $ mer_counting_quake# : public mer_countingcxx . . $ mer_counting#<jellyfishcxx . . $ jellyfish/::parse_quakecxx . . $ jellyfish/parse_quake#, fastq_hash_tcxx . . $ fastq_hash_t#> {
297 public:
298 mer_counting_quakecxx . . $ mer_counting_quake#mer_counting_quake(a409a6877a06f552).(stdcxx . . $ std/::vectorcxx . . $ std/vector#<const char *>,
299 count_argscxx . . $ count_args# &_args) :
300 mer_countingcxx . . $ mer_counting#<jellyfishcxx . . $ jellyfish/::parse_quakecxx . . $ jellyfish/parse_quake#, fastq_hash_tcxx . . $ fastq_hash_t#>(_args)
301 {
302 parsercxx . . $ mer_counting#parser. = new jellyfishcxx . . $ jellyfish/::parse_quakecxx . . $ jellyfish/parse_quake#(argscxx . . $ mer_counting#args.->file_argcxx . . $ count_args#file_arg.,
303 argscxx . . $ mer_counting#args.->mer_len_argcxx . . $ count_args#mer_len_arg., argscxx . . $ mer_counting#args.->buffers_argcxx . . $ count_args#buffers_arg.,
304 argscxx . . $ mer_counting#args.->buffer_size_argcxx . . $ count_args#buffer_size_arg.,
305 argscxx . . $ mer_counting#args.->quality_start_argcxx . . $ count_args#quality_start_arg.);
306 arycxx . . $ mer_counting#ary. = new fastq_hash_tcxx . . $ fastq_hash_t#::storage_tcxx . . $ jellyfish/hash#storage_t#(argscxx . . $ mer_counting#args.->size_argcxx . . $ count_args#size_arg., 2*argscxx . . $ mer_counting#args.->mer_len_argcxx . . $ count_args#mer_len_arg.,
307 argscxx . . $ mer_counting#args.->reprobes_argcxx . . $ count_args#reprobes_arg.,
308 jellyfishcxx . . $ jellyfish/::quadratic_reprobescxx . . $ jellyfish/quadratic_reprobes.);
309 hashcxx . . $ mer_counting#hash. = new fastq_hash_tcxx . . $ fastq_hash_t#(arycxx . . $ mer_counting#ary.);
310 if(argscxx . . $ mer_counting#args.->no_write_flagcxx . . $ count_args#no_write_flag.) {
311 dumpercxx . . $ mer_counting#dumper. = new jellyfishcxx . . $ jellyfish/::noop_dumpercxx . . $ jellyfish/noop_dumper#();
312 } else {
313 dumpercxx . . $ mer_counting#dumper. = new raw_fastq_dumper_tcxx . . $ raw_fastq_dumper_t#(argscxx . . $ mer_counting#args.->threads_argcxx . . $ count_args#threads_arg., argscxx . . $ mer_counting#args.->output_argcxx . . $ count_args#output_arg..c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(),
314 argscxx . . $ mer_counting#args.->out_buffer_size_argcxx . . $ count_args#out_buffer_size_arg.,
315 arycxx . . $ mer_counting#ary.);
316 }
317 hashcxx . . $ mer_counting#hash.->set_dumpercxx . . $ jellyfish/hash#set_dumper(3f9e1fcd3f2131d5).(dumpercxx . . $ mer_counting#dumper.);
318 parsercxx . . $ mer_counting#parser.->set_canonicalcxx . . $ jellyfish/parse_quake#set_canonical(b45ddcbc8423892c).(argscxx . . $ mer_counting#args.->both_strands_flagcxx . . $ count_args#both_strands_flag.);
319 }
320 };
321
322 int count_maincxx . . $ count_main(afcd3168fc1188a4).(int argc, char *argv[])
323 {
324 count_argscxx . . $ count_args# argscxx . . $ count_args#count_args(c759356ac01a31e7).(argc, argv);
325
326 if(args.mer_len_argcxx . . $ count_args#mer_len_arg. < 2 || args.mer_len_argcxx . . $ count_args#mer_len_arg. > 31)
327 diecxx . . $ `jellyfish/err.hpp:138:9`! <<cxx . . $ err/die_t#`operator<<`(f22e16ce67cbf691). "Invalid mer length '" <<cxx . . $ err/die_t#`operator<<`(f22e16ce67cbf691). args.mer_len_argcxx . . $ count_args#mer_len_arg.
328 <<cxx . . $ err/die_t#`operator<<`(f22e16ce67cbf691). "'. It must be in [2, 31].";
329
330 Timecxx . . $ Time# startcxx . . $ Time#Time(b45ddcbc8423892c).;
331 mer_counting_basecxx . . $ mer_counting_base# *counter;
332 if(!args.buffers_givencxx . . $ count_args#buffers_given.)
333 args.buffers_argcxx . . $ count_args#buffers_arg. = 20 * args.threads_argcxx . . $ count_args#threads_arg.;
334
335 if(args.quake_flagcxx . . $ count_args#quake_flag.) {
336 counter = new mer_counting_quakecxx . . $ mer_counting_quake#(argscxx . . $ std/vector#vector(a1201200cf0efa42)..file_argcxx . . $ count_args#file_arg., args);
337 } else if(ceilLog2cxx . . $ ceilLog2(11815c24b85c60f1).((unsigned long)args.size_argcxx . . $ count_args#size_arg.) > 2 * (unsigned long)args.mer_len_argcxx . . $ count_args#mer_len_arg.) {
338 if(args.min_quality_givencxx . . $ count_args#min_quality_given.)
339 counter = new mer_counting_qual_fasta_directcxx . . $ mer_counting_qual_fasta_direct#(args.file_argcxx . . $ count_args#file_arg., args);
340 else
341 counter = new mer_counting_fasta_directcxx . . $ mer_counting_fasta_direct#(args.file_argcxx . . $ count_args#file_arg., args);
342 } else if(args.min_quality_givencxx . . $ count_args#min_quality_given.) {
343 counter = new mer_counting_qual_fasta_hashcxx . . $ mer_counting_qual_fasta_hash#(args.file_argcxx . . $ count_args#file_arg., args);
344 } else {
345 counter = new mer_counting_fasta_hashcxx . . $ mer_counting_fasta_hash#(args.file_argcxx . . $ count_args#file_arg., args);
346 }
347 Timecxx . . $ Time# after_initcxx . . $ Time#Time(b45ddcbc8423892c).;
348 counter->countcxx . . $ mer_counting_base#count(49f6e7a06ebc5aa8).();
349 Timecxx . . $ Time# all_donecxx . . $ Time#Time(b45ddcbc8423892c).;
350
351 if(args.timing_givencxx . . $ count_args#timing_given.) {
352 stdcxx . . $ std/::ofstreamcxx . . $ std/ofstream# timing_fdcxx . . $ std/basic_ofstream#basic_ofstream(b8cd37071ce335df).(args.timing_argcxx . . $ count_args#timing_arg.);
353 if(!timing_fd.goodcxx . . $ std/basic_ios#good(50ce9a9e25b4a850).()) {
354 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Can't open timing file '" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). args.timing_argcxx . . $ count_args#timing_arg. <<cxx . . $ err/`operator<<`(6895dca1673efed1). errcxx . . $ err/::nocxx . . $ err/no.
355 <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
356 } else {
357 Timecxx . . $ Time# writing = counter->get_writing_timecxx . . $ mer_counting_base#get_writing_time(3a9c327c3081e598).();
358 Timecxx . . $ Time# counting = (all_done -cxx . . $ Time#operator-(28cdadeed157653). after_init) -cxx . . $ Time#operator-(28cdadeed157653). writing;
359 timing_fd <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Init " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). (after_init -cxx . . $ Time#operator-(28cdadeed157653). start).strcxx . . $ Time#str(219584694fe2b248).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"
360 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Counting " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). counting.strcxx . . $ Time#str(219584694fe2b248).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"
361 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Writing " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). writing.strcxx . . $ Time#str(219584694fe2b248).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n";
362 timing_fd.closecxx . . $ std/basic_ofstream#close(49f6e7a06ebc5aa8).();
363 }
364 }
365
366 if(args.stats_givencxx . . $ count_args#stats_given.) {
367 stdcxx . . $ std/::ofstreamcxx . . $ std/ofstream# stats_fdcxx . . $ std/basic_ofstream#basic_ofstream(b8cd37071ce335df).(args.stats_argcxx . . $ count_args#stats_arg.);
368 if(!stats_fd.goodcxx . . $ std/basic_ios#good(50ce9a9e25b4a850).()) {
369 stdcxx . . $ std/::cerrcxx . . $ std/cerr. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Can't open stats file '" <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). args.stats_argcxx . . $ count_args#stats_arg. <<cxx . . $ err/`operator<<`(6895dca1673efed1). errcxx . . $ err/::nocxx . . $ err/no.
370 <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
371 } else {
372 stats_fd <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Distinct: " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). counter->get_distinctcxx . . $ mer_counting_base#get_distinct(fe4d2d262d4164a8).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"
373 <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Total: " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). counter->get_totalcxx . . $ mer_counting_base#get_total(fe4d2d262d4164a8).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).;
374 stats_fd.closecxx . . $ std/basic_ofstream#close(49f6e7a06ebc5aa8).();
375 }
376 }
377
378 return 0;
379 }