def _second_start(read, poss, strand, chrom, segmentation, holesize_th):
"""
Return the coordinate of second start.
If read is not split or we wish algorithm
to think of read as linear, second_start equals to 0.
"""
holes = [j - i - 1 for i, j in zip(poss, poss[1:])]
# Get the size of the biggest hole:
biggest_hole_size = max(holes) if holes else 0
second_start = 0
is_strange = False
if not segmentation:
# Effectively this means, that read is considered as it has no holes.
if biggest_hole_size > holesize_th:
# Still, read is not treated as on with distinct second_start.
# However, it is reported as starnge:
is_strange = True
else:
biggest_hole_size_index = holes.index(biggest_hole_size)
# Take right border of hole on "+" and left border on "-" strand:
if strand == '+':
second_start = poss[biggest_hole_size_index + 1]
else:
second_start = poss[biggest_hole_size_index]
# Read is strange if:
# it is not intersecting with segmentation AND
# if there actually is a hole
if not _intersects_with_annotaton(second_start, segmentation, chrom, strand) and \
biggest_hole_size != 0:
is_strange = True
return second_start, is_strange
评论列表
文章目录