File: lav_tests.py

package info (click to toggle)
python-bx 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,000 kB
  • sloc: python: 17,136; ansic: 2,326; makefile: 24; sh: 8
file content (73 lines) | stat: -rw-r--r-- 2,487 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
"""
Tests for `bx.align.lav`.
"""

import unittest

import bx.align.lav as lav

test_lav = "test_data/lav_tests/apple_orange.lav"


class lavTestCase(unittest.TestCase):
    def testReader(self):
        reader = lav.Reader(open(test_lav))

        a = next(reader)
        assert a.score == 10286, f"a.score is wrong: {a.score}"
        assert len(a.components) == 2
        check_component(
            a.components[0],
            "apple",
            106,
            252,
            "+",
            411,
            "GTCCGGCCGGCTGAGAGCTACAATACACATGCACGCAGTTTGGCCACTCACATTAAGTATATGAGGAAGGGTTAGCATGAGTTGTACTATAAGGCAGCGGATAGCAGGTTGTGGAAAAATATCCTCCCGATTCAAATCCCCAGGTGCCTAAA----------------GTAGGGCCGGTAGTTGAATGCTTGCCTGTCAGACTGGATGACCAAGTTCAGTATCAACACAATATAGTGCCAGGAGCTAATTGTTCCCCAGCAGCGTGAC",
        )
        check_component(
            a.components[1],
            "lav_tests.orange",
            53,
            252,
            "+",
            361,
            "GTCCGGCCGGCTGTGTGCTACAATACACGTTCACGCAGTTTGGCCAATCACTTTAAGTATATACGAAATGGTTACCATGAGTTGTACTGTAAGGCAGCGGAAAGC---TTGTTAA--------CTCCTGGGCGACATT----GGGGCTGCAACATCGTTTATCCTCCTCTACAACCAATAGCTG-TTGCTTCTTGGTTCAAGTATATCCCATGGATTAGTATCAACACGATATAGTGTCAGGAGCTAATTGTTCCCCAGCAGCGTGAC",
        )

        a = next(reader)
        assert a.score == 3586, f"a.score is wrong: {a.score}"
        assert len(a.components) == 2
        check_component(
            a.components[0],
            "apple",
            52,
            72,
            "+",
            411,
            "TGCATATCGACTATTACAGCCACGCGAGTTACATTCCTCTTTTTTTTTGCTGGCGTCCGGCCGGCTGAGAGC",
        )
        check_component(
            a.components[1],
            "lav_tests.orange",
            2,
            72,
            "-",
            361,
            "TGCATATCGACTAGTACAGCCTCTCGAGTTACCCCCCCCATTCCTCTTGCTGACGTCACGCTGCTGGGGAAC",
        )

        a = next(reader)
        assert a is None

        reader.close()


def check_component(c, src, start, size, strand, src_size, text):
    # ..print "\"%s\" == \"%s\"" % (c.src,src)
    assert c.src == src, f"c.src = {c.src} (expected {src})"
    assert c.start == start, f"c.start = {c.start} (expected {start})"
    assert c.size == size, f"c.size = {c.size} (expected {size})"
    assert c.strand == strand, f"c.strand = {c.strand} (expected {strand})"
    assert c.src_size == src_size, f"c.src_size = {c.src_size} (expected {src_size})"
    assert c.text == text, f'c.text = "{c.text}" (expected "{text}")'