Ejemplo n.º 1
0
 def testOneIntervalEndingAfterHitEndCoverage(self):
     """
     If there is a single interval that ends after the end of the hit
     but doesn't start at zero, coverage should return the correct value.
     """
     ri = ReadIntervals(100)
     ri.add(50, 150)
     self.assertEqual(0.5, ri.coverage())
Ejemplo n.º 2
0
 def testOneIntervalCoveringAllExtendingLeftCoverage(self):
     """
     If there is a single interval that spans the whole hit, including
     going negative to the left, coverage should return 1.0.
     """
     ri = ReadIntervals(100)
     ri.add(-10, 100)
     self.assertEqual(1.0, ri.coverage())
Ejemplo n.º 3
0
 def testOneIntervalCoveringAllExtendingRightCoverage(self):
     """
     If there is a single interval that spans the whole hit, including
     going beyond the hit to the right, coverage should return 1.0.
     """
     ri = ReadIntervals(100)
     ri.add(0, 110)
     self.assertEqual(1.0, ri.coverage())
Ejemplo n.º 4
0
 def testOneIntervalEndingAfterHitEndCoverage(self):
     """
     If there is a single interval that ends after the end of the hit
     but doesn't start at zero, coverage should return the correct value.
     """
     ri = ReadIntervals(100)
     ri.add(50, 150)
     self.assertEqual(0.5, ri.coverage())
Ejemplo n.º 5
0
 def testOneIntervalStartingBeforeZeroCoverage(self):
     """
     If there is a single interval that starts before zero but doesn't
     cover the whole hit, coverage should return the correct value.
     """
     ri = ReadIntervals(100)
     ri.add(-50, 50)
     self.assertEqual(0.5, ri.coverage())
Ejemplo n.º 6
0
 def testOneIntervalExactCoveringCoverage(self):
     """
     If there is a single interval that spans the whole hit exactly,
     coverage should return 1.0.
     """
     ri = ReadIntervals(100)
     ri.add(0, 100)
     self.assertEqual(1.0, ri.coverage())
Ejemplo n.º 7
0
 def testOneIntervalStartingBeforeZeroCoverage(self):
     """
     If there is a single interval that starts before zero but doesn't
     cover the whole hit, coverage should return the correct value.
     """
     ri = ReadIntervals(100)
     ri.add(-50, 50)
     self.assertEqual(0.5, ri.coverage())
Ejemplo n.º 8
0
 def testOneIntervalCoveringAllExtendingRightCoverage(self):
     """
     If there is a single interval that spans the whole hit, including
     going beyond the hit to the right, coverage should return 1.0.
     """
     ri = ReadIntervals(100)
     ri.add(0, 110)
     self.assertEqual(1.0, ri.coverage())
Ejemplo n.º 9
0
 def testOneIntervalCoveringAllExtendingLeftCoverage(self):
     """
     If there is a single interval that spans the whole hit, including
     going negative to the left, coverage should return 1.0.
     """
     ri = ReadIntervals(100)
     ri.add(-10, 100)
     self.assertEqual(1.0, ri.coverage())
Ejemplo n.º 10
0
 def testOneIntervalExactCoveringCoverage(self):
     """
     If there is a single interval that spans the whole hit exactly,
     coverage should return 1.0.
     """
     ri = ReadIntervals(100)
     ri.add(0, 100)
     self.assertEqual(1.0, ri.coverage())
Ejemplo n.º 11
0
 def testOneIntervalCoveringAllExtendingBothCoverage(self):
     """
     If there is a single interval that spans the whole hit, including
     starting before zero and also going beyond the hit to the right,
     coverage should return 1.0
     """
     ri = ReadIntervals(100)
     ri.add(-10, 110)
     self.assertEqual(1.0, ri.coverage())
Ejemplo n.º 12
0
 def testOneIntervalCoveringAllExtendingBothCoverage(self):
     """
     If there is a single interval that spans the whole hit, including
     starting before zero and also going beyond the hit to the right,
     coverage should return 1.0
     """
     ri = ReadIntervals(100)
     ri.add(-10, 110)
     self.assertEqual(1.0, ri.coverage())
Ejemplo n.º 13
0
 def testTwoOverlappingIntervalsInMiddleCoverage(self):
     """
     If there are two overlapping intervals in the middle of the hit,
     coverage should return the correct value.
     """
     ri = ReadIntervals(100)
     ri.add(50, 60)
     ri.add(55, 70)
     self.assertEqual(0.2, ri.coverage())
Ejemplo n.º 14
0
    def testOneIntervalInMiddleCoverage(self):
        """
        If there is a single interval in the middle of the hit, coverage
        should return the correct value.

        """
        ri = ReadIntervals(100)
        ri.add(50, 60)
        self.assertEqual(0.1, ri.coverage())
Ejemplo n.º 15
0
    def testOneIntervalInMiddleCoverage(self):
        """
        If there is a single interval in the middle of the hit, coverage
        should return the correct value.

        """
        ri = ReadIntervals(100)
        ri.add(50, 60)
        self.assertEqual(0.1, ri.coverage())
Ejemplo n.º 16
0
 def testTwoOverlappingIntervalsInMiddleCoverage(self):
     """
     If there are two overlapping intervals in the middle of the hit,
     coverage should return the correct value.
     """
     ri = ReadIntervals(100)
     ri.add(50, 60)
     ri.add(55, 70)
     self.assertEqual(0.2, ri.coverage())
Ejemplo n.º 17
0
    def coverage(self):
        """
        Get the fraction of this title sequence that is matched by its reads.

        @return: The C{float} fraction of the title sequence matched by its
            reads.
        """
        intervals = ReadIntervals(self.subjectLength)
        for hsp in self.hsps():
            intervals.add(hsp.subjectStart, hsp.subjectEnd)
        return intervals.coverage()
Ejemplo n.º 18
0
    def coverage(self):
        """
        Get the fraction of this title sequence that is matched by its reads.

        @return: The C{float} fraction of the title sequence matched by its
            reads.
        """
        intervals = ReadIntervals(self.subjectLength)
        for hsp in self.hsps():
            intervals.add(hsp.subjectStart, hsp.subjectEnd)
        return intervals.coverage()
Ejemplo n.º 19
0
 def testPairOfTwoOverlappingIntervalsCoverage(self):
     """
     If there are two sets of two overlapping intervals in the middle of
     the hit, coverage should return the correct value.
     """
     ri = ReadIntervals(100)
     # First overlapping pair, 50-70.
     ri.add(50, 60)
     ri.add(55, 70)
     # First overlapping pair, 80-95.
     ri.add(80, 90)
     ri.add(85, 95)
     self.assertEqual(0.35, ri.coverage())
Ejemplo n.º 20
0
 def testPairOfTwoOverlappingIntervalsCoverage(self):
     """
     If there are two sets of two overlapping intervals in the middle of
     the hit, coverage should return the correct value.
     """
     ri = ReadIntervals(100)
     # First overlapping pair, 50-70.
     ri.add(50, 60)
     ri.add(55, 70)
     # First overlapping pair, 80-95.
     ri.add(80, 90)
     ri.add(85, 95)
     self.assertEqual(0.35, ri.coverage())
Ejemplo n.º 21
0
 def testOverlappingIntervalsThatCoverEverythingCoverage(self):
     """
     If there are sets of overlapping intervals that cover the whole hit,
     coverage should return the correct value.
     """
     ri = ReadIntervals(100)
     ri.add(-10, 20)
     ri.add(15, 40)
     ri.add(40, 70)
     ri.add(66, 89)
     ri.add(77, 93)
     ri.add(70, 110)
     self.assertEqual(1.0, ri.coverage())
Ejemplo n.º 22
0
 def testOverlappingIntervalsThatCoverEverythingCoverage(self):
     """
     If there are sets of overlapping intervals that cover the whole hit,
     coverage should return the correct value.
     """
     ri = ReadIntervals(100)
     ri.add(-10, 20)
     ri.add(15, 40)
     ri.add(40, 70)
     ri.add(66, 89)
     ri.add(77, 93)
     ri.add(70, 110)
     self.assertEqual(1.0, ri.coverage())
Ejemplo n.º 23
0
 def testEmptyCoverageOnZeroLengthSequence(self):
     """
     When no intervals are added, coverage should return 0.0
     """
     ri = ReadIntervals(0)
     self.assertEqual(0.0, ri.coverage())
Ejemplo n.º 24
0
 def testEmptyCoverage(self):
     """
     When no intervals are added, coverage should return 0.0
     """
     ri = ReadIntervals(100)
     self.assertEqual(0.0, ri.coverage())
Ejemplo n.º 25
0
 def testEmptyCoverageOnZeroLengthSequence(self):
     """
     When no intervals are added, coverage should return 0.0
     """
     ri = ReadIntervals(0)
     self.assertEqual(0.0, ri.coverage())
Ejemplo n.º 26
0
 def testEmptyCoverage(self):
     """
     When no intervals are added, coverage should return 0.0
     """
     ri = ReadIntervals(100)
     self.assertEqual(0.0, ri.coverage())