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

Uninformative error when input hmm file contains profiles with different alphabets #70

Closed
Sann5 opened this issue Jun 6, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Sann5
Copy link

Sann5 commented Jun 6, 2024

Assuming we have a hmm file containing profiles with different alphabets, and we run the following code:

  1. Download and unzip
    amino_dna.hmm.zip

  2. Open python, adjust the path to the file and run

from pyhmmer.plan7 import HMMFile
fp = "path_to_the_file/amino_dna.hmm"
with HMMFile(fp) as hmm_file:
    hmm_profiles = list(hmm_file)

The following will raise a TypeError with an uninformative message.

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "pyhmmer/plan7.pyx", line 3563, in pyhmmer.plan7.HMMFile.__next__
  File "pyhmmer/plan7.pyx", line 3641, in pyhmmer.plan7.HMMFile.read
TypeError: an integer is required

It would be nice if instead, the message said something like: "Found profiles with different alphabets."

@althonos
Copy link
Owner

althonos commented Jun 6, 2024

Actually, the error you get was raised in the code that was preparing a nicer exception message, but it had a bug and raised a TypeError instead. I fixed that and changed HMMFile.read and HMMPressedFile.read to raise AlphabetMismatch in that case, either because the file contains HMMs in multiple alphabets, or because the alphabet given to create the HMMFile is inconsistent with the alphabets of the HMMs in the file.

@althonos althonos added the bug Something isn't working label Jun 6, 2024
@althonos
Copy link
Owner

Fixed in v0.10.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants