This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
/
test_make_library_id_lists.py
56 lines (50 loc) · 1.9 KB
/
test_make_library_id_lists.py
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
#!/usr/bin/env python
from unittest import TestCase, main
from qiime.make_library_id_lists import (get_ids, get_first_id)
"""Tests of the make_library_id_lists.py file.
"""
__author__ = "Rob Knight"
__copyright__ = "Copyright 2011, The QIIME Project"
# remember to add yourself if you make changes
__credits__ = ["Rob Knight"]
__license__ = "GPL"
__version__ = "1.9.1-dev"
__maintainer__ = "Kyle Bittinger"
__email__ = "kylebittinger@gmail.com"
class TopLevelTests(TestCase):
"""Top-level tests of functions in make_library_id_lists.py"""
def test_get_ids(self):
"""get_ids should identify which ids are in which library"""
lines = """>S74_1 E86FECS01CEVAV orig_bc=ACATGTCACGTG new_bc=ACATGTCACGTG bc_diffs=0
CTCCTC
>Unassigned_2 E86FECS01EKKMF orig_bc=AGCGCTGATGTA new_bc=None bc_diffs=1
GGTGCCTCCCTCGC
>S80_3 E86FECS01EKKMF orig_bc=AGCGCTGATGTA new_bc=None bc_diffs=1
GGTGCCTCCCTCGC
>S80_4 E86FECS01CW66X orig_bc=AGTCCATAGCTG new_bc=AGTCCATAGCTG bc_diffs=0
GTCCTGGCAG""".splitlines()
result = get_ids(lines, 1)
self.assertEqual(
dict(result),
{'S74': ['E86FECS01CEVAV'],
'Unassigned': ['E86FECS01EKKMF'],
'S80': ['E86FECS01EKKMF',
'E86FECS01CW66X']})
def test_get_first_id(self):
"""get_first_id should identify first id in fasta file"""
lines = """>S74_1 E86FECS01CEVAV orig_bc=ACATGTCACGTG new_bc=ACATGTCACGTG bc_diffs=0
CTCCTC
>Unassigned_2 E86FECS01EKKMF orig_bc=AGCGCTGATGTA new_bc=None bc_diffs=1
GGTGCCTCCCTCGC
>S80_3 E86FECS01EKKMF orig_bc=AGCGCTGATGTA new_bc=None bc_diffs=1
GGTGCCTCCCTCGC
>S80_4 E86FECS01CW66X orig_bc=AGTCCATAGCTG new_bc=AGTCCATAGCTG bc_diffs=0
GTCCTGGCAG""".splitlines()
self.assertEqual(
get_first_id(lines),
set(['S74_1',
'Unassigned_2',
'S80_3',
'S80_4']))
if __name__ == '__main__':
main()