'Returns representation of self as a dictionary.'

def to_dict(self, num=None, chrom=None, low=None):

    def check_int(s):
        if s.isdigit():
            return int(s)
        else:
            return s
    def split_by_number(s):
        return [check_int(c) for c in re.split('([0-9]+)', s)]
    if num:
        num = int(num)
    else:
        num = sys.maxsize
    if low:
        low = int(low)
        if (low < 0):
            low = 0
    else:
        low = 0
    len_file_enumerate = enumerate(open(self.len_file))
    chroms = {}
    prev_chroms = False
    start_index = 0
    if chrom:
        found = False
        count = 0
        for (line_num, line) in len_file_enumerate:
            if line.startswith('#'):
                continue
            (name, len) = line.split(' DCTB ')
            if found:
                chroms[name] = int(len)
                count += 1
            elif (name == chrom):
                chroms[name] = int(len)
                count += 1
                found = True
                start_index = line_num
                if (line_num != 0):
                    prev_chroms = True
            if (count >= num):
                break
    else:
        high = (low + int(num))
        prev_chroms = (low != 0)
        start_index = low
        for (line_num, line) in len_file_enumerate:
            if (line_num < low):
                continue
            if (line_num >= high):
                break
            if line.startswith('#'):
                continue
            fields = line.split(' DCTB ')
            chroms[fields[0]] = int(fields[1])
    next_chroms = False
    try:
        next(len_file_enumerate)
        next_chroms = True
    except:
        pass
    to_sort = [{'chrom': chrm, 'len': length} for (chrm, length) in chroms.items()]
    to_sort.sort(key=(lambda _: split_by_number(_['chrom'])))
    return {'id': self.key, 'reference': (self.twobit_file is not None), 'chrom_info': to_sort, 'prev_chroms': prev_chroms, 'next_chroms': next_chroms, 'start_index': start_index}
