Skip to content

Commit 6ec2279

Browse files
committed
Add Python wrapper tests
1 parent 5662476 commit 6ec2279

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/install/
22
/__build-compile/
33
/Doxyfile.bak
4+
__pycache__/

scripts/test-wrappers

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ set -e
99

1010
cd "${MESON_SOURCE_ROOT}"
1111

12-
cd install/lib/btllib/python
13-
python3 -c 'import btllib; nt = btllib.NtHash("ACTG", 2, 3); nt.roll(); b = btllib.BloomFilter(1024, 2); b.insert(nt.hashes())'
12+
export PYTHONPATH="$(pwd)/install/lib/btllib/python"
13+
cd tests/python
14+
python -m unittest

tests/python/single_seq.fa

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
>1
2+
CGCGTGAAAGCAAAACAAGA

tests/python/test_bloom_filter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import btllib
2+
import unittest
3+
4+
class BloomFilterTests(unittest.TestCase):
5+
6+
def test_seq_insertion(self):
7+
seq, k = 'AGTCATCGACTGATGC', 5
8+
bf = btllib.KmerBloomFilter(1024, 3, k)
9+
bf.insert(seq)
10+
self.assertEqual(bf.contains('TCATC'), 1)

tests/python/test_seq_reader.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import btllib
3+
import unittest
4+
5+
6+
class SeqReaderTests(unittest.TestCase):
7+
8+
def setUp(self):
9+
self.base_dir = os.path.dirname(__file__)
10+
11+
def test_seq_reader_single_seq(self):
12+
seq = 'CGCGTGAAAGCAAAACAAGA'
13+
path = os.path.join(self.base_dir, 'single_seq.fa')
14+
with btllib.SeqReader(path, btllib.SeqReaderFlag.SHORT_MODE) as reader:
15+
read = [record.seq for record in reader]
16+
self.assertListEqual([seq], read)

0 commit comments

Comments
 (0)