Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong band width calculation under some circumstances #723

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/biotite/sequence/align/banded.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,6 @@ def align_banded(seq1, seq2, matrix, band, gap_penalty=-10, local=False,
else:
is_swapped = False
lower_diag, upper_diag = min(band), max(band)
band_width = upper_diag - lower_diag + 1
if band_width < 1:
raise ValueError("The width of the band is 0")
if len(seq1) + upper_diag <= 0 or lower_diag >= len(seq2):
raise ValueError(
"Alignment band is out of range, the band allows no overlap "
Expand All @@ -226,6 +223,9 @@ def align_banded(seq1, seq2, matrix, band, gap_penalty=-10, local=False,
# covers the search space of an unbanded alignment
lower_diag = max(lower_diag, -len(seq1)+1)
upper_diag = min(upper_diag, len(seq2)-1)
band_width = upper_diag - lower_diag + 1
if band_width < 1:
raise ValueError("The width of the band is 0")

# This implementation uses transposed tables in comparison
# to the common visualization
Expand All @@ -249,12 +249,12 @@ def align_banded(seq1, seq2, matrix, band, gap_penalty=-10, local=False,
###############

# A score value that signals that the respective direction in the
# dynamic programming matrix should not be used since, it would be
# dynamic programming matrix should not be used, since it would be
# outside the band
# It is the 'worst' score available, so the trace table will never
# include such a direction
neg_inf = np.iinfo(np.int32).min
# Correct the 'negative infinity' integer, by making it more positve
# Correct the 'negative infinity' integer, by making it more positive
# This prevents an integer underflow when the gap penalty or
# match score is added to this value
neg_inf -= min(gap_penalty) if affine_penalty else gap_penalty
Expand Down
Loading