-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_ypkpathway.py
56 lines (38 loc) · 1.74 KB
/
test_ypkpathway.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import shutil
import pytest
import textwrap
from pydna.parsers import parse
from pydna.readers import read
import tempfile
from ypkpathway import pathway
tmp = os.path.join( tempfile.gettempdir(), "ypkpathway_test_dir" )
def test_ypk():
datafiles = '''pth1.txt|pYPK0_CiGXF1_PsXYL2.gb|iM8oDuvJPMPO995IdW3B0oo0Hkc
pth2.txt|pYPK0_SsXYL1_SsXYL2.gb|CB_qLhPgemW0XNLQOQEAdJKFujU
pth3.txt|pYPK0_NC_006038_CiGXF1_PsXYL2.gb|48_Bek9U1wxXlq1otmE7YHjYpnk
pth4.txt|pYPK0_SsXYL1_SsXYL2_ScXKS1.gb|5OxynmwQA3br0cKAG8It7VVNGrg
pth5.txt|pYPK0_SsXYL1_SsXYL2_ScXKS1_ScTAL1.gb|K8z4ijkYa0hA0KEOhv7-6PNJgBM
pth6.txt|pYPK0_SsXYL1_SsXYL2_ScXKS1_ScTAL1.gb|K8z4ijkYa0hA0KEOhv7-6PNJgBM
pth7.txt|pYPK0_SsXYL1_SsXYL2_ScXKS1_ScTAL1.gb|K8z4ijkYa0hA0KEOhv7-6PNJgBM'''
for pYPKa_A in (True, False):
for datafile in textwrap.dedent(datafiles).split():
file_, name, code = datafile.split("|")
print()
print("############################")
print("datafile = ", file_)
print("pYPKa_A = ", pYPKa_A)
print("############################")
with open(file_, "r",) as f: text = f.read()
try:
shutil.rmtree(tmp)
except OSError:
pass
pw = pathway( parse(text), tmp, pYPKa_A=pYPKa_A)
s = read( os.path.join(tmp, name) )
with open(code+".txt") as f: c = f.read()
assert "".join( x for x in c.lower() if not x.isspace()) == str(s.seq).lower()
if __name__ == '__main__':
pytest.cmdline.main([__file__, "-v", "-s"])