本文整理汇总了Python中pybedtools.BedTool.delete_temporary_history方法的典型用法代码示例。如果您正苦于以下问题:Python BedTool.delete_temporary_history方法的具体用法?Python BedTool.delete_temporary_history怎么用?Python BedTool.delete_temporary_history使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybedtools.BedTool
的用法示例。
在下文中一共展示了BedTool.delete_temporary_history方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readBedIntervals
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import delete_temporary_history [as 别名]
def readBedIntervals(bedPath, ncol = 3,
chrom = None, start = None, end = None,
sort = False, ignoreBed12 = True):
""" Read bed intervals from a bed file (or a specifeid range therein).
NOTE: intervals are sorted by their coordinates"""
if not os.path.isfile(bedPath):
raise RuntimeError("Bed interval file %s not found" % bedPath)
assert ncol == 3 or ncol == 4 or ncol == 5
outIntervals = []
logger.debug("readBedIntervals(%s)" % bedPath)
bedTool = BedTool(bedPath)
if sort is True:
bedTool = bedTool.sort()
logger.debug("sortBed(%s)" % bedPath)
if ignoreBed12 is False:
bedTool = bedTool.bed6()
logger.debug("bed6(%s)" % bedPath)
if chrom is None:
bedIntervals = bedTool
else:
assert start is not None and end is not None
interval = Interval(chrom, start, end)
logger.debug("intersecting (%s,%d,%d) and %s" % (chrom, start, end,
bedPath))
# Below, we try switching from all_hits to intersect()
# all_hits seems to leak a ton of memory for big files, so
# we hope intersect (which creates a temp file) will be better
#bedIntervals = bedTool.all_hits(interval)
tempTool = BedTool(str(interval), from_string = True)
bedIntervals = bedTool.intersect(tempTool)
tempTool.delete_temporary_history(ask=False)
logger.debug("appending bed intervals")
for feat in bedIntervals:
outInterval = (feat.chrom, feat.start, feat.end)
if ncol >= 4:
outInterval += (feat.name,)
if ncol >= 5:
outInterval += (feat.score,)
outIntervals.append(outInterval)
logger.debug("finished readBedIntervals(%s)" % bedPath)
return outIntervals