| 209 | } |
| 210 | |
| 211 | void |
| 212 | buildFilters( |
| 213 | const std::vector<std::string>& readFilepaths, |
| 214 | const int r, |
| 215 | const size_t bloomBytesTotal) |
| 216 | { |
| 217 | assert(bloomBytesTotal > 0); |
| 218 | try { |
| 219 | if (opt::verbose) { |
| 220 | std::cerr << "Building Bloom filter(s) for r value " << r << '\n'; |
| 221 | } |
| 222 | |
| 223 | delete g_vanillaBloom; |
| 224 | delete g_spacedSeedsBloom; |
| 225 | |
| 226 | size_t bloomBytesVanilla = size_t(bloomBytesTotal); |
| 227 | size_t bloomBytesSpacedSeeds = 0; |
| 228 | |
| 229 | if (opt::errorCorrection) { |
| 230 | double vanillaRatio = |
| 231 | VANILLA_TO_SEEDS_MEM_RATIO * double(HASH_NUM) / |
| 232 | (double(HASH_NUM) + double(SPACED_SEEDS_COUNT * SPACED_SEEDS_HASHES_PER_SEED)); |
| 233 | bloomBytesVanilla = size_t(vanillaRatio * bloomBytesTotal); |
| 234 | bloomBytesSpacedSeeds = bloomBytesTotal - bloomBytesVanilla; |
| 235 | } |
| 236 | |
| 237 | if (opt::verbose > 1) { |
| 238 | if (opt::errorCorrection) { |
| 239 | std::cerr << "Total Bloom filter memory = " << bytesToSI(bloomBytesTotal) << '\n'; |
| 240 | std::cerr << "Vanilla Bloom filter memory = " << bytesToSI(bloomBytesVanilla) |
| 241 | << '\n'; |
| 242 | std::cerr << "Spaced seeds Bloom filter memory = " |
| 243 | << bytesToSI(bloomBytesSpacedSeeds) << '\n'; |
| 244 | } else { |
| 245 | std::cerr << "Vanilla Bloom filter memory = " << bytesToSI(bloomBytesVanilla) |
| 246 | << '\n'; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | g_vanillaBloom = new btllib::KmerBloomFilter(bloomBytesVanilla, HASH_NUM, r); |
| 251 | if (opt::errorCorrection) { |
| 252 | const auto patterns = |
| 253 | generateSpacedSeedsPatterns(SPACED_SEEDS_COUNT, r, SPACED_SEEDS_MISSES); |
| 254 | for (const auto& pattern : patterns) { |
| 255 | (void)pattern; |
| 256 | assert(pattern.size() == size_t(r)); |
| 257 | } |
| 258 | if (SPACED_SEEDS_QC) { |
| 259 | QCSpacedSeedsPatterns(patterns); |
| 260 | } |
| 261 | g_spacedSeedsBloom = new btllib::SeedBloomFilter(bloomBytesSpacedSeeds, r, patterns, SPACED_SEEDS_HASHES_PER_SEED); |
| 262 | } |
| 263 | |
| 264 | loadReads(readFilepaths, r); |
| 265 | |
| 266 | if (opt::verbose > 1) { |
| 267 | const auto vanillaFPR = g_vanillaBloom->get_fpr(); |
| 268 |
no test coverage detected