Beispiel #1
0
    def test_group_nucs_blank(self):
        output_file = StringIO("""\
sample,seed,region,query.nuc.pos,coverage
s1,R1-seed,R1,100,10
s1,R1-seed,R1,110,10
s1,R1-seed,R1,,0
""")
        expected_groups = dict(
            s1={
                ('R1-seed', 'R1'): [('x', {
                    'coverage': '10',
                    'query.nuc.pos': '100',
                    'region': 'R1',
                    'sample': 's1',
                    'seed': 'R1-seed'
                }),
                                    ('x', {
                                        'coverage': '10',
                                        'query.nuc.pos': '110',
                                        'region': 'R1',
                                        'sample': 's1',
                                        'seed': 'R1-seed'
                                    }),
                                    ('x', {
                                        'coverage': '0',
                                        'query.nuc.pos': '',
                                        'region': 'R1',
                                        'sample': 's1',
                                        'seed': 'R1-seed'
                                    })]
            })

        groups = group_nucs_file(output_file)

        self.assertEqual(expected_groups, groups)
    def test_group_nucs_single(self):
        output_file = StringIO("""\
sample,seed,region,query.nuc.pos
s1,R1-seed,R1,100
s1,R1-seed,R1,110
""")
        expected_groups = dict(s1={'R1-seed': [('R1', 100, 110)]})

        groups = group_nucs_file(output_file)

        self.assertEqual(expected_groups, groups)
    def test_group_nucs_single(self):
        output_file = StringIO("""\
sample,seed,region,query.nuc.pos
s1,R1-seed,R1,100
s1,R1-seed,R1,110
""")
        expected_groups = dict(s1={'R1-seed': [('R1', 100, 110)]})

        groups = group_nucs_file(output_file)

        self.assertEqual(expected_groups, groups)
    def test_group_nucs_two_regions(self):
        output_file = StringIO("""\
sample,seed,region,query.nuc.pos
s1,R1-seed,R1a,100
s1,R1-seed,R1a,110
s1,R1-seed,R1b,201
s1,R1-seed,R1b,211
""")
        expected_groups = dict(
            s1={'R1-seed': [('R1a', 100, 110), ('R1b', 201, 211)]})

        groups = group_nucs_file(output_file)

        self.assertEqual(expected_groups, groups)
    def test_group_nucs_two_regions(self):
        output_file = StringIO("""\
sample,seed,region,query.nuc.pos
s1,R1-seed,R1a,100
s1,R1-seed,R1a,110
s1,R1-seed,R1b,201
s1,R1-seed,R1b,211
""")
        expected_groups = dict(s1={'R1-seed': [('R1a', 100, 110),
                                               ('R1b', 201, 211)]})

        groups = group_nucs_file(output_file)

        self.assertEqual(expected_groups, groups)
Beispiel #6
0
    def test_group_nucs_with_coverage(self):
        output_file = StringIO("""\
sample,seed,region,query.nuc.pos,A,C,G,T,del,ins,coverage
s1,R1-seed,R1,100,100,0,0,0,0,0,100
s1,R1-seed,R1,101,99,1,0,0,0,0,100
s1,R1-seed,R1,102,1,99,0,0,0,0,100
s1,R1-seed,R1,103,0,99,0,0,0,0,99
""")
        expected_groups = dict(
            s1={
                ('R1-seed', 'R1'): [('A', {
                    'A': '100',
                    'C': '0',
                    'G': '0',
                    'T': '0',
                    'coverage': '100',
                    'del': '0',
                    'ins': '0',
                    'query.nuc.pos': '100',
                    'region': 'R1',
                    'sample': 's1',
                    'seed': 'R1-seed'
                }),
                                    ('A', {
                                        'A': '99',
                                        'C': '1',
                                        'G': '0',
                                        'T': '0',
                                        'coverage': '100',
                                        'del': '0',
                                        'ins': '0',
                                        'query.nuc.pos': '101',
                                        'region': 'R1',
                                        'sample': 's1',
                                        'seed': 'R1-seed'
                                    }),
                                    ('C', {
                                        'A': '1',
                                        'C': '99',
                                        'G': '0',
                                        'T': '0',
                                        'coverage': '100',
                                        'del': '0',
                                        'ins': '0',
                                        'query.nuc.pos': '102',
                                        'region': 'R1',
                                        'sample': 's1',
                                        'seed': 'R1-seed'
                                    }),
                                    ('x', {
                                        'A': '0',
                                        'C': '99',
                                        'G': '0',
                                        'T': '0',
                                        'coverage': '99',
                                        'del': '0',
                                        'ins': '0',
                                        'query.nuc.pos': '103',
                                        'region': 'R1',
                                        'sample': 's1',
                                        'seed': 'R1-seed'
                                    })]
            })

        groups = group_nucs_file(output_file)

        self.assertEqual(expected_groups, groups)