File: test_kegg_pos.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 (46 lines) | stat: -rw-r--r-- 1,831 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
#!/usr/bin/env python

from cogent.util.unit_test import TestCase, main
from cogent.parse.kegg_pos import parse_pos_lines, parse_pos_file

__author__ = "Jesse Zaneveld"
__copyright__ = "Copyright 2007-2012, The Cogent Project"
__credits__ = ["Jesse Zaneveld", "Rob Knight"]
__license__ = "GPL"
__version__ = "1.5.3"
__maintainer__ = "Jesse Zaneveld"
__email__ = "zaneveld@gmail.com"
__status__ = "Production"

"""
Test code for kegg_pos.py in cogent.parse.  
"""

class ParsePosTests(TestCase):
    
    def test_parse_pos_lines(self):
        """Parse pos lines should parse given lines and filename"""
        test_lines = \
        ['YPO0021 hemN    28982   28982..30355    1374\n',\
         'YPO0022 glnG, glnT, ntrC    30409   complement(30409..31821)    1413\n',\
         'YPO0023 glnL, ntrB  31829   complement(31829..32878)    1050\n',\
         'YPO0024 glnA    33131   complement(33131..34540)    1410\n']

        obs = parse_pos_lines(test_lines, file_name = 'y.pestis.pos')
        exp = ['y.pestis\tYPO0021 hemN    28982   28982..30355    1374\n',\
               'y.pestis\tYPO0022 glnG, glnT, ntrC    30409   complement(30409..31821)    1413\n',\
               'y.pestis\tYPO0023 glnL, ntrB  31829   complement(31829..32878)    1050\n',\
               'y.pestis\tYPO0024 glnA    33131   complement(33131..34540)    1410\n']

        for i,parsed_line in enumerate(obs):
            self.assertEqual(parsed_line, exp[i])
        
    def test_pos_to_fields(self):
        """parse_pos_to_fields should open files and extract fields"""
        # Note that this test is set to pass, as this is just a simple
        # open/yield wrapper equivalent to the demo blocks for other parsers.
        # It is kept as an independent function to allow calling by handlers.
        pass

if __name__=="__main__":
    main()