diff --git a/pyhmmer/easel.pyx b/pyhmmer/easel.pyx index ee243d4f5738d85ee332da8b24053cfcc4e18446..5f87047a21fbf91f525f90c7177ef51ffb69e577 100644 --- a/pyhmmer/easel.pyx +++ b/pyhmmer/easel.pyx @@ -3716,7 +3716,7 @@ cdef class TextMSA(MSA): return new elif status == libeasel.eslEINVAL: err_msg = errbuf.decode("utf-8", "replace") - raise ValueError(f"Cannot digitize MSA with alphabet {alphabet}: {err_msg}") + raise ValueError(f"Cannot digitize MSA with {alphabet.type} alphabet: {err_msg}") else: raise UnexpectedError(status, "esl_msa_Digitize") diff --git a/pyhmmer/plan7.pyx b/pyhmmer/plan7.pyx index b5cf93165cfed6e6e0581ddae18198e37b640e38..6f8b873e0e1acec813cdc513747be85932c9863c 100644 --- a/pyhmmer/plan7.pyx +++ b/pyhmmer/plan7.pyx @@ -3610,6 +3610,9 @@ cdef class HMMFile: file, or when the file could not be parsed. `~pyhmmer.errors.AllocationError`: When memory for the HMM could not be allocated successfully. + `~pyhmmer.errors.AlphabetMismatch`: When the file contains HMMs + in different alphabets, or in an alphabet that is different + from the alphabet used to initialize the `HMMFile`. .. versionadded:: 0.4.11 @@ -3638,8 +3641,7 @@ cdef class HMMFile: elif status == libeasel.eslEFORMAT: raise ValueError("Invalid format in file: {}".format(self._hfp.errbuf.decode("utf-8", "replace"))) elif status == libeasel.eslEINCOMPAT: - alphabet = libeasel.alphabet.esl_abc_DecodeType(self._alphabet.type) - raise ValueError("HMM is not in the expected {} alphabet".format(alphabet)) + raise AlphabetMismatch(self._alphabet) else: _reraise_error() raise UnexpectedError(status, "p7_hmmfile_Read") @@ -3818,6 +3820,10 @@ cdef class HMMPressedFile: closed file, or when the file could not be parsed. `~pyhmmer.errors.AllocationError`: When memory for the `OptimizedProfile` could not be allocated successfully. + `~pyhmmer.errors.AlphabetMismatch`: When the file contains + optimized profiles in different alphabets, or in an alphabet + that is different from the alphabet used to initialize the + `HMMFile`. .. versionadded:: 0.4.11 @@ -3845,8 +3851,7 @@ cdef class HMMPressedFile: elif status == libeasel.eslEFORMAT: raise ValueError("Invalid format in file: {}".format(self._hfp.errbuf.decode("utf-8", "replace"))) elif status == libeasel.eslEINCOMPAT: - alphabet = libeasel.alphabet.esl_abc_DecodeType(self._alphabet.type) - raise ValueError("HMM is not in the expected {} alphabet".format(alphabet)) + raise AlphabetMismatch(self._alphabet) else: _reraise_error() raise UnexpectedError(status, "p7_oprofile_ReadMSV")