File: test_adjust_seq_orientation.py

package info (click to toggle)
qiime 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 29,704 kB
  • sloc: python: 77,837; haskell: 379; sh: 113; makefile: 103
file content (89 lines) | stat: -rwxr-xr-x 2,408 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
#!/usr/bin/env python
# File created on 07 Oct 2009.
from __future__ import division

__author__ = "Greg Caporaso"
__copyright__ = "Copyright 2011, The QIIME Project"
__credits__ = ["Greg Caporaso"]
__license__ = "GPL"
__version__ = "1.4.0"
__maintainer__ = "Greg Caporaso"
__email__ = "gregcaporaso@gmail.com"
__status__ = "Release"


from unittest import TestCase, main
from cogent.parse.fasta import MinimalFastaParser
from qiime.adjust_seq_orientation import rc_fasta_lines, null_seq_desc_mapper,\
    append_rc
    
class AdjustSeqOrientationTests(TestCase):
    """ """
    
    def setUp(self):
        """ """
        self.fasta_lines1 = fasta_lines1.split('\n')
        self.fasta_lines1_mixed_case = fasta_lines1_mixed_case.split('\n')
        
        self.fasta_lines1_exp = list(MinimalFastaParser(
            fasta_lines1_exp.split('\n')))
        self.fasta_lines1_mixed_case_exp = list(MinimalFastaParser(
         fasta_lines1_mixed_case_exp.split('\n')))
        self.fasta_lines1_exp_null_desc_mapper = list(MinimalFastaParser(
            fasta_lines1_exp_null_desc_mapper.split('\n')))
            
    def test_rc_fasta_lines(self):
        """rc_fasta_lines: functions as expected w/ seq_id mapping 
        """
        self.assertEqual(list(rc_fasta_lines(self.fasta_lines1,append_rc)),
                         self.fasta_lines1_exp)
            
    def test_rc_fasta_lines_mixed_case(self):
        """rc_fasta_lines: functions with mixed cases in sequences
        """
        self.assertEqual(list(
         rc_fasta_lines(self.fasta_lines1_mixed_case,append_rc)),
         self.fasta_lines1_mixed_case_exp)
            
    def test_rc_fasta_lines_leave_seq_desc(self):
        """rc_fasta_lines: functions as expected w/o seq_id mapping 
        """
        self.assertEqual(list(
         rc_fasta_lines(self.fasta_lines1,null_seq_desc_mapper)),
                         self.fasta_lines1_exp_null_desc_mapper)


fasta_lines1 = """>s1 some description
AAATGGCGCGCG
>s2
TTATATCCGC
"""

fasta_lines1_mixed_case = """>s1 some description
aaatGGcgcgcg
>s2
ttatatccgc
"""

fasta_lines1_exp = """>s1 some description RC
CGCGCGCCATTT
>s2 RC
GCGGATATAA
"""

fasta_lines1_mixed_case_exp = """>s1 some description RC
CGCGCGCCATTT
>s2 RC
GCGGATATAA
"""

fasta_lines1_exp_null_desc_mapper = """>s1 some description
CGCGCGCCATTT
>s2
GCGGATATAA
"""



if __name__ == "__main__":
    main()