Example #1
0
def delimit_species(args):
    if not os.path.exists(args.stree):
        print("Input tree file does not exists: %s" % args.strees)
        sys.exit()

    try:
        tree = args.stree
        treetest = open(args.stree)
        l1 = treetest.readline()
        treetest.close()

        inputformat = "nexus"
        if l1.strip() == "#NEXUS":
            inputformat = "nexus"
        else:
            inputformat = "raxml"

        bsptp = bootstrap_ptp(filename=args.stree,
                              ftype=inputformat,
                              reroot=args.sreroot,
                              method=args.sstrategy,
                              firstktrees=args.num_trees)

        if args.outgroups != None and len(args.outgroups) > 0:
            bsptp.remove_outgroups(args.outgroups, remove=args.delete)

        pars, settings = bsptp.delimit(args=args)

        pp = partitionparser(taxa_order=bsptp.taxa_order,
                             partitions=pars,
                             scale=1)
        pp.summary(fout=args.output, bnmi=args.nmi, sp_setting=settings)

        if bsptp.numtrees > 1:
            min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions()
            print("Estimated number of species is between " + repr(min_no_p) +
                  " and " + repr(max_no_p))
            print("Mean: " + repr(mean_no_p))

        print_run_info(args=args)

    except treeIO.newick.NewickError:
        print("Unexisting tree file or Malformed newick tree structure.")
Example #2
0
def delimit_species(args):
    if not os.path.exists(args.stree):
        print("Input tree file does not exists: %s" % args.strees)
        sys.exit()

    try:
        tree = args.stree
        treetest = open(args.stree)
        l1 = treetest.readline()
        treetest.close()

        inputformat = "nexus"
        if l1.strip() == "#NEXUS":
            inputformat = "nexus"
        else:
            inputformat = "raxml"

        bsptp = bootstrap_ptp(
            filename=args.stree,
            ftype=inputformat,
            reroot=args.sreroot,
            method=args.sstrategy,
            firstktrees=args.num_trees,
        )

        if args.outgroups != None and len(args.outgroups) > 0:
            bsptp.remove_outgroups(args.outgroups, remove=args.delete)

        pars, settings = bsptp.delimit(args=args)

        pp = partitionparser(taxa_order=bsptp.taxa_order, partitions=pars, scale=1)
        pp.summary(fout=args.output, bnmi=args.nmi, sp_setting=settings)

        if bsptp.numtrees > 1:
            min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions()
            print("Estimated number of species is between " + repr(min_no_p) + " and " + repr(max_no_p))
            print("Mean: " + repr(mean_no_p))

        print_run_info(args=args)

    except treeIO.newick.NewickError:
        print("Unexisting tree file or Malformed newick tree structure.")
Example #3
0
            inputformat = "nexus"
        else:
            inputformat = "raxml"

        bsptp = bootstrap_ptp(filename=args.stree,
                              ftype=inputformat,
                              reroot=args.sreroot,
                              method=args.sstrategy,
                              firstktrees=args.num_trees)

        if args.outgroups != None and len(args.outgroups) > 0:
            bsptp.remove_outgroups(args.outgroups, remove=args.delete)

        pars, settings = bsptp.delimit(args=args)

        pp = partitionparser(taxa_order=bsptp.taxa_order,
                             partitions=pars,
                             scale=args.sscale)
        pp.summary(fout=args.output, bnmi=args.nmi, sp_setting=settings)

        if bsptp.numtrees > 1:
            min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions()
            print("Estimated number of species is between " + repr(min_no_p) +
                  " and " + repr(max_no_p))
            print("Mean: " + repr(mean_no_p))

        print_run_info(args=args)

    except ete2.parser.newick.NewickError:
        print("Unexisting tree file or Malformed newick tree structure.")
Example #4
0
        ftype=inputformat,
        reroot=args.reroot,
        method=args.method,
        seed=args.seed,
        thinning=args.imcmc,
        sampling=args.nmcmc,
        burnin=args.burnin,
        firstktrees=args.num_trees,
    )

    if args.outgroups != None and len(args.outgroups) > 0:
        bbptp.remove_outgroups(args.outgroups, remove=args.delete, output=args.trees + ".NoOutgroups")

    pars, llhs, settings = bbptp.delimit()

    pp = partitionparser(taxa_order=bbptp.taxa_order, partitions=pars, llhs=llhs, scale=args.scale)

    if bbptp.numtrees == 1:
        pp.summary(
            fout=args.output,
            bnmi=args.nmi,
            ML_par=bbptp.get_maxhhl_partition(),
            ml_spe_setting=bbptp.maxhhlsetting,
            sp_setting=settings,
        )
    else:
        pp.summary(fout=args.output, bnmi=args.nmi, sp_setting=settings)

    min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions()
    print("Estimated number of species is between " + repr(min_no_p) + " and " + repr(max_no_p))
    print("Mean: " + "{0:.2f}".format(mean_no_p))
Example #5
0
                        method=args.method,
                        seed=args.seed,
                        thinning=args.imcmc,
                        sampling=args.nmcmc,
                        burnin=args.burnin,
                        firstktrees=args.num_trees)

    if args.outgroups != None and len(args.outgroups) > 0:
        bbptp.remove_outgroups(args.outgroups,
                               remove=args.delete,
                               output=args.trees + ".NoOutgroups")

    pars, llhs, settings = bbptp.delimit()

    pp = partitionparser(taxa_order=bbptp.taxa_order,
                         partitions=pars,
                         llhs=llhs,
                         scale=args.scale)

    if bbptp.numtrees == 1:
        pp.summary(fout=args.output,
                   bnmi=args.nmi,
                   ML_par=bbptp.get_maxhhl_partition(),
                   ml_spe_setting=bbptp.maxhhlsetting,
                   sp_setting=settings)
    else:
        pp.summary(fout=args.output, bnmi=args.nmi, sp_setting=settings)

    min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions()
    print("Estimated number of species is between " + repr(min_no_p) +
          " and " + repr(max_no_p))
    print("Mean: " + "{0:.2f}".format(mean_no_p))
Example #6
0
                        method=args.method,
                        seed=args.seed,
                        thinning=args.imcmc,
                        sampling=args.nmcmc,
                        burnin=args.burnin,
                        firstktrees=args.num_trees)

    if args.outgroups != None and len(args.outgroups) > 0:
        bbptp.remove_outgroups(args.outgroups,
                               remove=args.delete,
                               output=args.trees + ".NoOutgroups")

    pars, llhs, settings = bbptp.delimit()

    pp = partitionparser(taxa_order=bbptp.taxa_order,
                         partitions=pars,
                         llhs=llhs)

    if bbptp.numtrees == 1:
        pp.summary(fout=args.output,
                   bnmi=args.nmi,
                   ML_par=bbptp.get_maxhhl_partition(),
                   ml_spe_setting=bbptp.maxhhlsetting,
                   sp_setting=settings)
    else:
        pp.summary(fout=args.output, bnmi=args.nmi, sp_setting=settings)

    min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions()
    print("Estimated number of species is between " + repr(min_no_p) +
          " and " + repr(max_no_p))
    print("Mean: " + "{0:.2f}".format(mean_no_p))
Example #7
0
	treetest.close()
	inputformat = "nexus"
	if l1.strip() == "#NEXUS":
		inputformat = "nexus"
	else:
		inputformat = "raxml"
	
	bbptp = bayesianptp(filename = args.trees, ftype = inputformat, 
	reroot = args.reroot, method = args.method, seed = args.seed, 
	thinning = args.imcmc, sampling = args.nmcmc, burnin = args.burnin, 
	firstktrees = args.num_trees)
	
	if args.outgroups!= None and len(args.outgroups) > 0:
		bbptp.remove_outgroups(args.outgroups, remove = args.delete, output = args.trees + ".NoOutgroups")
	
	pars, llhs, settings = bbptp.delimit()
	
	pp = partitionparser(taxa_order = bbptp.taxa_order, partitions = pars, llhs = llhs)
	
	if bbptp.numtrees == 1:
		pp.summary(fout = args.output, bnmi = args.nmi, ML_par = bbptp.get_maxhhl_partition(), 
		ml_spe_setting = bbptp.maxhhlsetting, sp_setting = settings)
	else:
		pp.summary(fout = args.output, bnmi = args.nmi, sp_setting = settings)
	
	min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions()
	print("Estimated number of species is between " + repr(min_no_p) + " and " + repr(max_no_p))
	print("Mean: " + "{0:.2f}".format(mean_no_p))
	print("")
	print_run_info(args, bbptp.numtrees)
Example #8
0
    def download1(self):
        try:
            self.toolButton_8.setEnabled(True)
            self.toolButton_9.setEnabled(True)
            m1 = int(self.m1.text())
            m3 = int(self.m3.text())
            m4 = float(self.m4.text())
            m5 = int(self.m5.text())
            m8 = int(self.m8.text())
            m2 = self.m2.text()
            m6 = self.m6.text()
            def_dict.default_factory = partial(factory, m6)
            m7 = def_dict[self.m7.text()]
            m6 = def_dict[self.m6.text()]
            tmpfname = self.filepath['path']
            origfname = None
            _, filename = os.path.split(tmpfname)
            filename = filename.split(".")[0]
            output = self.f.name
            self.outpath['output'] = output
            print(self.outpath['output'])

            open_file = tmpfname
            self.unique = str(int(time.time()))
            save_file = output

            with open(open_file) as treetest:
                l1 = treetest.readline()

            if self.radioButton.isChecked() == True:
                inputformat = "nexus"
                reroot = False

            elif self.radioButton_2.isChecked() == True:
                inputformat = "raxml"
                reroot = False

            elif self.radioButton_3.isChecked() == True:
                inputformat = "raxml"
                reroot = True

            else:
                inputformat = "raxml"
                reroot = True

            bsptp = bootstrap_ptp(filename=open_file,
                                  ftype=inputformat,
                                  reroot=reroot,
                                  method=m2,
                                  firstktrees=m8)
            pars, settings = bsptp.delimit(spe_rate=-1.0,
                                           max_iters=20000,
                                           min_br=0.0001,
                                           whiten=False,
                                           strategy=m2,
                                           sprint=False,
                                           pvalue=0.001)
            pp = partitionparser(taxa_order=bsptp.taxa_order,
                                 partitions=pars,
                                 scale=500,
                                 fileextension=open_file,
                                 ptp_status="ptp")
            pp.summary(fout=os.path.join(save_file, f"PTP_{self.unique}"),
                       bnmi=False,
                       sp_setting=settings)
            onlyfiles = [
                self.listWidget.addItem(f) for f in os.listdir(save_file)
                if os.path.isfile(os.path.join(save_file, f))
            ]

            if bsptp.numtrees > 1:
                min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions()
                print("Estimated number of species is between " +
                      repr(min_no_p) + " and " + repr(max_no_p))
                print("Mean: " + repr(mean_no_p))

        except Exception as e:
            QMessageBox.warning(
                self, "Warning",
                f"The species delimitation output  is not obtained because {e}"
            )
            return
        QMessageBox.information(
            self, "Information",
            "The species delimitation results generated successfully")
Example #9
0
    def download2(self):
        try:
            self.toolButton_8.setEnabled(True)
            self.toolButton_9.setEnabled(True)
            m1 = int(self.m1.text())
            m3 = int(self.m3.text())
            m4 = float(self.m4.text())
            m5 = int(self.m5.text())
            m8 = int(self.m8.text())
            m2 = self.m2.text()
            m6 = self.m6.text()
            def_dict.default_factory = partial(factory, m6)
            m7 = def_dict[self.m7.text()]
            m6 = def_dict[self.m6.text()]

            tmpfname = self.filepath['path']
            origfname = None

            _, filename = os.path.split(tmpfname)
            filename = filename.split(".")[0]
            output = self.f.name
            self.outpath['output'] = output
            print(self.outpath['output'])
            open_file = tmpfname
            self.unique = str(int(time.time()))
            save_file = output
            with open(open_file) as treetest:
                l1 = treetest.readline()

            if self.radioButton.isChecked() == True:
                inputformat = "nexus"
                reroot = False

            elif self.radioButton_2.isChecked() == True:
                inputformat = "raxml"
                reroot = False

            elif self.radioButton_3.isChecked() == True:
                inputformat = "raxml"
                reroot = True

            else:
                inputformat = "raxml"
                reroot = True

            bbptp = bayesianptp(filename=open_file,
                                ftype=inputformat,
                                reroot=reroot)
            bbptp = bayesianptp(filename=open_file,
                                ftype=inputformat,
                                reroot=reroot,
                                method=m2,
                                seed=m5,
                                thinning=m3,
                                sampling=m1,
                                burnin=m4,
                                firstktrees=m8)

            if m6 != None and len(m6) > 0:
                bbptp.remove_outgroups(m6,
                                       remove=m7,
                                       output=open_file + ".NoOutgroups")
            pars, llhs, settings = bbptp.delimit()
            pp = partitionparser(taxa_order=bbptp.taxa_order,
                                 partitions=pars,
                                 llhs=llhs,
                                 fileextension=open_file,
                                 ptp_status="bptp")
            if bbptp.numtrees == 1:
                pp.summary(fout=os.path.join(save_file, f"bPTP_{self.unique}"),
                           ML_par=bbptp.get_maxhhl_partition(),
                           ml_spe_setting=bbptp.maxhhlsetting,
                           sp_setting=settings)

            else:
                pp.summary(fout=os.path.join(save_file,
                                             f"bPTP_{int(time.time())}"),
                           sp_setting=settings)
                min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions()

            onlyfiles = [
                self.listWidget.addItem(f) for f in os.listdir(save_file)
                if os.path.isfile(os.path.join(save_file, f))
            ]

        except Exception as e:
            QMessageBox.warning(
                self, "Warning",
                f"The species delimitation output  is not obtained because {e}"
            )
            return
        QMessageBox.information(
            self, "Information",
            "The species delimitation results generated successfully")
Example #10
0
		l1 = treetest.readline()
		treetest.close()
		
		inputformat = "nexus"
		if l1.strip() == "#NEXUS":
			inputformat = "nexus"
		else:
			inputformat = "raxml"
		
		bsptp = bootstrap_ptp(filename = args.stree, ftype = inputformat, reroot = args.sreroot, method = args.sstrategy, firstktrees = args.num_trees)
		
		if args.outgroups!= None and len(args.outgroups) > 0:
			bsptp.remove_outgroups(args.outgroups, remove = args.delete)
		
		pars, settings = bsptp.delimit(args=args)
		
		pp = partitionparser(taxa_order = bsptp.taxa_order, partitions = pars, scale = args.sscale)
		pp.summary(fout = args.output, bnmi = args.nmi, sp_setting = settings)
		
		if bsptp.numtrees > 1:
			min_no_p, max_no_p, mean_no_p = pp.hpd_numpartitions()
			print("Estimated number of species is between " + repr(min_no_p) + " and " + repr(max_no_p))
			print("Mean: " + repr(mean_no_p)) 
		
		print_run_info(args = args)
		
	except ete2.parser.newick.NewickError:
		print("Unexisting tree file or Malformed newick tree structure.")