本文整理汇总了Python中CGAT.Bed.bed_iterator方法的典型用法代码示例。如果您正苦于以下问题:Python Bed.bed_iterator方法的具体用法?Python Bed.bed_iterator怎么用?Python Bed.bed_iterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGAT.Bed
的用法示例。
在下文中一共展示了Bed.bed_iterator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _count
# 需要导入模块: from CGAT import Bed [as 别名]
# 或者: from CGAT.Bed import bed_iterator [as 别名]
def _count(self, filename, idx):
'''count filename against idx.'''
overlapping_genes = set()
genes = set()
# iterate over exons
infile = IOTools.openFile(filename, "r")
it = Bed.bed_iterator(infile)
nexons, nexons_overlapping = 0, 0
nbases, nbases_overlapping = 0, 0
for this in it:
nexons += 1
nbases += this.end - this.start
try:
intervals = list(
idx[this.contig].find(max(0, this.start), this.end))
except KeyError:
continue
except Exception, msg:
raise Exception(
"error while processing %s, msg=%s" % (filename, msg))
if len(intervals) == 0:
continue
nexons_overlapping += 1
start, end = this.start, this.end
counts = numpy.zeros(end - start, numpy.int)
for other_start, other_end, other_value in intervals:
for x in range(max(start, other_start) - start, min(end, other_end) - start):
counts[x] += 1
nbases_overlapping += sum([1 for x in counts if x > 0])