本文整理汇总了Python中dark.intervals.ReadIntervals.walk方法的典型用法代码示例。如果您正苦于以下问题:Python ReadIntervals.walk方法的具体用法?Python ReadIntervals.walk怎么用?Python ReadIntervals.walk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dark.intervals.ReadIntervals
的用法示例。
在下文中一共展示了ReadIntervals.walk方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testOneIntervalExactCovering
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
def testOneIntervalExactCovering(self):
"""
If there is a single interval that spans the whole hit exactly, just
that one interval should be returned by walk, and it should be full.
"""
ri = ReadIntervals(100)
ri.add(0, 100)
self.assertEqual([(self.FULL, (0, 100))], list(ri.walk()))
示例2: testEmpty
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
def testEmpty(self):
"""
When no intervals are added, walk should just return one empty
interval that spans the entire rangoe from 0 to the sequence
length.
"""
ri = ReadIntervals(100)
self.assertEqual([(self.EMPTY, (0, 100))], list(ri.walk()))
示例3: testOneIntervalEndingAfterHitEnd
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
def testOneIntervalEndingAfterHitEnd(self):
"""
If there is a single interval that ends after the end of the hit
but doesn't start at zero, we should get 2 intervals back from walk,
an empty then a full.
"""
ri = ReadIntervals(100)
ri.add(50, 150)
self.assertEqual([(self.EMPTY, (0, 50)), (self.FULL, (50, 150))], list(ri.walk()))
示例4: testOneIntervalStartingBeforeZero
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
def testOneIntervalStartingBeforeZero(self):
"""
If there is a single interval that starts before zero but doesn't
cover the whole hit, we should get 2 intervals back from walk,
a full one and then an empty.
"""
ri = ReadIntervals(100)
ri.add(-50, 50)
self.assertEqual([(self.FULL, (-50, 50)), (self.EMPTY, (50, 100))], list(ri.walk()))
示例5: testOneIntervalCoveringAllExtendingBoth
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
def testOneIntervalCoveringAllExtendingBoth(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, that
one interval should be returned by walk, and it should be full.
"""
ri = ReadIntervals(100)
ri.add(-10, 110)
self.assertEqual([(self.FULL, (-10, 110))], list(ri.walk()))
示例6: testOneIntervalCoveringAllExtendingLeft
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
def testOneIntervalCoveringAllExtendingLeft(self):
"""
If there is a single interval that spans the whole hit, including
going negative to the left, that one interval should be returned by
walk, and it should be full.
"""
ri = ReadIntervals(100)
ri.add(-10, 100)
self.assertEqual([(self.FULL, (-10, 100))], list(ri.walk()))
示例7: testOverlappingIntervalsThatCoverEverything
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
def testOverlappingIntervalsThatCoverEverything(self):
"""
If there are sets of overlapping intervals that cover the whole hit,
we should get 1 full interval back from walk.
"""
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([(self.FULL, (-10, 110))], list(ri.walk()))
示例8: testTwoOverlappingIntervalsInMiddle
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
def testTwoOverlappingIntervalsInMiddle(self):
"""
If there are two overlapping intervals in the middle of the hit, we
should get 3 intervals back from walk: empty, full, empty.
"""
ri = ReadIntervals(100)
ri.add(50, 60)
ri.add(55, 70)
self.assertEqual(
[
(self.EMPTY, (0, 50)),
(self.FULL, (50, 70)),
(self.EMPTY, (70, 100)),
],
list(ri.walk()))
示例9: testOneIntervalInMiddle
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
def testOneIntervalInMiddle(self):
"""
If there is a single interval in the middle of the hit, we
should get 3 intervals back from walk: empty, full, empty.
"""
ri = ReadIntervals(100)
ri.add(50, 60)
self.assertEqual(
[
(self.EMPTY, (0, 50)),
(self.FULL, (50, 60)),
(self.EMPTY, (60, 100)),
],
list(ri.walk()))
示例10: testPairOfTwoOverlappingIntervals
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
def testPairOfTwoOverlappingIntervals(self):
"""
If there are two sets of two overlapping intervals in the middle of
the hit, we should get 5 intervals back from walk.
"""
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(
[
(self.EMPTY, (0, 50)),
(self.FULL, (50, 70)),
(self.EMPTY, (70, 80)),
(self.FULL, (80, 95)),
(self.EMPTY, (95, 100)),
],
list(ri.walk()))
示例11: alignmentGraph
# 需要导入模块: from dark.intervals import ReadIntervals [as 别名]
# 或者: from dark.intervals.ReadIntervals import walk [as 别名]
#.........这里部分代码省略.........
for hsp in titleAlignments.hsps():
readIntervals.add(hsp.readStartInSubject, hsp.readEndInSubject)
# Now adjust offsets in all HSPs.
offsetAdjuster = OffsetAdjuster(readIntervals, base=logBase)
for hsp in titleAlignments.hsps():
offsetAdjuster.adjustHSP(hsp)
# A function for adjusting other offsets, below.
adjustOffset = offsetAdjuster.adjustOffset
else:
def adjustOffset(offset):
return offset
# It would be more efficient to only walk through all HSPs once and
# compute these values all at once, but for now this is simple and clear.
maxY = int(ceil(titleAlignments.bestHsp().score.score))
minY = int(titleAlignments.worstHsp().score.score)
maxX = max(hsp.readEndInSubject for hsp in titleAlignments.hsps())
minX = min(hsp.readStartInSubject for hsp in titleAlignments.hsps())
if xRange == 'subject':
# We'll display a graph for the full subject range. Adjust X axis
# min/max to make sure we cover at least zero to the sequence length.
maxX = max(titleAlignments.subjectLength, maxX)
minX = min(0, minX)
# Swap min & max Y values, if needed, as it's possible we are dealing
# with LSPs but that the score adjuster made numerically greater values
# for those that were small.
if maxY < minY:
(maxY, minY) = (minY, maxY)
if logLinearXAxis:
# Adjust minX and maxX if we have gaps at the subject start or end.
gaps = list(readIntervals.walk())
if gaps:
# Check start of first gap:
intervalType, (start, stop) = gaps[0]
if intervalType == ReadIntervals.EMPTY:
adjustedStart = adjustOffset(start)
if adjustedStart < minX:
minX = adjustedStart
# Check stop of last gap:
intervalType, (start, stop) = gaps[-1]
if intervalType == ReadIntervals.EMPTY:
adjustedStop = adjustOffset(stop)
if adjustedStop > maxX:
maxX = adjustedStop
# We're all set up to start plotting the graph.
# Add light grey vertical rectangles to show the logarithmic gaps. Add
# these first so that reads will be plotted on top of them. Only draw
# gaps that are more than SMALLEST_LOGGED_GAP_TO_DISPLAY pixels wide as
# we could have millions of tiny gaps for a bacteria and drawing them
# all will be slow and only serves to make the entire background grey.
if logLinearXAxis and len(offsetAdjuster.adjustments()) < 100:
for (intervalType, interval) in readIntervals.walk():
if intervalType == ReadIntervals.EMPTY:
adjustedStart = adjustOffset(interval[0])
adjustedStop = adjustOffset(interval[1])
width = adjustedStop - adjustedStart
if width >= SMALLEST_LOGGED_GAP_TO_DISPLAY:
readsAx.axvspan(adjustedStart, adjustedStop,
color='#f4f4f4')
if colorQueryBases: