Пример #1
0
 def testEmpty(self):
     """
     When no intervals are given, the reduction should be for the full hit
     width.
     """
     adjuster = OffsetAdjuster()
     self.assertEqual([], adjuster.adjustments())
     self.assertEqual(0, adjuster.adjustOffset(0))
Пример #2
0
 def testEmpty(self):
     """
     When no intervals are given, the reduction should be for the full hit
     width.
     """
     adjuster = OffsetAdjuster()
     self.assertEqual([], adjuster.adjustments())
     self.assertEqual(0, adjuster.adjustOffset(0))
Пример #3
0
 def testNoReads(self):
     """
     When no reads are added to an interval, the reduction should be for
     the full hit width.
     """
     ri = ReadIntervals(64)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([(64, 58)], adjuster.adjustments())
     self.assertEqual(6, adjuster.adjustOffset(64))
Пример #4
0
 def testNoReads(self):
     """
     When no reads are added to an interval, the reduction should be for
     the full hit width.
     """
     ri = ReadIntervals(64)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([(64, 58)], adjuster.adjustments())
     self.assertEqual(6, adjuster.adjustOffset(64))
Пример #5
0
 def testOneReadThatExceedsHitOnBothEnds(self):
     """
     When one read is given that exceeds the hit at both ends, there should
     be no length reductions.
     """
     ri = ReadIntervals(106)
     ri.add(-100, 200)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([], adjuster.adjustments())
     self.assertEqual(106, adjuster.adjustOffset(106))
Пример #6
0
 def testOneReadThatExactlyCoversHit(self):
     """
     When one read is given that exactly covers the hit, there should
     be no length reductions.
     """
     ri = ReadIntervals(106)
     ri.add(0, 106)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([], adjuster.adjustments())
     self.assertEqual(106, adjuster.adjustOffset(106))
Пример #7
0
 def testOneReadInMiddle(self):
     """
     When one read is added to the middle of an interval, there should be
     two reductions.
     """
     ri = ReadIntervals(106)
     ri.add(32, 42)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([(32, 27), (106, 58)], adjuster.adjustments())
     self.assertEqual(106 - 27 - 58, adjuster.adjustOffset(106))
Пример #8
0
 def testOneReadAtEnd(self):
     """
     When one read is added to the end of an interval, there should be one
     reduction for the empty section before the read.
     """
     ri = ReadIntervals(228)
     ri.add(128, 228)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([(128, 121)], adjuster.adjustments())
     self.assertEqual(107, adjuster.adjustOffset(228))
Пример #9
0
 def testOneReadBeforeStart(self):
     """
     When one read is added to the start of an interval before zero, there
     should be one reduction for the empty section after the read.
     """
     ri = ReadIntervals(228)
     ri.add(-10, 100)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([(228, 121)], adjuster.adjustments())
     self.assertEqual(107, adjuster.adjustOffset(228))
Пример #10
0
 def testOneReadThatExceedsHitOnBothEnds(self):
     """
     When one read is given that exceeds the hit at both ends, there should
     be no length reductions.
     """
     ri = ReadIntervals(106)
     ri.add(-100, 200)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([], adjuster.adjustments())
     self.assertEqual(106, adjuster.adjustOffset(106))
Пример #11
0
 def testOneReadThatExactlyCoversHit(self):
     """
     When one read is given that exactly covers the hit, there should
     be no length reductions.
     """
     ri = ReadIntervals(106)
     ri.add(0, 106)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([], adjuster.adjustments())
     self.assertEqual(106, adjuster.adjustOffset(106))
Пример #12
0
 def testOneReadAtEnd(self):
     """
     When one read is added to the end of an interval, there should be one
     reduction for the empty section before the read.
     """
     ri = ReadIntervals(228)
     ri.add(128, 228)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([
         (128, 121),
     ], adjuster.adjustments())
     self.assertEqual(107, adjuster.adjustOffset(228))
Пример #13
0
 def testOneReadBeforeStart(self):
     """
     When one read is added to the start of an interval before zero, there
     should be one reduction for the empty section after the read.
     """
     ri = ReadIntervals(228)
     ri.add(-10, 100)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([
         (228, 121),
     ], adjuster.adjustments())
     self.assertEqual(107, adjuster.adjustOffset(228))
Пример #14
0
    def testTwoReadsInMiddle(self):
        """
        When two reads are added to the middle of an interval, there should be
        three reductions (after first empty area, after 2nd empty area, after
        final empty area.
        """
        ri = ReadIntervals(132)
        ri.add(32, 42)
        ri.add(58, 68)
        adjuster = OffsetAdjuster(ri)
        self.assertEqual([
            (32, 27),
            (58, 12),
            (132, 58),
        ], adjuster.adjustments())
        self.assertEqual(132 - 27 - 12 - 58, adjuster.adjustOffset(132))

        # Test an HSP at the beginning is unchanged.
        hsp = HSP(10,
                  readEndInSubject=10,
                  readStartInSubject=0,
                  subjectEnd=10,
                  subjectStart=0)
        adjuster.adjustHSP(hsp)
        self.assertEqual(10, hsp.readEndInSubject)
        self.assertEqual(0, hsp.readStartInSubject)
        self.assertEqual(10, hsp.subjectEnd)
        self.assertEqual(0, hsp.subjectStart)

        # Test an HSP in the first read region.
        hsp = HSP(10,
                  readEndInSubject=42,
                  readStartInSubject=32,
                  subjectEnd=40,
                  subjectStart=35)
        adjuster.adjustHSP(hsp)
        self.assertEqual(15, hsp.readEndInSubject)
        self.assertEqual(5, hsp.readStartInSubject)
        self.assertEqual(13, hsp.subjectEnd)
        self.assertEqual(8, hsp.subjectStart)

        # Test an HSP in the second read region.
        hsp = HSP(10,
                  readEndInSubject=68,
                  readStartInSubject=58,
                  subjectEnd=66,
                  subjectStart=60)
        adjuster.adjustHSP(hsp)
        self.assertEqual(29, hsp.readEndInSubject)
        self.assertEqual(19, hsp.readStartInSubject)
        self.assertEqual(27, hsp.subjectEnd)
        self.assertEqual(21, hsp.subjectStart)
Пример #15
0
 def testOneReadInMiddle(self):
     """
     When one read is added to the middle of an interval, there should be
     two reductions.
     """
     ri = ReadIntervals(106)
     ri.add(32, 42)
     adjuster = OffsetAdjuster(ri)
     self.assertEqual([
         (32, 27),
         (106, 58),
     ], adjuster.adjustments())
     self.assertEqual(106 - 27 - 58, adjuster.adjustOffset(106))
Пример #16
0
    def testTwoReadsInMiddle(self):
        """
        When two reads are added to the middle of an interval, there should be
        three reductions (after first empty area, after 2nd empty area, after
        final empty area.
        """
        ri = ReadIntervals(132)
        ri.add(32, 42)
        ri.add(58, 68)
        adjuster = OffsetAdjuster(ri)
        self.assertEqual(
            [
                (32, 27),
                (58, 12),
                (132, 58),
            ],
            adjuster.adjustments())
        self.assertEqual(132 - 27 - 12 - 58, adjuster.adjustOffset(132))

        # Test an HSP at the beginning is unchanged.
        hsp = HSP(10, readEndInSubject=10, readStartInSubject=0,
                  subjectEnd=10, subjectStart=0)
        adjuster.adjustHSP(hsp)
        self.assertEqual(10, hsp.readEndInSubject)
        self.assertEqual(0, hsp.readStartInSubject)
        self.assertEqual(10, hsp.subjectEnd)
        self.assertEqual(0, hsp.subjectStart)

        # Test an HSP in the first read region.
        hsp = HSP(10, readEndInSubject=42, readStartInSubject=32,
                  subjectEnd=40, subjectStart=35)
        adjuster.adjustHSP(hsp)
        self.assertEqual(15, hsp.readEndInSubject)
        self.assertEqual(5, hsp.readStartInSubject)
        self.assertEqual(13, hsp.subjectEnd)
        self.assertEqual(8, hsp.subjectStart)

        # Test an HSP in the second read region.
        hsp = HSP(10, readEndInSubject=68, readStartInSubject=58,
                  subjectEnd=66, subjectStart=60)
        adjuster.adjustHSP(hsp)
        self.assertEqual(29, hsp.readEndInSubject)
        self.assertEqual(19, hsp.readStartInSubject)
        self.assertEqual(27, hsp.subjectEnd)
        self.assertEqual(21, hsp.subjectStart)