Skip to content

Commit

Permalink
Merge pull request #252 from waveygang/avoid_overflow
Browse files Browse the repository at this point in the history
Avoid division by 0 to determine `minhash_kmer_size`
  • Loading branch information
AndreaGuarracino authored Jun 23, 2024
2 parents 577c3de + c455a67 commit 59f12f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/common/wflign/src/wflign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 59f12f6

Please sign in to comment.