コード例 #1
0
    def test_intersec_segments(self):
        'It test the segment intersection'
        coord = CoordSystem(relations=[])

        limits1 = [(0, 2)]
        limits2 = [(2, 8)]
        expected = [(0, 1), (2, 2), (3, 8)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(1, 10)]
        limits2 = [(5, 6)]
        expected = [(1, 4), (5, 6), (7, 10)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(1, 10)]
        limits2 = [(1, 10)]
        expected = [(1, 10)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(1, 10)]
        limits2 = [(2, 9)]
        expected = [(1, 1), (2, 9), (10, 10)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(4, 12)]
        limits2 = [(6, 8)]
        expected = [(4, 5), (6, 8), (9, 12)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(4, 8)]
        limits2 = [(6, 12)]
        expected = [(4, 5), (6, 8), (9, 12)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(0, 8)]
        limits2 = [(0, 12)]
        expected = [(0, 8), (9, 12)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(0, 8)]
        limits2 = [(2, 8)]
        expected = [(0, 1), (2, 8)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(0, 2)]
        limits2 = [(3, 8)]
        expected = [(0, 2), (3, 8)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(0, 2)]
        limits2 = [(4, 8)]
        expected = [(0, 2), (4, 8)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(0, 12)]
        limits2 = [(2, 5), (8, 11)]
        expected = [(0, 1), (2, 5), (6, 7), (8, 11), (12, 12)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(12, 0)]
        limits2 = [(12, 0)]
        expected = [(12, 0)]
        assert coord._intersec_segments(limits1, limits2) == expected

        limits1 = [(12, 6), (5, 0)]
        limits2 = [(13, 7)]
        expected = [(13, 13), (12, 7), (6, 6), (5, 0)]
        assert coord._intersec_segments(limits1, limits2) == expected

        #cdna     876  543210
        #prot      54  3210
        limits1 = [(8, 6), (5, 0)]
        limits2 = [(7, 2)]
        expected = [(8, 8), (7, 6), (5, 2), (1, 0)]
        assert coord._intersec_segments(limits1, limits2) == expected