def _iter_loci(meta, clusters, s2p, filtered, n_cluster):
    """
    Go through all locus and decide if they are part
    of the same TU or not.

    :param idx: int cluster id
    :param s2p: dict with [loci].coverage[start] = # of sequences there
    :param filtered: dict with clusters object
    :param n_cluster: int cluster id

    :return:
        * filtered: dict of cluster objects
        * n_cluster: int cluster id
    """
    global CONFLICT
    loci = dict(zip(meta, [clusters[idc] for idc in meta]))

    n_loci = len(meta)
    n_loci_prev = n_loci + 1
    cicle = 0
    # [logger.note("BEFORE %s %s %s" % (c.id, idl, len(c.loci2seq[idl]))) for idl in c.loci2seq]
    internal_cluster = {}
    if n_loci == 1:
        n_cluster += 1
        filtered[n_cluster] = clusters[meta[0]]
        filtered[n_cluster].update(id=n_cluster)
        filtered[n_cluster].set_freq(s2p[1])

    while n_loci < n_loci_prev and n_loci != 1:
        n_loci_prev = n_loci
        cicle += 1
        if (cicle % 1) == 0:
            logger.debug("_iter_loci:number of cicle: %s with n_loci %s" % (cicle, n_loci))
        loci_similarity = _calculate_similarity(loci)
        internal_cluster = _merge_similar(loci, loci_similarity)
        n_loci = len(internal_cluster)
        loci = internal_cluster
        logger.debug("_iter_loci: n_loci %s" % n_loci)

    if n_loci > 1:
        n_internal_cluster = sorted(internal_cluster.keys(), reverse=True)[0]
        CONFLICT += 1
        internal_cluster = _solve_conflict(internal_cluster, s2p, n_internal_cluster)

    internal_cluster = _clean_cluster(internal_cluster)

    for idc in internal_cluster:
        n_cluster += 1
        logger.debug("_iter_loci: add to filtered %s" % n_cluster)
        filtered[n_cluster] = internal_cluster[idc]
        filtered[n_cluster].id = n_cluster
        filtered[n_cluster].update(id=n_cluster)
        filtered[n_cluster].set_freq(s2p[1])
    logger.debug("_iter_loci: filtered %s" % filtered.keys())

    # for new_c in internal_cluster.values():
    #    [logger.note("%s %s %s %s" % (meta, new_c.id, idl, len(new_c.loci2seq[idl]))) for idl in new_c.loci2seq]
    return filtered, n_cluster
def _iter_loci ( meta , clusters , s2p , filtered , n_cluster ) : global CONFLICT loci = dict ( zip ( meta , [ clusters [ idc ] for idc in meta ] ) ) n_loci = len ( meta ) n_loci_prev = n_loci + 1 cicle = 0 internal_cluster = { } if n_loci == 1 : n_cluster += 1 filtered [ n_cluster ] = clusters [ meta [ 0 ] ] filtered [ n_cluster ] . update ( id = n_cluster ) filtered [ n_cluster ] . set_freq ( s2p [ 1 ] ) while n_loci < n_loci_prev and n_loci != 1 : n_loci_prev = n_loci cicle += 1 if ( cicle % 1 ) == 0 : logger . debug ( "_iter_loci:number of cicle: %s with n_loci %s" % ( cicle , n_loci ) ) loci_similarity = _calculate_similarity ( loci ) internal_cluster = _merge_similar ( loci , loci_similarity ) n_loci = len ( internal_cluster ) loci = internal_cluster logger . debug ( "_iter_loci: n_loci %s" % n_loci ) if n_loci > 1 : n_internal_cluster = sorted ( internal_cluster . keys ( ) , reverse = True ) [ 0 ] CONFLICT += 1 internal_cluster = _solve_conflict ( internal_cluster , s2p , n_internal_cluster ) internal_cluster = _clean_cluster ( internal_cluster ) for idc in internal_cluster : n_cluster += 1 logger . debug ( "_iter_loci: add to filtered %s" % n_cluster ) filtered [ n_cluster ] = internal_cluster [ idc ] filtered [ n_cluster ] . id = n_cluster filtered [ n_cluster ] . update ( id = n_cluster ) filtered [ n_cluster ] . set_freq ( s2p [ 1 ] ) logger . debug ( "_iter_loci: filtered %s" % filtered . keys ( ) ) return filtered , n_cluster
Go through all locus and decide if they are part
    of the same TU or not.

    :param idx: int cluster id
    :param s2p: dict with [loci].coverage[start] = # of sequences there
    :param filtered: dict with clusters object
    :param n_cluster: int cluster id

    :return:
        * filtered: dict of cluster objects
        * n_cluster: int cluster id