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 65 66 67 68 69 70 71 72 73 74
|
#!/usr/bin/env python
from os import remove
from cogent.util.unit_test import TestCase, main
from cogent.core.info import Info
from cogent.app.dynalign import Dynalign
__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 DynalignTest(TestCase):
"""Tests for Dynalign application controller"""
def setUp(self):
self.input1 = dynalign_input1
self.input2 = dynalign_input2
def test_stdout_input_as_lines(self):
"""Test Dynalign stdout input as lines"""
d = Dynalign(InputHandler='_input_as_lines')
exp = '%s\n' % '\n'.join([str(i).strip('\n') for i in dynalign_stdout])
res = d([self.input1,self.input2])
obs = res['StdOut'].read()
self.assertEqual(obs,exp)
res.cleanUp()
def test_stdout_input_as_string(self):
"""Test Dynalign stdout input as string"""
d = Dynalign()
exp = '%s\n' % '\n'.join([str(i).strip('\n') for i in dynalign_stdout])
f = open('/tmp/dyn1','w')
txt = '\n'.join([str(i).strip('\n') for i in self.input1])
f.write(txt)
f.close()
s = open('/tmp/dyn2','w')
txt = '\n'.join([str(i).strip('\n') for i in self.input2])
s.write(txt)
s.close()
res = d(['/tmp/dyn1','/tmp/dyn2'])
obs = res['StdOut'].read()
self.assertEqual(obs,exp)
res.cleanUp()
def test_get_result_path(self):
"""Tests Dynalign result path"""
d = Dynalign(InputHandler='_input_as_lines')
res = d([self.input1,self.input2])
self.assertEqualItems(res.keys(),['StdOut','StdErr','ExitStatus',\
'seq_1_ct','seq_2_ct','alignment'])
self.assertEqual(res['ExitStatus'],0)
res.cleanUp()
dynalign_input1 = [';\n', 'testSeq1\n', '\n',
'GGCTAGATAGCTCAGGTCGGTTCGATCCCGGCTCTGGCC1']
dynalign_input2 = [';\n', 'testSeq2\n', '\n',
'GGCTAGATAGCTGTGTCGTCGGTTCGATCCCGGCTCTGGCC1']
dynalign_stdout = ['12%\n', '25%\n', '38%\n', '51%\n', '64%\n', '76%\n',
'89%\n']
if __name__ == '__main__':
main()
|