def _get_interval_for_r_new_otus(seq, r):
    """Compute interval between r new OTUs for seq of samples.

    Imagine an urn with colored balls. Given a drawing of balls from the urn,
    compute how many balls need to be looked at to discover r new colors.
    Colors can be repeated.

    Parameters
    ----------
    seq : sequence
        Series of observations (the actual sample, not the frequencies).
    r : int
        Number of new colors that need to be observed for a new interval.

    Returns
    -------
    generator
        For each new color seen for the first time, yields a tuple of four
        elements: the length of interval (i.e. number of observations looked
        at), the set of seen colors, position in seq after seeing last new
        color (end of interval), and position in seq where interval is started.

    """
    seen = set()
    seq_len = len(seq)

    # note: first iteration is after looking at first char
    for i, curr in enumerate(seq):
        # bail out if there's nothing new
        if seen in curr:
            continue
        else:
            seen.add(curr)

        # otherwise, need to see distance to get k colors
        unseen = 0
        j = i + 1
        while unseen < r and j < seq_len:
            if seq[j] not in seen:
                unseen += 1
            # note: increments after termination condition
            j += 1

        # the interval to see r new colors
        count = j - i - 1
        # the position in seq after seeing r new ones
        cost = j

        # bail out if not enough unseen
        if not count or (unseen < r):
            return

        # make a copy of seen before yielding, as we'll continue to add to the
        # set in subsequent iterations
        yield count, set(seen), cost, i
dataset/ETHPy150Open biocore/scikit-bio/skbio/diversity/alpha/_lladser.py/_get_interval_for_r_new_otus/swapped operands of `in`