Skip to content

Commit

Permalink
Add tests for __getbuffer__ implementation of TextSequence and `D…
Browse files Browse the repository at this point in the history
…igitalSequence`
  • Loading branch information
althonos committed Oct 25, 2024
1 parent 6d2b28a commit f4cf040
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/pyhmmer/tests/test_easel/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ def test_reverse_complement_protein(self):
def test_invalid_characters(self):
self.assertRaises(ValueError, easel.DigitalSequence, self.abc, name=b"TEST", sequence=b"test")

def test_memoryview(self):
seq = easel.TextSequence(sequence="ATGC").digitize(self.abc)
mem = memoryview(seq)
self.assertEqual(mem.tobytes(), b"\0\3\2\1")

def test_translate(self):
gencode = easel.GeneticCode()
seq = easel.TextSequence(sequence="ATGCTGCCCGGTTTGGCACTGCTCCTGCTGGCCGCC").digitize(gencode.nucleotide_alphabet)
Expand Down Expand Up @@ -220,6 +225,11 @@ def test_digitize_invalid(self):
self.assertRaises(ValueError, seq1.digitize, easel.Alphabet.dna())
self.assertRaises(ValueError, seq1.digitize, easel.Alphabet.amino())

def test_memoryview(self):
seq = self.Sequence(sequence="ATGC")
mem = memoryview(seq)
self.assertEqual(mem.tobytes(), b"ATGC")

def test_reverse_complement(self):
seq = easel.TextSequence(sequence="ATGC")
rc = seq.reverse_complement()
Expand Down

0 comments on commit f4cf040

Please sign in to comment.