def read_taxid_list(filename, _dict=None):
    """ Read a taxID list file.

    A taxID list file consists of three tab separated columns: 1. ID type,
    2. ID of sequence, 3. NCBI taxonomy ID for the sequence. It is headed by
    one line starting with the '#' char.

    Parameters
    ----------
    filename : str
        Path to the file containing the taxID list.
    _dict : dict
        Optional. Provide an existing dictionary into which parsed results
        should be added. Useful if the taxID list consists of several files.

    Returns
    -------
    A dict of dict. First dict's keys are the sequence types, e.g. "gi",
    "GeneID", "NC". Second level keys are the sequence IDs and their values are
    the according NCBI taxonomy IDs, or taxIDs for short.

    Raises
    ------
    ValueError
        If a line does not contain of exactly three tab delimited fields.
    """
    if _dict is None:
        _dict = dict()
    f = open(filename, 'r')
    f.readline()  # header
    for line in f:
        try:
            _type, accession, taxid = line.rstrip().split("\t")
            if _type not in _dict:
                _dict[_type] = {}
            _dict[_type][accession] = taxid
        except ValueError:
            f.close()
            raise ValueError("Error parsing line '%s' of file '%s'" %
                             (line, filename))

    f.close()
    return _dict