1 | """ |
---|
2 | Tests for `bx.align.lav`. |
---|
3 | """ |
---|
4 | |
---|
5 | import unittest |
---|
6 | import sys |
---|
7 | import bx.align as align |
---|
8 | import bx.align.lav as lav |
---|
9 | |
---|
10 | test_lav = "test_data/lav_tests/apple_orange.lav" |
---|
11 | |
---|
12 | class lavTestCase(unittest.TestCase): |
---|
13 | |
---|
14 | def testReader(self): |
---|
15 | |
---|
16 | reader = lav.Reader(file(test_lav)) |
---|
17 | |
---|
18 | a = reader.next() |
---|
19 | assert a.score == 10286, "a.score is wrong: %s" % a.score |
---|
20 | assert len(a.components) == 2 |
---|
21 | check_component(a.components[0], "apple", 106, 252, "+", 411, "GTCCGGCCGGCTGAGAGCTACAATACACATGCACGCAGTTTGGCCACTCACATTAAGTATATGAGGAAGGGTTAGCATGAGTTGTACTATAAGGCAGCGGATAGCAGGTTGTGGAAAAATATCCTCCCGATTCAAATCCCCAGGTGCCTAAA----------------GTAGGGCCGGTAGTTGAATGCTTGCCTGTCAGACTGGATGACCAAGTTCAGTATCAACACAATATAGTGCCAGGAGCTAATTGTTCCCCAGCAGCGTGAC") |
---|
22 | check_component(a.components[1], "lav_tests.orange", 53, 252, "+", 361, "GTCCGGCCGGCTGTGTGCTACAATACACGTTCACGCAGTTTGGCCAATCACTTTAAGTATATACGAAATGGTTACCATGAGTTGTACTGTAAGGCAGCGGAAAGC---TTGTTAA--------CTCCTGGGCGACATT----GGGGCTGCAACATCGTTTATCCTCCTCTACAACCAATAGCTG-TTGCTTCTTGGTTCAAGTATATCCCATGGATTAGTATCAACACGATATAGTGTCAGGAGCTAATTGTTCCCCAGCAGCGTGAC") |
---|
23 | |
---|
24 | a = reader.next() |
---|
25 | assert a.score == 3586, "a.score is wrong: %s" % a.score |
---|
26 | assert len(a.components) == 2 |
---|
27 | check_component(a.components[0], "apple", 52, 72, "+", 411, "TGCATATCGACTATTACAGCCACGCGAGTTACATTCCTCTTTTTTTTTGCTGGCGTCCGGCCGGCTGAGAGC") |
---|
28 | check_component(a.components[1], "lav_tests.orange", 2, 72, "-", 361, "TGCATATCGACTAGTACAGCCTCTCGAGTTACCCCCCCCATTCCTCTTGCTGACGTCACGCTGCTGGGGAAC") |
---|
29 | |
---|
30 | a = reader.next() |
---|
31 | assert a is None |
---|
32 | |
---|
33 | reader.close() |
---|
34 | |
---|
35 | def check_component( c, src, start, size, strand, src_size, text ): |
---|
36 | #..print "\"%s\" == \"%s\"" % (c.src,src) |
---|
37 | assert c.src == src, "c.src = %s (expected %s)" % (c.src, src) |
---|
38 | assert c.start == start, "c.start = %s (expected %s)" % (c.start, start) |
---|
39 | assert c.size == size, "c.size = %s (expected %s)" % (c.size, size) |
---|
40 | assert c.strand == strand, "c.strand = %s (expected %s)" % (c.strand, strand) |
---|
41 | assert c.src_size == src_size, "c.src_size = %s (expected %s)" % (c.src_size,src_size) |
---|
42 | assert c.text == text, "c.text = \"%s\" (expected \"%s\")" % (c.text, text) |
---|
43 | |
---|
44 | test_classes = [ lavTestCase ] |
---|
45 | suite = unittest.TestSuite([ unittest.makeSuite(c) for c in test_classes ]) |
---|