

def _validate_otu_ids_and_tree(counts, otu_ids, tree):
    len_otu_ids = len(otu_ids)
    set_otu_ids = set(otu_ids)
    if (len_otu_ids != len(set_otu_ids)):
        raise ValueError('``otu_ids`` cannot contain duplicated ids.')
    if (len(counts) != len_otu_ids):
        raise ValueError('``otu_ids`` must be the same length as ``counts`` vector(s).')
    if (len(tree.root().children) == 0):
        raise ValueError('``tree`` must contain more than just a root node.')
    if (len(tree.root().children) > 2):
        raise ValueError('``tree`` must be rooted.')
    branch_lengths = []
    tip_names = []
    for e in tree.traverse():
        if (not e.is_root()):
            branch_lengths.append(e.length)
        if e.is_tip():
            tip_names.append(e.name)
    set_tip_names = set(tip_names)
    if (len(tip_names) != len(set_tip_names)):
        raise DuplicateNodeError('All tip names must be unique.')
    if np.array([(l is None) for l in branch_lengths]).any():
        raise ValueError('All non-root nodes in ``tree`` must have a branch length.')
    missing_tip_names = (e - set_tip_names)
    if (missing_tip_names != set()):
        n_missing_tip_names = len(missing_tip_names)
        raise MissingNodeError(('All ``otu_ids`` must be present as tip names in ``tree``. ``otu_ids`` not corresponding to tip names (n=%d): %s' % (n_missing_tip_names, ' '.join(missing_tip_names))))

dataset/ETHPy150Open biocore/scikit-bio/skbio/diversity/_util.py _validate_otu_ids_and_tree/VarMisuse@242/424 `set_otu_ids`->`e`