diff --git a/src/sse_banded_LCS_alignment.c b/src/sse_banded_LCS_alignment.c index 8790c6b..eab489b 100644 --- a/src/sse_banded_LCS_alignment.c +++ b/src/sse_banded_LCS_alignment.c @@ -900,6 +900,14 @@ double generic_sse_banded_lcs_align(char* seq1, char* seq2, double threshold, bo lmin = l1; } + // Check that the sequences are not greater than what can be aligned using the 16 bits registers (as the LCS and alignment lengths are kept on 16 bits) + if (lmax > SHRT_MAX) + { + obi_set_errno(OBI_ALIGN_ERROR); + obidebug(1, "\nError: can not align sequences longer than %d (as the LCS and alignment lengths are kept on 16 bits)", SHRT_MAX); + return 0; // TODO DOUBLE_MIN to flag error + } + // If the score is expressed as a normalized distance, get the corresponding identity if (!similarity_mode && normalize) threshold = 1.0 - threshold; @@ -995,6 +1003,14 @@ double obiblob_sse_banded_lcs_align(Obi_blob_p seq1, Obi_blob_p seq2, double thr lmin = l1; } + // Check that the sequences are not greater than what can be aligned using the 16 bits registers (as the LCS and alignment lengths are kept on 16 bits) + if (lmax > SHRT_MAX) + { + obi_set_errno(OBI_ALIGN_ERROR); + obidebug(1, "\nError: can not align sequences longer than %d (as the LCS and alignment lengths are kept on 16 bits)", SHRT_MAX); + return 0; // TODO DOUBLE_MIN to flag error + } + // If the score is expressed as a normalized distance, get the corresponding identity if (!similarity_mode && normalize) threshold = 1.0 - threshold;