예제 #1
0
    def test_upstream(self):
        iv = self.intervals
        upstreams = iv.upstream_of_interval(IntervalObj(59, 60),
                                            num_intervals=200)

        for u in upstreams:
            self.assertTrue(u.end < 59)

        upstreams = iv.upstream_of_interval(IntervalObj(60, 70, strand=-1),
                                            num_intervals=200)
        for u in upstreams:
            self.assertTrue(u.start > 70)

        upstreams = iv.upstream_of_interval(IntervalObj(58, 58, strand=-1),
                                            num_intervals=200)
        for u in upstreams:
            self.assertTrue(u.start > 59)
예제 #2
0
    def setUp(self):
        iv = IntervalTree()
        n = 0
        for i in range(1, 1000, 80):
            iv.insert(i, i + 10, dict(value=i * i))
            # add is synonym for insert.
            iv.add(i + 20, i + 30, dict(astr=str(i * i)))

            # or insert/add an interval object with start, end attrs.
            iv.insert_interval(
                IntervalObj(i + 40, i + 50, value=dict(astr=str(i * i))))
            iv.add_interval(
                IntervalObj(i + 60, i + 70, value=dict(astr=str(i * i))))

            n += 4
        self.intervals = self.iv = iv
        self.nintervals = n
예제 #3
0
    def test_n(self):
        iv = self.intervals
        for i in range(0, 90, 10):
            r = iv.after(i, max_dist=20, num_intervals=2)
            self.assertEqual(r[0].start, i + 10)
            self.assertEqual(r[1].start, i + 20)

            r = iv.after_interval(IntervalObj(i, i),
                                  max_dist=20, num_intervals=2)
            self.assertEqual(r[0].start, i + 10)
            self.assertEqual(r[1].start, i + 20)