forked from eggnogdb/eggnog-mapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
executable file
·57 lines (46 loc) · 1.79 KB
/
test.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
import unittest
import subprocess
import os
def run(cmd):
cmd = './emapper.py ' + cmd
print cmd
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
out, err = process.communicate()
if not out:
out = ''
if not err:
err = ''
return (process.returncode, out, err)
class Test(unittest.TestCase):
def test_executions(self):
os.system('rm borrame.emapper.*')
# should run
st, out, err = run('-i test/polb.fa -d bact:localhost:51500 -o borrame')
assert st == 0
# should fail because output files exist
st, out, err = run('-i test/polb.fa -d bact:localhost:51500 -o borrame')
assert st == 1
assert 'Use --resume' in out
# should run
st, out, err = run('-i test/polb.fa -d bact:localhost:51500 -o borrame --override')
assert st == 0
# should run with no search
st, out, err = run('-i test/polb.fa -d bact:localhost:51500 -o borrame --resume')
assert st == 0
# should run with no search and read prev table
st, out, err = run('-i test/polb.fa -d bact:localhost:51500 -o borrame --annotate_hits_table borrame.emapper.seed_orthologs --override')
assert st == 0
# should run from disk
os.system('rm borrame.emapper.*')
st, out, err = run('-i test/polb.fa -d maNOG -o borrame')
assert st == 0
# should run from mem
os.system('rm borrame.emapper.*')
st, out, err = run('-i test/polb.fa -d maNOG -o borrame --usemem')
assert st == 0
# should run from mem
os.system('rm borrame.emapper.*')
st, out, err = run('-i test/polb.fa -o borrame -m diamond --cpu 0')
assert st == 0
if __name__ == '__main__':
unittest.main()