File: test_sfold.py

package info (click to toggle)
python-cogent 1.5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 16,424 kB
  • ctags: 24,343
  • sloc: python: 134,200; makefile: 100; ansic: 17; sh: 10
file content (90 lines) | stat: -rw-r--r-- 2,844 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
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python

"""Provides Tests for Sfold application controller.

IMPORTANT!!! don't forget to set param_dir variable in sfold
application controller IMPORTANT!!!
"""

from os                    import remove
from cogent.util.unit_test import TestCase, main
from cogent.core.info      import Info
from cogent.app.sfold      import Sfold

__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 SfoldTest(TestCase):
    """Tests for Sfold application controller"""

    def setUp(self):
        self.input = sfold_input
        
    def test_stdout_input_as_lines(self):
        """Test Sfold stdout input as lines"""

        s = Sfold(InputHandler='_input_as_lines')
        res = s(self.input)

        self.assertEqual(res['ExitStatus'],0)
        assert res['StdOut'] is not None
        res.cleanUp()

    def test_stdout_input_as_string(self):
        """Test Sfold stdout input as string"""

        s = Sfold()
        f = open('/tmp/single.fasta','w')
        f.write('\n'.join(self.input))
        f.close()
        res = s('/tmp/single.fasta')

        self.assertEqual(res['ExitStatus'],0)
        assert res['StdOut'] is not None
        res.cleanUp()
        remove('/tmp/single.fasta')

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

        s = Sfold(InputHandler='_input_as_lines')
        res = s(self.input)
        self.assertEqualItems(res.keys(),['StdOut','StdErr','ExitStatus',
        '10structure','10structure_2','Dharmacon_thermo','bp',
        'bprob','cdf','fe','loopr','oligo','oligo_f','pdf',
        'sample','sample_1000','sirna','sirna_f','sirna_s',
        'smfe','sstrand','stability'])
        self.assertEqual(res['ExitStatus'],0)
        assert res['10structure'] is not None
        assert res['10structure_2'] is not None
        assert res['Dharmacon_thermo'] is not None
        assert res['bp'] is not None
        assert res['cdf'] is not None
        assert res['fe'] is not None
        assert res['loopr'] is not None
        assert res['oligo'] is not None
        assert res['oligo_f'] is not None
        assert res['pdf'] is not None
        assert res['sample'] is not None
        assert res['sample_1000'] is not None
        assert res['sirna'] is not None
        assert res['sirna_f'] is not None
        assert res['sirna_s'] is not None
        assert res['smfe'] is not None
        assert res['sstrand'] is not None
        assert res['stability'] is not None

        res.cleanUp()

sfold_input = ['>seq1\n', 
'GGCUAGAUAGCUCAGAUGGUAGAGCAGAGGAUUGAAGAUCCUUGUGUCGUCGGUUCGAUCCCGGCUCUGGC\n', 
'\n']

if __name__ == '__main__':
    main()