Skip to content

Commit

Permalink
Fix issue with masking of trailing nucleotides (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed May 18, 2024
1 parent 2a6eca0 commit 1562471
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion pyrodigal/lib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class Sequence(typing.Sized):
def __init__(
self,
sequence: Union[str, bytes, bytearray, Sequence],
mask: bool = False
mask: bool = False,
mask_size; int = 50,
) -> None: ...
def __len__(self) -> int: ...
def __sizeof__(self) -> int: ...
Expand Down
2 changes: 2 additions & 0 deletions pyrodigal/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,8 @@ cdef class Sequence:
if i >= mask_size + mask_begin:
self.masks._add_mask(mask_begin, i)
mask_begin = -1
if mask_begin != -1:
self.masks._add_mask(mask_begin, self.slen)
return 0

cdef int _allocate(self, int slen) except 1:
Expand Down
6 changes: 0 additions & 6 deletions pyrodigal/tests/test_gene.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ def test_translate_strictness(self):
self.assertEqual(strict[1:9], "XXXXXXXX")
self.assertEqual(non_strict[1:9], "PRLTVAGS")

# strict = gene.translate(strict=True, translation_table=3)
# non_strict = gene.translate(strict=False, translation_table=3)

# self.assertEqual(strict[1:9], "XXXXXXXX")
# self.assertEqual(non_strict[1:9], "PRTTVAGS")

strict = gene.translate(strict=True, translation_table=12)
non_strict = gene.translate(strict=False, translation_table=12)

Expand Down
4 changes: 4 additions & 0 deletions pyrodigal/tests/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ def test_shine_dalgarno_mismatch(self):
# AGGxGG if i == 0 else None
expected = 19 if i == 0 else 0
self.assertEqual(seq.shine_dalgarno(i, 15, tinf, exact=False), expected, i)

def test_mask_trailing(self):
seq = Sequence("AGCGGGCTACTGNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", mask=True, mask_size=10)
self.assertEqual(len(seq.masks), 1)

0 comments on commit 1562471

Please sign in to comment.