-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_database_build.py
59 lines (49 loc) · 1.66 KB
/
test_database_build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Unit tests for class Database
"""
import tempfile
import unittest
from pathlib import Path
from pynteny.api import Build
from pynteny.preprocessing import Database, LabelledFASTA
this_file_dir = Path(__file__).parent
class TestDatabase(unittest.TestCase):
def test_build_fasta(self):
data = Path(this_file_dir / "test_data/test_assembly")
database = Database(data)
with tempfile.NamedTemporaryFile() as outfile:
labelled_database = database.build(
seq_prefix="test",
output_file=outfile.name,
prepend_file_name=True,
tempdir=None,
)
self.assertIsInstance(
labelled_database,
LabelledFASTA,
"Failed to build database from assembly data",
)
def test_build(self):
with tempfile.NamedTemporaryFile() as outfile:
Build(
data=Path(this_file_dir / "test_data/test_assembly"),
outfile=outfile.name,
logfile=None,
tempdir=None,
).run()
def test_build_gbk(self):
data = Path(this_file_dir / "test_data/MG1655.gb")
database = Database(data)
with tempfile.NamedTemporaryFile() as outfile:
labelled_database = database.build(
seq_prefix="test", output_file=outfile.name
)
self.assertIsInstance(
labelled_database,
LabelledFASTA,
"Failed to build database from GenBank data",
)
if __name__ == "__main__":
unittest.main()