regions.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:cellranger 作者: 10XGenomics 项目源码 文件源码
def get_closest_region(self, pt):
        """ Returns the start and end of the closest region, and whether the region contains the point
        """
        containining_region = self.get_region_containing_point(pt)
        if not(containining_region is None):
            (start, end) = containining_region
            return (start, end, True)

        right_index = bisect.bisect(self.starts, pt)
        left_index = right_index - 1

        if right_index == 0:
            return (self.starts[right_index], self.ends[right_index], False)
        elif right_index == len(self.starts):
            return (self.starts[left_index], self.ends[left_index], False)
        else:
            left_dist = pt - self.ends[left_index]
            right_dist = self.starts[right_index] - pt

            if left_dist < right_dist:
                return (self.starts[left_index], self.ends[left_index], False)
            else:
                return (self.starts[right_index], self.ends[right_index], False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号