コード例 #1
0
ファイル: test_Intervals.py プロジェクト: pezmaster31/pbbam
    def test_copy(self):

        a = PacBioBam.GenomicInterval("foo", 10, 20)
        b = PacBioBam.GenomicInterval(a)
        c = a

        self.assertEqual(a, a)
        self.assertEqual(a, b)
        self.assertEqual(a, c)
コード例 #2
0
ファイル: test_Intervals.py プロジェクト: pezmaster31/pbbam
    def test_ctors(self):

        empty = PacBioBam.GenomicInterval()
        normal = PacBioBam.GenomicInterval("foo", 100, 200)

        self.assertEqual("", empty.Name())
        self.assertEqual(0, empty.Start())
        self.assertEqual(0, empty.Stop())

        self.assertEqual("foo", normal.Name())
        self.assertEqual(100, normal.Start())
        self.assertEqual(200, normal.Stop())
コード例 #3
0
ファイル: test_Intervals.py プロジェクト: pezmaster31/pbbam
    def test_modifiers(self):

        a = PacBioBam.GenomicInterval("foo", 10, 20)

        b = PacBioBam.GenomicInterval(a)
        b.Name("bar").Start(2).Stop(10)

        c = PacBioBam.GenomicInterval(a)
        c.Interval(b.Interval())

        self.assertNotEqual(a, b)
        self.assertEqual("bar", b.Name())
        self.assertEqual(2, b.Start())
        self.assertEqual(10, b.Stop())
        self.assertEqual(a.Name(), c.Name())
        self.assertEqual(b.Interval(), c.Interval())
コード例 #4
0
ファイル: test_Intervals.py プロジェクト: pezmaster31/pbbam
    def test_cover(self):

        a = PacBioBam.GenomicInterval("foo", 2, 4)
        b = PacBioBam.GenomicInterval("foo", 3, 5)
        c = PacBioBam.GenomicInterval("foo", 6, 8)
        d = PacBioBam.GenomicInterval("foo", 1, 7)
        e = PacBioBam.GenomicInterval("foo", 5, 8)
        f = PacBioBam.GenomicInterval("bar", 3, 5)  # same as b, different ref

        #   0123456789
        # a   --
        # b    --
        # c       --
        # d  ------
        # e      ---

        # self-cover
        self.assertTrue(a.Covers(a))
        self.assertTrue(a.CoveredBy(a))

        # basic covers/covered
        self.assertTrue(b.CoveredBy(d))
        self.assertTrue(d.Covers(b))
        self.assertNotEqual(b, d)
        self.assertFalse(b.Covers(d))

        # same coords as b, but different ref
        self.assertFalse(f.CoveredBy(d))
        self.assertFalse(d.Covers(f))
        self.assertNotEqual(f, d)
        self.assertFalse(f.Covers(d))

        # obvious disjoint
        self.assertFalse(b.Covers(c))
        self.assertFalse(c.Covers(b))
        self.assertFalse(b.CoveredBy(c))
        self.assertFalse(c.CoveredBy(b))

        # b.stop == e.start (intervals are right-open, so disjoint)
        self.assertFalse(b.Covers(e))
        self.assertFalse(b.CoveredBy(e))

        # shared endpoint, start contained
        self.assertTrue(e.Covers(c))
        self.assertTrue(c.CoveredBy(e))
コード例 #5
0
ファイル: test_Intervals.py プロジェクト: pezmaster31/pbbam
    def test_validity(self):

        a = PacBioBam.GenomicInterval()  # default
        b = PacBioBam.GenomicInterval("foo", 0,
                                      0)  # valid id, start == stop (zero)
        c = PacBioBam.GenomicInterval("foo", 4,
                                      4)  # valid id, start == stop (non-zero)
        d = PacBioBam.GenomicInterval(
            "foo", 0, 1)  # valid id, start <  stop (start == zero)     OK
        e = PacBioBam.GenomicInterval(
            "foo", 4, 5)  # valid id, start <  stop (start >  zero)     OK
        f = PacBioBam.GenomicInterval("foo", 5, 4)  # valid id, start >  stop
        g = PacBioBam.GenomicInterval("", 0,
                                      0)  # invalid id, start == stop (zero)
        h = PacBioBam.GenomicInterval(
            "", 4, 4)  # invalid id, start == stop (non-zero)
        i = PacBioBam.GenomicInterval(
            "", 0, 1)  # invalid id, start <  stop (start == zero)
        j = PacBioBam.GenomicInterval(
            "", 4, 5)  # invalid id, start <  stop (start >  zero)
        k = PacBioBam.GenomicInterval("", 5, 4)  # invalid id, start >  stop

        self.assertTrue(d.IsValid())
        self.assertTrue(e.IsValid())
        self.assertFalse(a.IsValid())
        self.assertFalse(b.IsValid())
        self.assertFalse(c.IsValid())
        self.assertFalse(f.IsValid())
        self.assertFalse(g.IsValid())
        self.assertFalse(h.IsValid())
        self.assertFalse(i.IsValid())
        self.assertFalse(j.IsValid())
        self.assertFalse(k.IsValid())