Skip to content

Commit

Permalink
Avoid GIL acquisition to check exceptions of GeneticCode._translate
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Nov 28, 2023
1 parent 3039a56 commit aa387b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyhmmer/easel.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ cdef class GeneticCode:
cdef readonly Alphabet nucleotide_alphabet
cdef ESL_GENCODE* _gcode

cdef void _translate(
cdef int _translate(
self,
const ESL_DSQ* seq,
int64_t seqlen,
ESL_DSQ* out,
int64_t outlen
) except * nogil
) except -1 nogil

cpdef VectorU8 translate(self, const ESL_DSQ[::1] sequence)

Expand Down
6 changes: 4 additions & 2 deletions pyhmmer/easel.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,13 @@ cdef class GeneticCode:

# --- Utils --------------------------------------------------------------

cdef void _translate(
cdef int _translate(
self,
const ESL_DSQ* seq,
int64_t seqlen,
ESL_DSQ* out,
int64_t outlen
) except * nogil:
) except -1 nogil:
cdef int aa
cdef int64_t i
cdef int64_t j
Expand All @@ -567,6 +567,8 @@ cdef class GeneticCode:
raise ValueError(f"Failed to translate codon at index {j!r}")
out[i] = aa

return 0

# --- Methods ------------------------------------------------------------

cpdef VectorU8 translate(self, const ESL_DSQ[::1] sequence):
Expand Down

0 comments on commit aa387b3

Please sign in to comment.