[biopython/biopython] local pairwise alignment using pairwise2

Setup

I am reporting a problem with Biopython version, Python version, and operating system as follows:

3.6.13 | packaged by conda-forge | (default, Feb 19 2021, 05:36:01) 
[GCC 9.3.0]
CPython
Linux-5.11.0-41-generic-x86_64-with-debian-bullseye-sid
1.78

# also tested on windows-subsystem
3.9.7 (default, Sep 16 2021, 13:09:58)
[GCC 7.5.0]
CPython
Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.31
1.78

Expected behaviour

The local pairwise alignment between seq1 and seq2 were performed using localms function:

seq1 = "AATTCCAGTGTCAGACCCTGTTCTAAGTACTTCTATCTATCTATC"
seq2 = "CTGTGTCAGACCCTGTTCTAAGTACTTCCT"
alignments = align.localms(seq1.upper(), seq2.upper(), 1, -0.9, -0.75, -0.1)
[aln_ref, aln_seq, aln_score, aln_start, aln_end] = alignments[0]

Considering the gap open penalty is -0.75 and extend penalty is -0.1, and the number of gap shouldn’t exceed 3. The result should be the following, which only contains one gap:

AATTCCAGTGTCAGACCCTGTTCTAAGTACTTC-TATCTATCTATC
-----CTGTGTCAGACCCTGTTCTAAGTACTTCCT-------

Actual behaviour

However, the result contains 3 gaps,

AATTCCAGTGTCAGACCCTGTTCTAAGTACTTCTATCTATCTATC
-----CTGTGTCAGACCCTGTTCTAAGTACTTC---CT-------

And then, I exchanged the input order:

alignments = align.localms(seq2.upper(), seq1.upper(), 1, -0.9, -0.75, -0.1)

The result is the same.

Looking forward to your reply, thanks!

Steps to reproduce

Read more here: Source link