-
Notifications
You must be signed in to change notification settings - Fork 3
/
cmd_make_bf.cc
767 lines (624 loc) · 21.2 KB
/
cmd_make_bf.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
// cmd_make_bf.cc-- convert a sequence file to a bloom filter
#include <string>
#include <cstdlib>
#include <cstdint>
#include <iostream>
#include <vector>
#include "utilities.h"
#include "hash.h"
#include "jelly_kmers.h"
#include "bloom_filter.h"
#include "bloom_filter_file.h"
#include "support.h"
#include "commands.h"
#include "cmd_make_bf.h"
using std::string;
using std::vector;
using std::cout;
using std::cerr;
using std::endl;
#define u32 std::uint32_t
#define u64 std::uint64_t
void MakeBFCommand::short_description
(std::ostream& s)
{
s << commandName << "-- convert a sequence file to a bloom filter" << endl;
}
void MakeBFCommand::usage
(std::ostream& s,
const string& message)
{
if (!message.empty())
{
s << message << endl;
s << endl;
}
short_description(s);
s << "usage: " << commandName << " <filename> [<filename>..] [options]" << endl;
// 123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789
s << " <filename> (cumulative) a sequence file, e.g. fasta, fastq, or kmers" << endl;
s << " (one bloom filter is created, for the union of the" << endl;
s << " sequence files)" << endl;
s << " --kmersin input files are kmers" << endl;
s << " (by default input files are expected to be fasta or fastq)" << endl;
s << " --out=<filename> name for bloom filter file" << endl;
s << " (by default this is derived from first sequence filename)" << endl;
s << " --list=<filename> file containing a list of bloom filters to create; this is" << endl;
s << " used in place of the <filename>s on the command line; the" << endl;
s << " file format is described below" << endl;
s << " --asper=<filename> name of an existing bloom filter file to extract settings" << endl;
s << " from; that file's --k, --hashes, --seed, --modulus," << endl;
s << " --bits and compression type will be used if they are not" << endl;
s << " otherwise specified on the command line" << endl;
s << " --k=<N> kmer size (number of nucleotides in a kmer)" << endl;
s << " (default is " << defaultKmerSize << ")" << endl;
s << " --min=<N> kmers occuring fewer than N times are left out of the" << endl;
s << " bloom filter; this does not apply when --kmersin is used" << endl;
s << " (default is " << defaultMinAbundance << ")" << endl;
s << " --threads=<N> number of threads to use during kmerization" << endl;
s << " (default is " << defaultNumThreads << ")" << endl;
s << " --hashes=<N> how many hash functions to use for the filter" << endl;
s << " (default is " << defaultNumHashes << ")" << endl;
s << " --seed=<number> the hash function's 56-bit seed" << endl;
s << " --seed=<number>,<number> both the hash function seeds; the second seed is" << endl;
s << " only used if more than one hash function is being used" << endl;
s << " (by default the second seed is the first seed plus 1)" << endl;
s << " --modulus=<M> set the hash modulus, if larger than the number of bits" << endl;
s << " (by default this is the same as the number of bits)" << endl;
s << " --bits=<N> number of bits in the bloom filter" << endl;
s << " (default is " << defaultNumBits << ")" << endl;
s << " --uncompressed make the filter with uncompressed bit vector(s)" << endl;
s << " (this is the default)" << endl;
s << " --rrr make the filter with RRR-compressed bit vector(s)" << endl;
s << " --roar make the filter with roar-compressed bit vector(s)" << endl;
s << " --stats[=<filename>] write bloom filter stats to a text file" << endl;
s << " (if no filename is given this is derived from the bloom" << endl;
s << " filter filename)" << endl;
s << endl;
s << "When --list is used, each line of the file corresponds to a bloom filter. The" << endl;
s << "format of each line is" << endl;
s << " <filename> [<filename>..] [--kmersin] [--out=<filename>]" << endl;
s << "with meaning the same as on the command line. No other options (e.g. --k or" << endl;
s << "--bits) are allowed in the file. These are specified on the command line and" << endl;
s << "will affect all the bloom filters." << endl;
s << endl;
s << "When --kmersin is used, each line of the sequence input files is a single kmer," << endl;
s << "as the first field in the line. Any additional fields on the line are ignored." << endl;
s << "For example, with --k=20 this might be" << endl;
s << " ATGACCAGATATGTACTTGC" << endl;
s << " TCTGCGAACCCAGACTTGGT" << endl;
s << " CAAGACCTATGAGTAGAACG" << endl;
s << " ..." << endl;
s << "Every kmer in the file(s) is added to the filter. No counting is performed," << endl;
s << "and --min is not allowed." << endl;
}
void MakeBFCommand::debug_help
(std::ostream& s)
{
s << "--debug= options" << endl;
s << " settings" << endl;
s << " add" << endl;
s << " contains" << endl;
s << " kmers" << endl;
s << " strings" << endl;
s << " v1file" << endl;
}
void MakeBFCommand::parse
(int _argc,
char** _argv)
{
int argc;
char** argv;
// defaults
listFilename = "";
inputIsKmers = false;
bfFilename = "";
kmerSize = defaultKmerSize; bool kmerSizeSet = false;
minAbundance = defaultMinAbundance; minAbundanceSet = false;
numThreads = defaultNumThreads;
numHashes = defaultNumHashes; bool numHashesSet = false;
hashSeed1 = 0; bool hashSeed1Set = false;
hashSeed2 = 0; bool hashSeed2Set = false;
numBits = defaultNumBits; bool numBitsSet = false;
hashModulus = 0; bool hashModulusSet = false;
compressor = bvcomp_uncompressed; bool compressorSet = false;
outputStats = false;
statsFilename = "";
#ifdef useJellyHash
hashSeed1 = JellyHashSeed;
#endif
// skip command name
argv = _argv+1; argc = _argc - 1;
if (argc <= 0) chastise ();
//////////
// scan arguments
//////////
for (int argIx=0 ; argIx<argc ; argIx++)
{
string arg = argv[argIx];
string argVal;
if (arg.empty()) continue;
string::size_type argValIx = arg.find('=');
if (argValIx == string::npos) argVal = "";
else argVal = arg.substr(argValIx+1);
// --help, etc.
if ((arg == "--help")
|| (arg == "-help")
|| (arg == "--h")
|| (arg == "-h")
|| (arg == "?")
|| (arg == "-?")
|| (arg == "--?"))
{ usage (cerr); std::exit (EXIT_SUCCESS); }
if ((arg == "--help=debug")
|| (arg == "--help:debug")
|| (arg == "?debug"))
{ debug_help(cerr); std::exit (EXIT_SUCCESS); }
// --kmersin
if ((arg == "--kmersin")
|| (arg == "--askmers="))
{ inputIsKmers = true; continue; }
// --out=<filename>
if ((is_prefix_of (arg, "--out="))
|| (is_prefix_of (arg, "--output=")))
{ bfFilename = argVal; continue; }
// --list=<filename>
if (is_prefix_of (arg, "--list="))
{ listFilename = argVal; continue; }
// --asper=<filename>
if (is_prefix_of (arg, "--asper="))
{ asPerFilename = argVal; continue; }
// --k=<N>
if ((is_prefix_of (arg, "K="))
|| (is_prefix_of (arg, "--K="))
|| (is_prefix_of (arg, "k="))
|| (is_prefix_of (arg, "--k="))
|| (is_prefix_of (arg, "--kmer="))
|| (is_prefix_of (arg, "--kmersize=")))
{
kmerSize = string_to_u32(argVal);
kmerSizeSet = true;
continue;
}
// --min=<N>
if ((is_prefix_of (arg, "--min="))
|| (is_prefix_of (arg, "--abundance=")))
{
minAbundance = string_to_u32(argVal);
if (minAbundance < 1) minAbundance = 1;
minAbundanceSet = (minAbundance > 1);
continue;
}
// --threads=<N>
if ((is_prefix_of (arg, "--threads="))
|| (is_prefix_of (arg, "T="))
|| (is_prefix_of (arg, "--T=")))
{
numThreads = string_to_u32(argVal);
if (numThreads == 0)
chastise ("(in \"" + arg + "\") number of threads cannot be zero");
continue;
}
// --hashes=<N>
if ((is_prefix_of (arg, "--hashes="))
|| (is_prefix_of (arg, "H="))
|| (is_prefix_of (arg, "--H=")))
{
numHashes = string_to_u32(argVal);
numHashesSet = true;
continue;
}
// --seed=<number> or --seed=<number>,<number>
if ((is_prefix_of (arg, "--seed="))
|| (is_prefix_of (arg, "S="))
|| (is_prefix_of (arg, "--S=")))
{
string::size_type commaIx = argVal.find(',');
if (commaIx == string::npos)
{
hashSeed1 = string_to_u64 (argVal);
hashSeed1Set = true;
}
else
{
hashSeed1 = string_to_u64 (argVal.substr(0,commaIx));
hashSeed2 = string_to_u64 (argVal.substr(commaIx+1));
hashSeed1Set = hashSeed2Set = true;
}
continue;
}
// --modulus=<M>
if ((is_prefix_of (arg, "--modulus="))
|| (is_prefix_of (arg, "M="))
|| (is_prefix_of (arg, "--M=")))
{
hashModulus = string_to_unitized_u64(argVal);
hashModulusSet = true;
continue;
}
// --bits=<N>
if ((is_prefix_of (arg, "--bits="))
|| (is_prefix_of (arg, "B="))
|| (is_prefix_of (arg, "--B=")))
{
numBits = string_to_unitized_u64(argVal);
numBitsSet = true;
continue;
}
// bit vector type
if (arg == "--uncompressed")
{
compressor = bvcomp_uncompressed;
compressorSet = true;
continue;
}
if ((arg == "--rrr")
|| (arg == "--RRR"))
{
compressor = bvcomp_rrr;
compressorSet = true;
continue;
}
if ((arg == "--roar")
|| (arg == "--roaring"))
{
compressor = bvcomp_roar;
compressorSet = true;
continue;
}
// (unadvertised) special bit vector types
if ((arg == "--zeros")
|| (arg == "--allzeros")
|| (arg == "--all_zeros")
|| (arg == "--all-zeros"))
{
compressor = bvcomp_zeros;
compressorSet = true;
continue;
}
if ((arg == "--ones")
|| (arg == "--allones")
|| (arg == "--all_ones")
|| (arg == "--all-ones"))
{
compressor = bvcomp_ones;
compressorSet = true;
continue;
}
if (arg == "--uncrrr")
{
compressor = bvcomp_unc_rrr;
compressorSet = true;
continue;
}
if (arg == "--uncroar")
{
compressor = bvcomp_unc_roar;
compressorSet = true;
continue;
}
// --stats[=<filename>]
if (arg == "--stats")
{ outputStats = true; continue; }
if ((is_prefix_of (arg, "--stats=")))
{
outputStats = true;
statsFilename = argVal;
continue;
}
// (unadvertised) debug options
if (arg == "--debug")
{ debug.insert ("debug"); continue; }
if (is_prefix_of (arg, "--debug="))
{
for (const auto& field : parse_comma_list(argVal))
debug.insert(to_lower(field));
continue;
}
// unrecognized --option
if (is_prefix_of (arg, "--"))
chastise ("unrecognized option: \"" + arg + "\"");
// <filename>
seqFilenames.emplace_back(strip_blank_ends(arg));
}
// if an "as per" file was given, modify settings that weren't otherwise
// specified
if (not asPerFilename.empty())
{
BloomFilter bf(asPerFilename);
bf.load();
if (!kmerSizeSet) { kmerSize = bf.kmerSize; kmerSizeSet = true; }
if (!numHashesSet) { numHashes = bf.numHashes; numHashesSet = true; }
if (!hashSeed1Set) { hashSeed1 = bf.hashSeed1; hashSeed1Set = true; }
if (!hashSeed2Set) { hashSeed2 = bf.hashSeed2; hashSeed2Set = true; }
if (!hashModulusSet) { hashModulus = bf.hashModulus; hashModulusSet = true; }
if (!numBitsSet) { numBits = bf.numBits; numBitsSet = true; }
// øøø don't access bvs like this
if (!compressorSet) { compressor = bf.bvs[0]->compressor(); compressorSet = true; }
}
// sanity checks
if ((compressor == bvcomp_zeros)
|| (compressor == bvcomp_ones))
{
if (not listFilename.empty())
chastise ("cannot use --list with --zeros or --ones");
if (not seqFilenames.empty())
chastise ("cannot use sequence files with --zeros or --ones");
if (bfFilename.empty())
chastise ("--zeros or --ones requires --out");
}
else if (listFilename.empty())
{
if (seqFilenames.empty())
chastise ("at least one sequence filename is required");
}
else
{
if (not seqFilenames.empty())
chastise ("cannot use --list with sequence filenames (e.g. " + seqFilenames[0] + ") in the command");
if (not bfFilename.empty())
chastise ("cannot use --list with a filter filename (" + bfFilename + ") in the command");
if (not statsFilename.empty())
chastise ("cannot use --list with a stats filename (" + statsFilename + ") in the command");
}
if (kmerSize == 0)
chastise ("kmer size cannot be zero");
if (numHashes == 0)
chastise ("number of hash functions cannot be zero");
if (numBits < 2)
chastise ("number of bits must be at least 2");
if (numHashes == 1)
hashSeed2 = 0;
else if (not hashSeed2Set)
hashSeed2 = hashSeed1 + 1;
if (not hashModulusSet)
hashModulus = numBits;
if (hashModulus < numBits)
chastise ("hash modulus (" + std::to_string(hashModulus)+ ")"
+ " cannot be less than the number of bits"
+ " (" + std::to_string(numBits) + ")");
if ((inputIsKmers) and (minAbundanceSet))
chastise ("cannot use --kmersin with --min");
if (contains(debug,"settings"))
{
cerr << "kmerSize = " << kmerSize << endl;
cerr << "numHashes = " << numHashes << endl;
cerr << "hashSeed1 = " << hashSeed1 << endl;
cerr << "hashSeed2 = " << hashSeed2 << endl;
cerr << "hashModulus = " << hashModulus << endl;
cerr << "numBits = " << numBits << endl;
cerr << "compressor = " << compressor << endl;
}
return;
}
int MakeBFCommand::execute()
{
// if we're to make a single filter, do so
if (listFilename.empty())
{
if (inputIsKmers) make_bloom_filter_kmers ();
else make_bloom_filter_fasta ();
}
// otherwise, make a series of filters according to each line specified in
// a file
else
{
std::ifstream in (listFilename);
if (not in)
fatal ("error: failed to open \"" + listFilename + "\"");
string line;
int lineNum = 0;
while (std::getline (in, line))
{
lineNum++;
seqFilenames.clear();
inputIsKmers = false;
bfFilename = "";
vector<string> tokens = tokenize(line);
for (size_t argIx=0 ; argIx<tokens.size() ; argIx++)
{
string arg = tokens[argIx];
string argVal;
string::size_type argValIx = arg.find('=');
if (argValIx == string::npos) argVal = "";
else argVal = arg.substr(argValIx+1);
if ((arg == "--kmersin")
|| (arg == "--askmers="))
{
if (minAbundanceSet)
fatal ("cannot use --kmersin, with --min on the command line"
" (at line " + std::to_string(lineNum)
+ " in " + listFilename + ")");
inputIsKmers = true;
continue;
}
if ((is_prefix_of (arg, "--out="))
|| (is_prefix_of (arg, "--output=")))
{ bfFilename = argVal; continue; }
if (is_prefix_of (arg, "--"))
fatal ("unrecognized field: \"" + arg + "\""
+ " at line " + std::to_string(lineNum)
+ " in " + listFilename);
seqFilenames.emplace_back(strip_blank_ends(arg));
}
if (inputIsKmers) make_bloom_filter_kmers ();
else make_bloom_filter_fasta ();
}
in.close();
}
return EXIT_SUCCESS;
}
void MakeBFCommand::make_bloom_filter_fasta() // this also supports fastq
{
string bfOutFilename = build_output_filename();
// create the hash table, with jellyfish defaults
const u64 hashSize = 10*1000*1000;
const u32 numReprobes = 126;
const u32 counterLen = 7;
unsigned int savedKmerSize = jellyfish::mer_dna::k();
jellyfish::mer_dna::k(kmerSize);
mer_hash_type merHash (hashSize, kmerSize*2, counterLen, numThreads, numReprobes);
// count the kmers
// nota bene: MerCounter internally discards kmers containing any non-ACGT
// $$$ ERROR_CHECK need to trap exceptions from the jellyfish stuff
// $$$ ERROR_CHECK does jellyfish give us any indication if one of the sequence files doesn't exist?
MerCounter counter(numThreads, merHash, seqFilenames.begin(), seqFilenames.end());
counter.exec_join (numThreads);
// build the bloom filter
BloomFilter* bf = new BloomFilter(bfOutFilename, kmerSize,
numHashes, hashSeed1, hashSeed2,
numBits, hashModulus);
if (contains(debug,"add")) bf->dbgAdd = true;
if (contains(debug,"contains")) bf->dbgContains = true;
bf->new_bits (compressor);
const auto jfAry = merHash.ary();
const auto end = jfAry->end();
u64 kmersAdded = 0;
for (auto kmer=jfAry->begin() ; kmer!=end ; ++kmer)
{
auto& keyValuePair = *kmer;
if (keyValuePair.second >= minAbundance)
{
if (contains(debug,"kmers"))
cerr << keyValuePair.first << " " << keyValuePair.second << endl;
if (contains(debug,"strings"))
bf->add (keyValuePair.first.to_str());
else
bf->add ((u64*) keyValuePair.first.data());
kmersAdded++;
}
}
jellyfish::mer_dna::k(savedKmerSize); // restore jellyfish kmer size
if (not contains(debug,"v1file"))
{
bf->setSizeKnown = true;
bf->setSize = kmersAdded;
}
if ((compressor == bvcomp_unc_rrr)
|| (compressor == bvcomp_unc_roar))
{
BitVector* bv = bf->bvs[0];
bv->unfinished();
}
bf->reportSave = true;
bf->save();
delete bf;
// report stats to a file and/or the console
if ((outputStats) or (contains(debug,"fprate")))
report_stats(bfOutFilename,kmersAdded);
}
void MakeBFCommand::make_bloom_filter_kmers()
{
string bfOutFilename = build_output_filename();
// build the bloom filter
BloomFilter* bf = new BloomFilter(bfOutFilename, kmerSize,
numHashes, hashSeed1, hashSeed2,
numBits, hashModulus);
if (contains(debug,"add")) bf->dbgAdd = true;
if (contains(debug,"contains")) bf->dbgContains = true;
bf->new_bits (compressor);
u64 kmersAdded = 0;
for (const auto& kmersFilename : seqFilenames)
{
std::ifstream in (kmersFilename);
if (not in)
fatal ("error: failed to open \"" + kmersFilename + "\"");
string line, kmer;
int lineNum = 0;
while (std::getline (in, line))
{
lineNum++;
line = strip_blank_ends (line);
if (line.empty()) continue;
string::size_type whitespaceIx = line.find_first_of(" \t");
if (whitespaceIx == string::npos) kmer = line;
else kmer = line.substr(0,whitespaceIx);
if (kmer.length() != kmerSize)
fatal ("error: expected " + std::to_string(kmerSize) + "-mer"
+ " but encountered " + std::to_string(kmer.length()) + "-mer"
+ " (at line " + std::to_string(lineNum)
+ " in " + kmersFilename + ")");
string::size_type badIx = kmer.find_first_not_of("ACGTacgt");
if (badIx != string::npos) continue;
if (contains(debug,"kmers"))
cerr << kmer << endl;
bf->add (kmer);
kmersAdded++;
}
}
if (not contains(debug,"v1file"))
{
bf->setSizeKnown = true;
bf->setSize = kmersAdded;
}
if ((compressor == bvcomp_unc_rrr)
|| (compressor == bvcomp_unc_roar))
{
BitVector* bv = bf->bvs[0];
bv->unfinished();
}
bf->reportSave = true;
bf->save();
delete bf;
// report stats to a file and/or the console
if ((outputStats) or (contains(debug,"fprate")))
report_stats(bfOutFilename,kmersAdded);
}
void MakeBFCommand::report_stats(const string& bfOutFilename, u64 kmersAdded)
{
// (in earlier versions, this incorrectly used numBits instead of hashModulus)
double fpRate = BloomFilter::false_positive_rate(numHashes,hashModulus,kmersAdded);
if (outputStats)
{
string statsOutFilename = build_stats_filename(bfOutFilename);
cerr << "writing bloom filter stats to \"" << statsOutFilename << "\"" << endl;
std::ofstream statsF(statsOutFilename);
statsF << "#filename"
<< "\tnumHashes"
<< "\tnumBits"
<< "\tkmersAdded"
<< "\tbfFpRate"
<< endl;
statsF << bfOutFilename
<< "\t" << numHashes
<< "\t" << hashModulus // (in earlier versions, this was incorrectly numBits)
<< "\t" << kmersAdded
<< "\t" << fpRate
<< endl;
}
if (contains(debug,"fprate"))
{
cerr << bfOutFilename << " kmers inserted: " << kmersAdded << endl;
cerr << bfOutFilename << " estimated BF false positive rate: " << fpRate << endl;
}
}
string MakeBFCommand::build_output_filename()
{
string bfOutFilename = bfFilename;
if (bfOutFilename.empty())
{
string ext = "." + BitVector::compressor_to_string(compressor) + ".bf";
if (ext == ".uncompressed.bf") ext = ".bf";
string seqFilename = seqFilenames[0];
string::size_type dotIx = seqFilename.find_last_of(".");
if (dotIx == string::npos)
bfOutFilename = seqFilename + ext;
else
bfOutFilename = seqFilename.substr(0,dotIx) + ext;
}
return bfOutFilename;
}
string MakeBFCommand::build_stats_filename(const string& bfOutFilename)
{
string statsOutFilename = statsFilename;
if (statsOutFilename.empty())
{
string ext = ".stats";
string::size_type dotIx = bfOutFilename.find_last_of(".");
if (dotIx == string::npos)
statsOutFilename = bfOutFilename + ext;
else
statsOutFilename = bfOutFilename.substr(0,dotIx) + ext;
}
return statsOutFilename;
}