def testEmptyCoverageCounts(self): """ When no intervals are added, coverageCounts should return an empty Counter. """ ri = ReadIntervals(100) self.assertEqual({}, ri.coverageCounts())
def testEmptyCoverageCountsOnZeroLengthSequence(self): """ When no intervals are added, coverageCounts should return an empty Counter. """ ri = ReadIntervals(0) self.assertEqual({}, ri.coverageCounts())
def coverageCounts(self): """ For each location in the title sequence, return a count of how many times that location is covered by a read. """ intervals = ReadIntervals(self.subjectLength) for hsp in self.hsps(): intervals.add(hsp.subjectStart, hsp.subjectEnd) return intervals.coverageCounts()
def coverageCounts(self): """ For each location in the title sequence, return a count of how many times that location is covered by a read. """ intervals = ReadIntervals(self.subjectLength) for hsp in self.hsps(): intervals.add(hsp.subjectStart, hsp.subjectEnd) return intervals.coverageCounts()
def testOneIntervalInMiddleCoverageCounts(self): """ If there is a single interval in the middle of the hit, coverageCounts should return the correct result. """ ri = ReadIntervals(10) ri.add(5, 6) c = Counter([5]) self.assertEqual(c, ri.coverageCounts())
def testOneIntervalStartingAtZeroCoverageCounts(self): """ If there is a single interval that starts at zero but doesn't cover the whole hit, coverageCounts should return the correct result. """ ri = ReadIntervals(10) ri.add(0, 5) c = Counter([0, 1, 2, 3, 4]) self.assertEqual(c, ri.coverageCounts())
def testOneIntervalExactCoveringCoverageCounts(self): """ If there is a single interval that spans the whole hit exactly, coverageCounts should return the correct result. """ ri = ReadIntervals(10) ri.add(0, 10) c = Counter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) self.assertEqual(c, ri.coverageCounts())
def testTwoOverlappingIntervalsInMiddleCoverageCounts(self): """ If there are two overlapping intervals in the middle of the hit, coverageCounts should return the correct result. """ ri = ReadIntervals(10) ri.add(5, 7) ri.add(6, 8) c = Counter([5, 6, 6, 7]) self.assertEqual(c, ri.coverageCounts())
def testOneIntervalEndingAtHitEndCoverageCounts(self): """ If there is a single interval that ends at the end of the hit but doesn't start at zero, coverageCounts should return the correct result. """ ri = ReadIntervals(10) ri.add(5, 10) c = Counter([5, 6, 7, 8, 9]) self.assertEqual(c, ri.coverageCounts())
def testOneIntervalCoveringAllExtendingRightCoverageCounts(self): """ If there is a single interval that spans the whole hit, including going beyond the hit to the right, coverageCounts should return the correct result. """ ri = ReadIntervals(10) ri.add(0, 12) c = Counter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) self.assertEqual(c, ri.coverageCounts())