Skip to content

Commit

Permalink
Merge branch 'DOR-939_disallow_inferior_barcodes' into 'master'
Browse files Browse the repository at this point in the history
DOR-939 Added additional check to declassify inferior scoring barcodes

Closes DOR-939

See merge request machine-learning/dorado!1252
  • Loading branch information
MarkBicknellONT committed Nov 15, 2024
2 parents 0d788d7 + cc32c93 commit 40296da
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions dorado/demux/BarcodeClassifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,28 @@ BarcodeScoreResult BarcodeClassifier::find_best_barcode(
}
}

if (kit.double_ends) {
// For more stringent classification, ensure that neither end of a read has a higher scoring
// barcode, if any of the barcodes at that end are better than the threshold.
auto best_top_result = std::min_element(
results.begin(), results.end(),
[](const auto& l, const auto& r) { return l.top_penalty < r.top_penalty; });
auto best_bottom_result = std::min_element(
results.begin(), results.end(),
[](const auto& l, const auto& r) { return l.bottom_penalty < r.bottom_penalty; });

if (((out.barcode_name != best_top_result->barcode_name) &&
(best_top_result->top_penalty <= m_scoring_params.max_barcode_penalty)) ||
((out.barcode_name != best_bottom_result->barcode_name) &&
(best_bottom_result->bottom_penalty <= m_scoring_params.max_barcode_penalty))) {
spdlog::trace(
"Superior barcode found for arrangement {} : top best bc {}, bottom best bc {}",
out.barcode_name, best_top_result->barcode_name,
best_bottom_result->barcode_name);
return UNCLASSIFIED;
}
}

// If nothing is found, report as unclassified.
return out;
}
Expand Down

0 comments on commit 40296da

Please sign in to comment.