tad.py 文件源码

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

项目:tadtool 作者: vaquerizaslab 项目源码 文件源码
def sub_regions(regions, region):
    """
    Get regions from a list the overlap with another region.

    :param regions: List of :class:`~GenomicRegion`
    :param region: :class:`~GenomicRegion` used for overlap calculation
    """
    if isinstance(region, string_types):
        region = GenomicRegion.from_string(region)

    sr = []
    start_ix = None
    end_ix = None
    for i, r in enumerate(regions):
        if r.chromosome == region.chromosome and r.start <= region.end and r.end >= region.start:
            if start_ix is None:
                start_ix = i
            end_ix = i
            sr.append(r.copy())
        else:
            if end_ix is not None:
                break

    if start_ix is None or end_ix is None:
        raise ValueError("Region not found in dataset! {}:{}-{}".format(region.chromosome, region.start, region.end))

    return sr, start_ix, end_ix
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号