segregation.py 文件源码

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

项目:gamtools 作者: pombo-lab 项目源码 文件源码
def parse_location_string(loc_string):
    """
    Parse a UCSC format location string (e.g. "chr2:1000-1100") and return
    an interval tuple in the format ('chr2', 1000, 1100).

    :param loc_string: Input location string
    :type loc_string: :ref:`location string <location_string>`
    :returns: (chromosome name, start coordinate, stop coordinate)
    """

    chrom_fields = loc_string.split(':')

    chrom = chrom_fields[0]

    if len(chrom_fields) == 1:

        start, stop = 0, np.Inf

    else:

        pos_fields = chrom_fields[1].split('-')

        start, stop = (int(pos.replace(",", "")) for pos in pos_fields)

    return chrom, start, stop
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号