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
评论列表
文章目录