本文整理汇总了Python中pybedtools.BedTool.total_coverage方法的典型用法代码示例。如果您正苦于以下问题:Python BedTool.total_coverage方法的具体用法?Python BedTool.total_coverage怎么用?Python BedTool.total_coverage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybedtools.BedTool
的用法示例。
在下文中一共展示了BedTool.total_coverage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GenomicSubset
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import total_coverage [as 别名]
class GenomicSubset(object):
def __init__(self, name, path=paths.genome_subsets, assembly='hg19'):
self.assembly = assembly
self.name = name
self.bedtool = BedTool(path + name + '.bed').sort()
# Intersect the pathway with the appropriate genome build
# TODO: this step should be unnecessary if the pathways are correct
if name != self.assembly:
self.bedtool = GenomicSubset.reference_genome(
self.assembly).bedtool.intersect(self.bedtool).sort().saveas()
def expand_by(self, expansion_in_each_direction_Mb):
window_size_str = str(expansion_in_each_direction_Mb) + 'Mb'
print('total size before window addition:', self.bedtool.total_coverage(), 'bp')
# compute the flanks
# TODO: use 1cM instead of 1Mb
print('computing flanks')
flanks = self.bedtool.flank(
genome=self.assembly,
b=expansion_in_each_direction_Mb*1000000).sort().merge().saveas()
# compute the union of the flanks and the pathway
print('computing union')
union = self.bedtool.cat(flanks, postmerge=False).sort()
merged = union.merge().saveas()
print('total size after window addition:', merged.total_coverage(), 'bp')
self.bedtool = merged
def restricted_to_chrom_bedtool(self, chrnum):
return self.bedtool.filter(
lambda x : x[0] == 'chr' + str(int(chrnum))).saveas()
@classmethod
def reference_genome(cls, assembly='hg19'):
return GenomicSubset(assembly, path=paths.reference, assembly=assembly)
@classmethod
def reference_chrom_bedtool(cls, chrnum, assembly='hg19'):
return cls.reference_genome(assembly=assembly).restricted_to_chrom_bedtool(chrnum)
@classmethod
def whole_genome(cls, assembly='hg19'):
return cls(assembly, path=paths.reference)