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 60 61 62 63 64
|
#!/usr/bin/env python
from os import remove
from cogent.util.unit_test import TestCase, main
from cogent.app.pknotsrg import PknotsRG
__author__ = "Shandy Wikman"
__copyright__ = "Copyright 2007-2012, The Cogent Project"
__contributors__ = ["Shandy Wikman"]
__license__ = "GPL"
__version__ = "1.5.3"
__maintainer__ = "Shandy Wikman"
__email__ = "ens01svn@cs.umu.se"
__status__ = "Development"
class PknotsrgTest(TestCase):
"""Tests for Pknotsrg application controller"""
def setUp(self):
self.input = pknotsrg_input
def test_stdout_input_as_lines(self):
"""Test pknotsrg stdout input as lines"""
p = PknotsRG(InputHandler='_input_as_lines')
exp= '%s\n' % '\n'.join([str(i).strip('\n') for i in pknotsrg_stdout])
res = p(self.input)
obs = res['StdOut'].read()
self.assertEqual(obs,exp)
res.cleanUp()
def test_stdout_input_as_string(self):
"""Test pknotsrg stdout input as string"""
p = PknotsRG()
exp= '%s\n' % '\n'.join([str(i).strip('\n') for i in pknotsrg_stdout])
f = open('/tmp/single.plain','w')
txt = '\n'.join([str(i).strip('\n') for i in self.input])
f.write(txt)
f.close()
res = p('/tmp/single.plain')
obs = res['StdOut'].read()
self.assertEqual(obs,exp)
res.cleanUp()
remove('/tmp/single.plain')
def test_get_result_path(self):
"""Tests pknotsrg result path"""
p = PknotsRG(InputHandler='_input_as_lines')
res = p(self.input)
self.assertEqualItems(res.keys(),['StdOut','StdErr','ExitStatus'])
self.assertEqual(res['ExitStatus'],0)
assert res['StdOut'] is not None
res.cleanUp()
pknotsrg_input = ['GGCUAGAUAGCUCAGAUGGUAGAGCAGAGGAUUGAAGAUCCUUGUGUCGUCGGUUCGAUCCCGGCUCUGGC\n']
pknotsrg_stdout = ['GGCUAGAUAGCUCAGAUGGUAGAGCAGAGGAUUGAAGAUCCUUGUGUCGUCGGUUCGAUCCCGGCUCUGGC\n', '.((((((..((((........)))).(((((((...))))))).....(((((.......))))))))))) (-22.40)\n']
if __name__ == '__main__':
main()
|