diff --git a/docs/DualBarcodesPairedEnd_8hpp_source.html b/docs/DualBarcodesPairedEnd_8hpp_source.html index a6d02d3..60f5383 100644 --- a/docs/DualBarcodesPairedEnd_8hpp_source.html +++ b/docs/DualBarcodesPairedEnd_8hpp_source.html @@ -322,106 +322,104 @@
311 auto deets1 = constant1.initialize(against1.first, against1.second - against1.first);
312 auto deets2 = constant2.initialize(against2.first, against2.second - against2.first);
313
-
314 state.second_matches.clear();
-
315 int chosen = -1;
-
316 int best_mismatches = max_mm1 + max_mm2 + 1;
-
317
-
318 auto checker = [&](size_t idx2) -> void {
-
319 const auto& current2 = state.second_matches[idx2];
-
320 state.combined = state.first_match.first;
-
321 state.combined += current2.first; // separate line is deliberate.
-
322 varlib.search(state.combined, state.details, std::array<int, 2>{ max_mm1 - state.first_match.second, max_mm2 - current2.second });
+
314 // Getting all hits on the second read, and then looping over that
+
315 // vector for each hit of the first read. We have to do all pairwise
+
316 // comparisons anyway to find the best hit.
+
317 state.second_matches.clear();
+
318 while (inner_process(search_reverse2, constant2, max_mm2, against2.first, deets2, state.second_matches)) {}
+
319
+
320 int chosen = -1;
+
321 int best_mismatches = max_mm1 + max_mm2 + 1;
+
322 size_t num_second_matches = state.second_matches.size();
323
-
324 int cur_mismatches = state.details.mismatches;
-
325 if (cur_mismatches < best_mismatches) {
-
326 chosen = state.details.index;
-
327 best_mismatches = cur_mismatches;
-
328 } else if (cur_mismatches == best_mismatches && chosen != state.details.index) { // ambiguous.
-
329 chosen = -1;
-
330 }
-
331 };
+
324 if (!state.second_matches.empty()) {
+
325 while (inner_process(search_reverse1, constant1, max_mm1, against1.first, deets1, state.first_match)) {
+
326 for (size_t i = 0; i < num_second_matches; ++i) {
+
327 const auto& current2 = state.second_matches[i];
+
328
+
329 state.combined = state.first_match.first;
+
330 state.combined += current2.first; // separate line is deliberate.
+
331 varlib.search(state.combined, state.details, std::array<int, 2>{ max_mm1 - state.first_match.second, max_mm2 - current2.second });
332
-
333 // Getting all hits on the second read, and then looping over that
-
334 // vector for each hit of the first read. We have to do all pairwise
-
335 // comparisons anyway to find the best hit.
-
336 while (inner_process(search_reverse2, constant2, max_mm2, against2.first, deets2, state.second_matches)) {
-
337 checker(state.second_matches.size() - 1);
-
338 }
-
339
-
340 if (!state.second_matches.empty()) {
-
341 while (inner_process(search_reverse1, constant1, max_mm1, against1.first, deets1, state.first_match)) {
-
342 for (size_t i = 0; i < state.second_matches.size(); ++i) {
-
343 checker(i);
-
344 }
-
345 }
-
346 }
-
347
-
348 return std::make_pair(chosen, best_mismatches);
-
349 }
-
350
-
351public:
-
355 bool process(State& state, const std::pair<const char*, const char*>& r1, const std::pair<const char*, const char*>& r2) const {
-
356 bool found;
-
357
-
358 if (use_first) {
-
359 found = process_first(state, r1, r2);
-
360 if (!found && randomized) {
-
361 found = process_first(state, r2, r1);
-
362 }
-
363
-
364 } else {
-
365 auto best = process_best(state, r1, r2);
-
366 if (randomized) {
-
367 auto best2 = process_best(state, r2, r1);
-
368 if (best.first < 0 || best.second > best2.second) {
-
369 best = best2;
-
370 } else if (best.second == best2.second && best.first != best2.first) {
-
371 best.first = -1; // ambiguous.
-
372 }
-
373 }
-
374
-
375 found = best.first >= 0;
-
376 if (found) {
-
377 ++state.counts[best.first];
-
378 }
-
379 }
-
380
-
381 ++state.total;
-
382 return found;
-
383 }
-
388private:
-
389 bool search_reverse1, search_reverse2;
-
390
-
391 ScanTemplate<max_size> constant1, constant2;
-
392 SegmentedBarcodeSearch<2> varlib;
-
393 int max_mm1, max_mm2;
-
394
-
395 bool randomized;
-
396 bool use_first = true;
-
397
-
398 std::vector<int> counts;
-
399 int total = 0;
-
400
-
401public:
-
407 const std::vector<int>& get_counts() const {
-
408 return counts;
-
409 }
-
410
-
414 int get_total() const {
-
415 return total;
-
416 }
-
417};
-
418
-
422// Soft-deprecated back-compatible aliases.
-
423template<size_t max_size>
-
424using DualBarcodes = DualBarcodesPairedEnd<max_size>;
-
429}
-
430
-
431#endif
+
333 if (state.details.index >= 0) {
+
334 int cur_mismatches = state.details.mismatches + state.first_match.second + current2.second;
+
335 if (cur_mismatches < best_mismatches) {
+
336 chosen = state.details.index;
+
337 best_mismatches = cur_mismatches;
+
338 } else if (cur_mismatches == best_mismatches && chosen != state.details.index) { // ambiguous.
+
339 chosen = -1;
+
340 }
+
341 }
+
342 }
+
343 }
+
344 }
+
345
+
346 return std::make_pair(chosen, best_mismatches);
+
347 }
+
348
+
349public:
+
353 bool process(State& state, const std::pair<const char*, const char*>& r1, const std::pair<const char*, const char*>& r2) const {
+
354 bool found;
+
355
+
356 if (use_first) {
+
357 found = process_first(state, r1, r2);
+
358 if (!found && randomized) {
+
359 found = process_first(state, r2, r1);
+
360 }
+
361
+
362 } else {
+
363 auto best = process_best(state, r1, r2);
+
364 if (randomized) {
+
365 auto best2 = process_best(state, r2, r1);
+
366 if (best.first < 0 || best.second > best2.second) {
+
367 best = best2;
+
368 } else if (best.second == best2.second && best.first != best2.first) {
+
369 best.first = -1; // ambiguous.
+
370 }
+
371 }
+
372
+
373 found = best.first >= 0;
+
374 if (found) {
+
375 ++state.counts[best.first];
+
376 }
+
377 }
+
378
+
379 ++state.total;
+
380 return found;
+
381 }
+
386private:
+
387 bool search_reverse1, search_reverse2;
+
388
+
389 ScanTemplate<max_size> constant1, constant2;
+
390 SegmentedBarcodeSearch<2> varlib;
+
391 int max_mm1, max_mm2;
+
392
+
393 bool randomized;
+
394 bool use_first = true;
+
395
+
396 std::vector<int> counts;
+
397 int total = 0;
+
398
+
399public:
+
405 const std::vector<int>& get_counts() const {
+
406 return counts;
+
407 }
+
408
+
412 int get_total() const {
+
413 return total;
+
414 }
+
415};
+
416
+
420// Soft-deprecated back-compatible aliases.
+
421template<size_t max_size>
+
422using DualBarcodes = DualBarcodesPairedEnd<max_size>;
+
427}
+
428
+
429#endif
kaori::DualBarcodesPairedEnd
Handler for dual barcodes.
Definition: DualBarcodesPairedEnd.hpp:27
-
kaori::DualBarcodesPairedEnd::get_counts
const std::vector< int > & get_counts() const
Definition: DualBarcodesPairedEnd.hpp:407
+
kaori::DualBarcodesPairedEnd::get_counts
const std::vector< int > & get_counts() const
Definition: DualBarcodesPairedEnd.hpp:405
kaori::DualBarcodesPairedEnd::DualBarcodesPairedEnd
DualBarcodesPairedEnd(const char *template_seq1, size_t template_length1, const BarcodePool &barcode_pool1, const char *template_seq2, size_t template_length2, const BarcodePool &barcode_pool2, const Options &options)
Definition: DualBarcodesPairedEnd.hpp:92
-
kaori::DualBarcodesPairedEnd::get_total
int get_total() const
Definition: DualBarcodesPairedEnd.hpp:414
+
kaori::DualBarcodesPairedEnd::get_total
int get_total() const
Definition: DualBarcodesPairedEnd.hpp:412
kaori::SegmentedBarcodeSearch
Search for known barcode sequences with segmented mismatches.
Definition: BarcodeSearch.hpp:290
kaori::SegmentedBarcodeSearch::reduce
void reduce(State &state)
Definition: BarcodeSearch.hpp:423
kaori::SegmentedBarcodeSearch::search
void search(const std::string &search_seq, State &state) const
Definition: BarcodeSearch.hpp:461