@staticmethod
def _parse_region(s):
    """
		Parse a string like "name:begin-end" or "name:begin..end".
		The returned tuple is (name, start, stop, revcomp).
		start is begin-1, stop is equal to end.
		That is, this function converts from 1-based intervals to pythonic
		open intervals!

		The string may be prefixed with "rc:", in which case revcomp is set to True.

		If 'end' is an empty string (as in "chrx:1-"), then stop is set to None.
		If no range is given, as in "chrx:27", then stop is set to start+1.
		If only 'name' is given (or "rc:name"), start is set to 0 and stop to None.

		Commas within the numbers (thousands separators) are ignored.
		"""
    revcomp = False
    if s.startswith('rc:'):
        revcomp = True
        s = s[3:]
    fields = s.rsplit(':', 1)
    if len(fields) == 1:
        region = fields[0], 0, None, revcomp
    else:
        if '..' in fields[1]:
            sep = '..'
        else:
            sep = '-'
        coords = fields[1].split(sep, maxsplit=1)
        start = int(coords[0].replace(',', ''))
        if len(coords) == 1:
            stop = start
        else:
            stop = int(coords[1].replace(',', '')) if coords[1] != '' else None
        assert 0 < start and (stop is None or start <= stop)
        region = fields[0], start - 1, stop, revcomp
    return region
