'Return a chrom, start, stop tuple for viewing a file.'

def get_estimated_display_viewport(self, dataset, chrom_col=None, start_col=None, end_col=None):

    viewport_feature_count = 100
    max_line_count = max(viewport_feature_count, 500)
    if (not self.displayable(dataset)):
        return (None, None, None)
    try:
        if (chrom_col is None):
            chrom_col = (int(dataset.metadata.chromCol) - 1)
        if (start_col is None):
            start_col = (int(dataset.metadata.startCol) - 1)
        if (end_col is None):
            end_col = (int(dataset.metadata.endCol) - 1)
        chrom = None
        start = sys.maxsize
        end = 0
        max_col = max(chrom_col, start_col, end_col)
        fh = open(dataset.file_name)
        while True:
            line = fh.readline(VIEWPORT_READLINE_BUFFER_SIZE)
            if (not line):
                break
            if (not line.startswith('#')):
                try:
                    fields = line.rstrip().split(' DCTB ')
                    if (len(fields) > max_col):
                        if ((chrom is None) or (chrom == fields[chrom_col])):
                            start = min(start, int(fields[start_col]))
                            end = max(end, int(fields[end_col]))
                            chrom = fields[chrom_col]
                        viewport_feature_count -= 1
                except Exception:
                    pass
            readline_count = VIEWPORT_MAX_READS_PER_LINE
            while (line.rstrip('\n\r') == line):
                assert (readline_count > 0), Exception(('Viewport    readline    count    exceeded    for    dataset    %s.' % dataset.id))
                line = fh.readline(VIEWPORT_READLINE_BUFFER_SIZE)
                if (not line):
                    break
                readline_count -= 1
            max_line_count -= 1
            if ((not viewport_feature_count) or (not max_line_count)):
                break
        if (chrom is not None):
            return (chrom, str(start), str(end))
    except Exception:
        log.exception("Exception    caught    attempting    to    generate    viewport    for    dataset    '%d'", dataset.id)
    return (None, None, None)
