def activate(self, tourfile=None, minsize=10000, backuptour=True):
        """
        Select contigs in the current partition. This is the setup phase of the
        algorithm, and supports two modes:

        - "de novo": This is useful at the start of a new run where no tours
          available. We select the strong contigs that have significant number
          of links to other contigs in the partition. We build a histogram of
          link density (# links per bp) and remove the contigs that appear as
          outliers. The orientations are derived from the matrix decomposition
          of the pairwise strandedness matrix O.

        - "hotstart": This is useful when there was a past run, with a given
          tourfile. In this case, the active contig list and orientations are
          derived from the last tour in the file.
        """
        if tourfile and (not op.exists(tourfile)):
            logging.debug("Tourfile `{}` not found".format(tourfile))
            tourfile = None

        if tourfile:
            logging.debug("Importing tourfile `{}`".format(tourfile))
            tour, tour_o = iter_last_tour(tourfile, self)
            self.active = set(tour)
            tig_to_idx = self.tig_to_idx
            tour = [tig_to_idx[x] for x in tour]
            signs = sorted([(x, FF[o]) for (x, o) in zip(tour, tour_o)])
            _, signs = zip(*signs)
            self.signs = np.array(signs, dtype=int)
            if backuptour:
                backup(tourfile)
            tour = array.array('i', tour)
        else:
            self.report_active()
            while True:
                logdensities = self.calculate_densities()
                lb, ub = outlier_cutoff(logdensities.values())
                logging.debug("Log10(link_densities) ~ [{}, {}]"
                              .format(lb, ub))
                remove = set(x for x, d in logdensities.items() if
                             (d < lb and self.tig_to_size[x] < minsize * 10))
                if remove:
                    self.active -= remove
                    self.report_active()
                else:
                    break

            logging.debug("Remove contigs with size < {}".format(minsize))
            self.active = set(x for x in self.active if
                              self.tig_to_size[x] >= minsize)
            tour = range(self.N)  # Use starting (random) order otherwise
            tour = array.array('i', tour)

            # Determine orientations
            self.flip_all(tour)

        self.report_active()
        self.tour = tour

        return tour
def activate ( self , tourfile = None , minsize = 10000 , backuptour = True ) : if tourfile and ( not op . exists ( tourfile ) ) : logging . debug ( "Tourfile `{}` not found" . format ( tourfile ) ) tourfile = None if tourfile : logging . debug ( "Importing tourfile `{}`" . format ( tourfile ) ) tour , tour_o = iter_last_tour ( tourfile , self ) self . active = set ( tour ) tig_to_idx = self . tig_to_idx tour = [ tig_to_idx [ x ] for x in tour ] signs = sorted ( [ ( x , FF [ o ] ) for ( x , o ) in zip ( tour , tour_o ) ] ) _ , signs = zip ( * signs ) self . signs = np . array ( signs , dtype = int ) if backuptour : backup ( tourfile ) tour = array . array ( 'i' , tour ) else : self . report_active ( ) while True : logdensities = self . calculate_densities ( ) lb , ub = outlier_cutoff ( logdensities . values ( ) ) logging . debug ( "Log10(link_densities) ~ [{}, {}]" . format ( lb , ub ) ) remove = set ( x for x , d in logdensities . items ( ) if ( d < lb and self . tig_to_size [ x ] < minsize * 10 ) ) if remove : self . active -= remove self . report_active ( ) else : break logging . debug ( "Remove contigs with size < {}" . format ( minsize ) ) self . active = set ( x for x in self . active if self . tig_to_size [ x ] >= minsize ) tour = range ( self . N ) tour = array . array ( 'i' , tour ) self . flip_all ( tour ) self . report_active ( ) self . tour = tour return tour
Select contigs in the current partition. This is the setup phase of the
        algorithm, and supports two modes:

        - "de novo": This is useful at the start of a new run where no tours
          available. We select the strong contigs that have significant number
          of links to other contigs in the partition. We build a histogram of
          link density (# links per bp) and remove the contigs that appear as
          outliers. The orientations are derived from the matrix decomposition
          of the pairwise strandedness matrix O.

        - "hotstart": This is useful when there was a past run, with a given
          tourfile. In this case, the active contig list and orientations are
          derived from the last tour in the file.