File: test_consan.py

package info (click to toggle)
python-cogent 1.4.1-1.2
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze
  • size: 13,260 kB
  • ctags: 20,087
  • sloc: python: 116,163; ansic: 732; makefile: 74; sh: 9
file content (79 lines) | stat: -rw-r--r-- 2,417 bytes parent folder | download
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
75
76
77
78
79
#!/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.consan import Consan

__author__ = "Shandy Wikman"
__copyright__ = "Copyright 2007-2009, The Cogent Project"
__contributors__ = ["Shandy Wikman"]
__license__ = "GPL"
__version__ = "1.4.1"
__maintainer__ = "Shandy Wikman"
__email__ = "ens01svn@cs.umu.se"
__status__ = "Development"

class ConsanTest(TestCase):
    """Tests for Consan application controller"""

    def setUp(self):
        self.input1 = consan_input1
        self.input2 = consan_input2
        
        
    def test_stdout_input_as_lines(self):
        """Test Consan stdout input as lines"""

        c = Consan(InputHandler='_input_as_lines')
        input = self.input1
        input.extend(self.input2)
        res = c(input)

        #Impossible to compare stdout since copmutation time is in the output
        #which may differ between runs
        self.assertEqual(res['ExitStatus'],0)
        assert res['StdOut'] is not None
        res.cleanUp()

    def test_input_as_string(self):
        """Test Consan stdout input as string"""

        c = Consan()
        f = open('/tmp/seq1.fasta','w')
        txt = '\n'.join([str(i).strip('\n') for i in self.input1])
        f.write(txt)
        f.close()
        s = open('/tmp/seq2.fasta','w')
        txt = '\n'.join([str(i).strip('\n') for i in self.input2])
        s.write(txt)
        s.close()
        res = c(['/tmp/seq1.fasta','/tmp/seq2.fasta'])

        #Impossible to compare stdout since copmutation time is in the output
        #which may differ between runs
        self.assertEqual(res['ExitStatus'],0)
        assert res['StdOut'] is not None
                         
        res.cleanUp()

    def test_get_result_path(self):
        """Tests Consan result path"""

        c = Consan(InputHandler='_input_as_lines')
        input = self.input1
        input.extend(self.input2)
        res = c(input)
        self.assertEqualItems(res.keys(),['StdOut','StdErr','ExitStatus'])
        self.assertEqual(res['ExitStatus'],0)
        res.cleanUp()

consan_input1 = ['>seq1\n', 
'GGCCACGTAGCTCAGTCGGTAGAGCAAAGGACTGAAAATCCTTGTGTCGTTGGTTCAATTCCAACCGTGGCCACCA']
consan_input2 = ['>seq2\n', 
'GCCAGATAGCTCAGTCGGTAGAGCGTTCGCCTGAAAAGTGAAAGGTCGCCGGTTCGATCCCGGCTCTGGCCACCA']



if __name__ == '__main__':
    main()