From c455a6727ece3689ba8ea0cb1618c07c07c4c6e1 Mon Sep 17 00:00:00 2001 From: AndreaGuarracino Date: Sun, 23 Jun 2024 10:18:57 +0200 Subject: [PATCH] avoid division by 0 to determine `minhash_kmer_size` --- src/common/wflign/src/wflign.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/wflign/src/wflign.cpp b/src/common/wflign/src/wflign.cpp index a05e2152..12901641 100644 --- a/src/common/wflign/src/wflign.cpp +++ b/src/common/wflign/src/wflign.cpp @@ -329,7 +329,9 @@ void WFlign::wflign_affine_wavefront( return; } - const int minhash_kmer_size = std::max(8, std::min(17, (int)std::floor(1.0 / (1.0 - mashmap_estimated_identity)))); + // Check if mashmap_estimated_identity == 1 to avoid division by zero, leading to a minhash_kmer_size of 8. + // Such low value was leading to confusion in HORs alignments in the human centromeres (high runtime and memory usage, and wrong alignments) + const int minhash_kmer_size = mashmap_estimated_identity == 1 ? 17 : std::max(8, std::min(17, (int)std::floor(1.0 / (1.0 - mashmap_estimated_identity)))); // Set penalties for wfa affine wflign_penalties_t wfa_affine_penalties;