本文整理汇总了Python中CGAT.Intervals.calculateOverlap方法的典型用法代码示例。如果您正苦于以下问题:Python Intervals.calculateOverlap方法的具体用法?Python Intervals.calculateOverlap怎么用?Python Intervals.calculateOverlap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGAT.Intervals
的用法示例。
在下文中一共展示了Intervals.calculateOverlap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: count
# 需要导入模块: from CGAT import Intervals [as 别名]
# 或者: from CGAT.Intervals import calculateOverlap [as 别名]
def count( self, bed ):
'''update internal counts.'''
results = []
for track in self.tracks:
try:
overlaps = [ (x[0],x[1]) for x in self.index[track][bed.contig].find( bed.start, bed.end ) ]
except KeyError:
overlaps = []
results.append( (len(overlaps),
Intervals.calculateOverlap( [(bed.start, bed.end),],
Intervals.combine( overlaps ) ) ) )
self.data = results
示例2: merge
# 需要导入模块: from CGAT import Intervals [as 别名]
# 或者: from CGAT.Intervals import calculateOverlap [as 别名]
#.........这里部分代码省略.........
% (d, last, bed)
if bed.contig != last.contig:
for s in to_join:
if to_join[s]:
yield to_join[s]
to_join[s] = []
max_end[s] = 0
elif (d > max_distance or
(by_name and last_name[strand] != bed.name)):
if to_join[strand]:
yield to_join[strand]
to_join[strand] = []
last = bed
last_name[strand] = last.name
max_end[strand] = max(bed.end, max_end[strand])
to_join[strand].append(bed)
for strand in to_join:
if to_join[strand]:
yield to_join[strand]
raise StopIteration
c = E.Counter()
for to_join in iterate_chunks(iterator):
c.input += 1
if remove_inconsistent:
names = set([x.name for x in to_join])
if len(names) > 1:
c.skipped_inconcistent_intervals += 1
continue
if resolve_blocks:
# keep track of number of intervals in each entry
for bed in to_join:
bed["score"] = 1
merged = True
while merged:
joined = []
not_joined = []
merged = False
while len(to_join) > 0:
bed1, to_join = to_join[0], to_join[1:]
intervals1 = bed1.toIntervals()
for bed2 in to_join:
intervals2 = bed2.toIntervals()
if Intervals.calculateOverlap(intervals1, intervals2) > 0:
intervals = Intervals.combine(intervals1 +
intervals2)
bed1.fromIntervals(intervals)
bed1["score"] += bed2["score"]
merged = True
else:
not_joined.append(bed2)
joined.append(bed1)
to_join = not_joined
not_joined = []
to_join = joined
joined = []
to_join = sorted(to_join, key=lambda x: int(x.start))
# keep only those with the created from the merge of the minimum
# number of intervals
for bed in to_join:
if bed["score"] < min_intervals:
c.skipped_min_intervals += 1
continue
yield bed
c.output += 1
else:
if len(to_join) < min_intervals:
c.skipped_min_intervals += 1
continue
a = to_join[0]
a.end = max([entry.end for entry in to_join])
a.score = len(to_join)
yield a
c.output += 1
E.info(str(c))