In my work I've found that in circumstances where there is a mismatch near the edges of the query sequence, blastn prefers to return a shorter contiguous alignment, rather than allowing for a mismatch near the 5' or 3' end of the query sequence.

For example, consider the subject sequence (bold indicates alignment with mismatch in brackets):


and query sequence:


Blasting this will return the 19bp contiguous alignment upstream of the mismatch, rather than returning a 21bp alignment with a single mismatch at the G/A base at position 20 in the query.

I'm using the command line version of blastn, and I've tried messing with the penalties as well as setting -task blastn-short, but nothing seems to fix this issue.

I speculate that the various gap and mismatch penalties are working out such that a shorter contiguous alignment is preferred over a slightly longer alignment with a mismatch, but I haven't been able to figure out how to modify the penalties in such a way as to change this preference.

  • 1
    $\begingroup$ Nope, altering the weights is the solution as you said. So please do answer your own question —this a totally encouraged behaviour. $\endgroup$ Oct 8, 2021 at 9:20

1 Answer 1


Here's my working solution,

So I found a choice of parameters that resolves this, -reward 3 -gapopen 5 -gapextend 5.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.