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

error: "local variable 'encode' referenced before assignment" #5

Open
LedaKatopodi opened this issue Mar 28, 2023 · 2 comments
Open

Comments

@LedaKatopodi
Copy link

hi~

running deepimmuno-cnn on mode "multiple" returns this error:

UnboundLocalError: local variable 'encode' referenced before assignment

which can be traced back to line 156 of deepimmuno-cnn.py when running peptide_data_aaindex - specifically when running:

encode_pep = peptide_data_aaindex(peptide,after_pca)

replacing the function peptide_data_aaindex in place solved the issue for me - so instead of running the line above I run instead:

# encode_pep = peptide_data_aaindex(peptide,after_pca)    # [10,12]
    length = len(peptide)
    if length == 10:
        encode = aaindex(peptide,after_pca)
    elif length == 9:
        peptide = peptide[:5] + '-' + peptide[5:]
        encode = aaindex(peptide,after_pca)
    encode = encode.reshape(encode.shape[0], encode.shape[1], -1)
    encode_pep = encode

not sure whether anyone else can replicate this error, but am raising the issue in case this is actually a bug.

thanks for building this tool!

cheers,
Leda

@frankligy
Copy link
Owner

Hi @LedaKatopodi,

Thanks for bringing this up and sorry for the inconvenience you were experiencing.

The UnboundLocalError usually comes from the fact that there are peptides not of length 9 or 10, because as you can see from the function peptide_data_aaindex, if the length doesn't fit into 9 or 10, no encode will be defined, so when later executing reshape function, it will throw an error.

But you said replacing the code solves your problem, which I can not intuit an explanation off hand, because if there are peptides of other lengths, the same issue should persist. But Maybe I missed something here.

Would you mind first checking the peptide length in your input? And happy to help further!

Best,
Frank

@LedaKatopodi
Copy link
Author

hi @frankligy~

I also thought it might be the length but for that specific batch I only loaded 9aa-long antigens.

thanks for looking into this

best,
Leda

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

No branches or pull requests

2 participants