Exemplo n.º 1
0
    def delimit(self, args):
        self.partitions = []
        self.settings = []
        cnt = 1

        if len(self.trees) == 1:
            tree = self.trees[0]
            me = None
            if args.spe_rate <= 0:
                me = exponential_mixture(tree=tree,
                                         max_iters=args.max_iter,
                                         min_br=args.min_brl)
            else:
                me = exponential_mixture(tree=tree,
                                         max_iters=args.max_iter,
                                         min_br=args.min_brl,
                                         sp_rate=args.spe_rate,
                                         fix_sp_rate=True)

            if args.whiten:
                me.whitening_search(reroot=self.reroot,
                                    strategy=args.sstrategy)
            else:
                me.search(reroot=self.reroot, strategy=args.sstrategy)

            if args.sprint:
                me.count_species(pv=args.pvalue)
                me.print_species()
            else:
                print("Number of species: " +
                      repr(me.count_species(pv=args.pvalue)))

            to, par = me.output_species(taxa_order=self.taxa_order)
            self.partitions.append(par)
            self.settings.append(me.max_setting)

        else:
            for tree in self.trees:
                print("Running PTP on tree " + repr(cnt) + " ........")
                cnt = cnt + 1
                me = exponential_mixture(tree=tree,
                                         max_iters=args.max_iter,
                                         min_br=args.min_brl)
                me.search(reroot=self.reroot, strategy=args.sstrategy)
                me.count_species(pv=args.pvalue, print_log=False)
                to, par = me.output_species(taxa_order=self.taxa_order)
                self.partitions.append(par)
                self.settings.append(me.max_setting)
                print("")
        return self.partitions, self.settings
Exemplo n.º 2
0
 def delimit_EPA(self, sstrategy, reroot, max_iters, min_brl, sp_rate, pvalue=0.001):
     tree = self.trees[0]
     me = exponential_mixture(tree=tree, max_iters=max_iters, min_br=min_brl, sp_rate=sp_rate, fix_sp_rate=True)
     me.search(reroot=reroot, strategy=sstrategy)
     num_spe = me.count_species(print_log=False, pv=pvalue)
     taxa_order, partition = me.output_species(taxa_order=self.taxa_order)
     return partition2names(taxa_order, partition)
Exemplo n.º 3
0
	def __init__(self, tree, start_config = None, reroot = False, startmethod = "H0", min_br = 0.0001, seed = 1234, thinning = 100, sampling = 10000, burning = 0.1, taxa_order = []):
		if start_config == None:
			me = exponential_mixture(tree= tree)
			me.search(strategy = startmethod, reroot = reroot)
			me.count_species(print_log = False, pv = 0.0)
			self.tree = me.tree
			self.current_setting = me.max_setting
		else:
			self.current_setting = start_config
			self.tree = Tree(tree, format = 1)
		self.burning = burning
		self.last_setting = self.current_setting
		self.current_logl = self.current_setting.get_log_l()
		self.last_logl = self.last_setting.get_log_l()
		self.min_br = min_br
		self.rand_nr = random.Random()
		self.rand_nr.seed(seed)
		self.thinning = thinning
		self.sampling = sampling
		if taxa_order == []:
			self.taxaorder = self.tree.get_leaf_names()
		else:
			self.taxaorder = taxa_order
		self.numtaxa = len(self.taxaorder)
		self.partitions = []
		self.llhs = []
		self.nsplit = 0
		self.nmerge = 0
		"""remember the ML partition"""
		self.maxllh = self.current_logl
		to, spe = self.current_setting.output_species(taxa_order = self.taxaorder)
		self.maxpar = spe
		self.max_setting = self.current_setting
		"""record all delimitation settings for plotting, this could consume a lot of MEM"""
		self.settings = []
Exemplo n.º 4
0
	def __init__(self, tree, start_config = None, reroot = False, startmethod = "H0", min_br = 0.0001, seed = 1234, thinning = 100, sampling = 10000, burning = 0.1, taxa_order = []):
		if start_config == None:
			me = exponential_mixture(tree= tree)
			me.search(strategy = startmethod, reroot = reroot)
			me.count_species(print_log = False, pv = 0.0)
			self.tree = me.tree
			self.current_setting = me.max_setting
		else:
			self.current_setting = start_config
			self.tree = Tree(tree, format = 1)
		self.burning = burning
		self.last_setting = self.current_setting
		self.current_logl = self.current_setting.get_log_l()
		self.last_logl = self.last_setting.get_log_l()
		self.min_br = min_br
		self.rand_nr = random.Random()
		self.rand_nr.seed(seed)
		self.thinning = thinning
		self.sampling = sampling
		if taxa_order == []:
			self.taxaorder = self.tree.get_leaf_names()
		else:
			self.taxaorder = taxa_order
		self.numtaxa = len(self.taxaorder)
		self.partitions = []
		self.llhs = []
		self.nsplit = 0
		self.nmerge = 0
		"""remember the ML partition"""
		self.maxllh = self.current_logl
		to, spe = self.current_setting.output_species(taxa_order = self.taxaorder)
		self.maxpar = spe
		self.max_setting = self.current_setting
		"""record all delimitation settings for plotting, this could consume a lot of MEM"""
		self.settings = []
Exemplo n.º 5
0
    def delimit(self, args):
        self.partitions = []
        self.settings = []
        cnt = 1

        if len(self.trees) == 1:
            tree = self.trees[0]
            me = None
            if args.spe_rate <= 0:
                me = exponential_mixture(tree=tree, max_iters=args.max_iter, min_br=args.min_brl)
            else:
                me = exponential_mixture(
                    tree=tree, max_iters=args.max_iter, min_br=args.min_brl, sp_rate=args.spe_rate, fix_sp_rate=True
                )

            if args.whiten:
                me.whitening_search(reroot=self.reroot, strategy=args.sstrategy)
            else:
                me.search(reroot=self.reroot, strategy=args.sstrategy)

                # print to screen
                # me.count_species(pv = args.pvalue)
                # me.print_species()
            print("Number of species: " + repr(me.count_species(pv=args.pvalue)))

            to, par = me.output_species(taxa_order=self.taxa_order)
            self.partitions.append(par)
            self.settings.append(me.max_setting)

        else:
            for tree in self.trees:
                print("Running PTP on tree " + repr(cnt) + " ........")
                cnt = cnt + 1
                me = exponential_mixture(tree=tree, max_iters=args.max_iter, min_br=args.min_brl)
                me.search(reroot=self.reroot, strategy=args.sstrategy)
                me.count_species(pv=args.pvalue, print_log=False)
                to, par = me.output_species(taxa_order=self.taxa_order)
                self.partitions.append(par)
                self.settings.append(me.max_setting)
                print("")
        return self.partitions, self.settings
Exemplo n.º 6
0
 def delimit_EPA(self,
                 sstrategy,
                 reroot,
                 max_iters,
                 min_brl,
                 sp_rate,
                 pvalue=0.001):
     tree = self.trees[0]
     me = exponential_mixture(tree=tree,
                              max_iters=max_iters,
                              min_br=min_brl,
                              sp_rate=sp_rate,
                              fix_sp_rate=True)
     me.search(reroot=reroot, strategy=sstrategy)
     num_spe = me.count_species(print_log=False, pv=pvalue)
     taxa_order, partition = me.output_species(taxa_order=self.taxa_order)
     return partition2names(taxa_order, partition)