Build a index for the given file.

    Args:
        fn (str): the name of the file.
        cols (list): a list containing column to keep (as int).
        names (list): the name corresponding to the column to keep (as str).
        sep (str): the field separator.

    Returns:
        pandas.DataFrame: the index.

def generate_index(fn, cols=None, names=None, sep=" "):
    """Build a index for the given file.

    Args:
        fn (str): the name of the file.
        cols (list): a list containing column to keep (as int).
        names (list): the name corresponding to the column to keep (as str).
        sep (str): the field separator.

    Returns:
        pandas.DataFrame: the index.

    """
    # Some assertions
    assert cols is not None, "'cols' was not set"
    assert names is not None, "'names' was not set"
    assert len(cols) == len(names)

    # Getting the open function
    bgzip, open_func = get_open_func(fn, return_fmt=True)

    # Reading the required columns
    data = pd.read_csv(fn, sep=sep, engine="c", usecols=cols, names=names,
                       compression="gzip" if bgzip else None)

    # Getting the seek information
    f = open_func(fn, "rb")
    data["seek"] = np.fromiter(_seek_generator(f), dtype=np.uint)[:-1]
    f.close()

    # Saving the index to file
    write_index(get_index_fn(fn), data)

    return data