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 typo when indexing into gap scores in forward pass #132

Merged
merged 1 commit into from
May 22, 2023

Conversation

fymue
Copy link
Contributor

@fymue fymue commented May 5, 2023

Hi DeepBLAST team,

while trying out the Aligning proteins example from your Wiki page, I noticed somewhat undefined behaviour when trying to align two specific sequences when loading the DeepBLAST model on the CPU:

import torch, os
from deepblast.utils import load_model

os.system("wget https://users.flatironinstitute.org/jmorton/public_www/deepblast-public-data/checkpoints/deepblast-pt-l8.ckpt")

model = load_model("deepblast-pt-l8.ckpt",  device="cpu")

seq_1 = "GGREGVLKKLRAVENELHYNKSLLEEVKD"
seq_2 = "QTNINSLAVRGKDCTVVISQKKVPDKLLDPTTVSYIFCISRTIGMVVNGPIPDARNAALRAKAEAAEFRYKYG"

pred_alignment = model.align(seq_1, seq_2)
print(pred_alignment)

Running this example sometimes succeeds, but often prints a different alignment string for every re-run, which it should'nt. The calculated alignments also differ from the alignment that gets calculated when running the model on the GPU with the same input sequences.
Other times the program crashes with errors like RuntimeError: Function 'NeedlemanWunschFunctionBackward' returned nan values in its 0th output. or IndexError: index -30 is out of bounds for dimension 0 with size 29.

I fixed these errors for myself by adjusting the indices that are used in the _forward_pass_numba function in nw.py to access the gap scores/penalties. This also looks like it is maybe just a typo.

@@ -55,7 +55,7 @@ def _forward_pass_numba(theta, A):
for j in range(1, M + 1):
maxargs[x] = A[i - 1, j - 1] + V[i - 1, j] # x
maxargs[m] = V[i - 1, j - 1] # m
maxargs[y] = A[i - j, 1 - 1] + V[i, j - 1] # y
maxargs[y] = A[i - 1, j - 1] + V[i, j - 1] # y
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I'm really confused where this is coming from -- yes that is definitely a (bad) typo. Thanks for catching this!

@mortonjt
Copy link
Collaborator

Wow -- that is a really embarrassing typo ... yes we want to merge this in.

@mortonjt mortonjt merged commit 912a391 into flatironinstitute:master May 22, 2023
@mortonjt
Copy link
Collaborator

Thanks for the contribution @fymue !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants