import logging
import collections


def get_full_tax(idx):
    """
    Getting full taxonomy for all genes.
    return: {(tax_lev1, tax_lev2, ...) : genome_ID : genome_len}
    """
    logging.info('Compiling the taxonomy for all genomes...')
    tax_idx = collections.defaultdict(dict)
    for cluster_id,v in idx.items():
        for tax,vv in v.items():
            for genome_id,x in vv.items():
                tax_idx[tax][genome_id] = x['genome_len']
    n_genomes = 0
    for tax,v in tax_idx.items():
        n_genomes += len(v.keys())
    logging.info('  Total number of genomes: {}'.format(n_genomes))
    # return
    return tax_idx