Split the list of OTUs (and associated sequence ids) into two lists:
    those occurring in more than some percentage of samples and those less than
    the cutoff.

    :type otus: dict
    :param otus: {otuid: [taxonomy, [sequence IDs]]}
    :type nsamples: int
    :param nsamples: The total number of samples in the data set
    :type pct: float
    :param pct: The cutoff percentage for inclusion in the filtered
                 set of OTUs
    :type phyl_level: str
    :param phyl_level: The phylogenetic level (e.g. family, group, etc...) at
                       which to combine OTU counts for thresholding. One of
                       the following: ['k','p','c','o','f','g','s']

    :rtype: tuple
    :return: Two dicts: the OTU IDs and sequence IDs above and below the
              percentage threshold.

def filter_by_sample_pct(otus, nsamples, pct, phyl_level):
    """
    Split the list of OTUs (and associated sequence ids) into two lists:
    those occurring in more than some percentage of samples and those less than
    the cutoff.

    :type otus: dict
    :param otus: {otuid: [taxonomy, [sequence IDs]]}
    :type nsamples: int
    :param nsamples: The total number of samples in the data set
    :type pct: float
    :param pct: The cutoff percentage for inclusion in the filtered
                 set of OTUs
    :type phyl_level: str
    :param phyl_level: The phylogenetic level (e.g. family, group, etc...) at
                       which to combine OTU counts for thresholding. One of
                       the following: ['k','p','c','o','f','g','s']

    :rtype: tuple
    :return: Two dicts: the OTU IDs and sequence IDs above and below the
              percentage threshold.
    """
    if phyl_level not in ['k', 'p', 'c', 'o', 'f', 'g', 's']:
        phyl_level = 's'
    nsamples = float(nsamples)
    sample_counts = defaultdict(set)
    # count the number of sequences per OTU
    for otuid in otus:
        phyl = util.split_phylogeny(otus[otuid][0], phyl_level)
        samples = {seqid.split('_')[0] for seqid in otus[otuid][1]}
        sample_counts[phyl].update(samples)
    sample_counts = {phyl: len(sample_counts[phyl])/nsamples
                     for phyl in sample_counts}

    # separate OTUs
    above = {}
    below = {}
    for otuid in otus:
        phyl = util.split_phylogeny(otus[otuid][0], phyl_level)
        if sample_counts[phyl] >= pct:
            above[otuid] = otus[otuid]
        else:
            below[otuid] = [sample_counts[phyl], '',
                            otus[otuid][0], otus[otuid][1]]

    return above, below