File: test_mothur.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 (35 lines) | stat: -rw-r--r-- 985 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
#!/usr/bin/env python
#file cogent.parse.mothur.py

__author__ = "Kyle Bittinger"
__copyright__ = "Copyright 2007-2012, The Cogent Project"
__credits__ = ["Kyle Bittinger"]
__license__ = "GPL"
__version__ = "1.5.3"
__maintainer__ = "Kyle Bittinger"
__email__ = "kylebittinger@gmail.com"
__status__ = "Prototype"

from cStringIO import StringIO

from cogent.util.unit_test import TestCase, main
from cogent.parse.mothur import parse_otu_list

class FunctionTests(TestCase):
    def test_parse_otu_list(self):
        observed = list(parse_otu_list(StringIO(mothur_output)))
        expected = [
            (0.0, [['cccccc'], ['bbbbbb'], ['aaaaaa']]),
            (0.62, [['bbbbbb', 'cccccc'], ['aaaaaa']]),
            (0.67000000000000004, [['aaaaaa', 'bbbbbb', 'cccccc']])
            ]
        self.assertEqual(observed, expected)

mothur_output = """\
unique	3	cccccc	bbbbbb	aaaaaa
0.62	2	bbbbbb,cccccc	aaaaaa
0.67	1	aaaaaa,bbbbbb,cccccc
"""

if __name__ == '__main__':
    main()