fileflag = 0; indir, script_outdir = gwctcore.getOutdir(ins, "run_codeml", starttime, outdir_suffix); outdir = os.path.join(script_outdir, "codeml_out"); filelist = os.listdir(indir); if aopt == 1: ancdir = os.path.join(script_outdir, "anc_seqs_fa"); print gwctcore.getTime() + " | Creating main output directory:\t" + script_outdir; os.system("mkdir " + script_outdir); logfilename = os.path.join(script_outdir, "run_codeml.log"); logfile = open(logfilename, "w"); logfile.write(""); logfile.close(); gwctcore.logCheck(l, logfilename, "======================================================================="); gwctcore.logCheck(l, logfilename, "\t\t\tRunning codeml"); gwctcore.logCheck(l, logfilename, "\t\t\t" + gwctcore.getDateTime()); if fileflag == 1: gwctcore.logCheck(l, logfilename, "INPUT | Making tree from file:\t\t" + ins); else: gwctcore.logCheck(l, logfilename, "INPUT | Running codeml on all files in:\t" + indir); gwctcore.logCheck(l, logfilename, "INFO | PAML path set to:\t\t\t" + ppath); if treefile != "": gwctcore.logCheck(l, logfilename, "INFO | Using tree from file:\t\t" + treefile); else: gwctcore.logCheck(l, logfilename, "INFO | No tree file specified. codeml will infer a tree for each gene."); if prune == 1: gwctcore.logCheck(l, logfilename, "INFO | Pruning the tree for each gene."); if bsopt == 0: gwctcore.logCheck(l, logfilename, "INFO | Not doing branch-site test.");
targets = targets.split(","); indir, script_outdir = gwctcore.getOutdir(indir, "gwct", starttime, suffix); print "# " + gwctcore.getTime() + " | Creating main output directory:\t" + script_outdir; os.system("mkdir " + script_outdir); logfilename = os.path.join(script_outdir, "gwct.log"); logfile = open(logfilename, "w"); logfile.write(""); logfile.close(); uniq_header = "#\tChromosome\tGeneID\tAlignLen\tPosition\tBackgroundAlleles\tTargetAlleles\n"; l = 1; sp = 65; gwctcore.logCheck(l, logfilename, "# ======================================================================="); gwctcore.logCheck(l, logfilename, "#\tGWCT: Genome-Wide Convergence Tester -- Unique substitutions"); gwctcore.logCheck(l, logfilename, "#\t\t\t" + gwctcore.getDateTime()); gwctcore.logCheck(l, logfilename, gwctcore.spacedOut("# INPUT | Using sequences in:", sp) + indir); gwctcore.logCheck(l, logfilename, gwctcore.spacedOut("# INPUT | Target species:", sp) + ",".join(targets)); gwctcore.logCheck(l, logfilename, gwctcore.spacedOut("# OUTPUT | Output directory created within input directory:", sp) + script_outdir); gwctcore.logCheck(l, logfilename, "# ---------------------------------------------"); gwctcore.logCheck(2, logfilename, uniq_header); ################################ print "# " + gwctcore.getTime() + " | Counting unique substitutions...."; filelist = os.listdir(indir); numfiles = len(filelist); numbars = 0; donepercent = []; i = 0;
indir, script_outdir = gwctcore.getOutdir(indir, "gwct", starttime, suffix) print "# " + gwctcore.getTime( ) + " | Creating main output directory:\t" + script_outdir os.system("mkdir " + script_outdir) logfilename = os.path.join(script_outdir, "gwct.log") logfile = open(logfilename, "w") logfile.write("") logfile.close() uniq_header = "#\tChromosome\tGeneID\tAlignLen\tPosition\tBackgroundAlleles\tTargetAlleles\n" l = 1 sp = 65 gwctcore.logCheck( l, logfilename, "# =======================================================================" ) gwctcore.logCheck( l, logfilename, "#\tGWCT: Genome-Wide Convergence Tester -- Unique substitutions") gwctcore.logCheck(l, logfilename, "#\t\t\t" + gwctcore.getDateTime()) gwctcore.logCheck( l, logfilename, gwctcore.spacedOut("# INPUT | Using sequences in:", sp) + indir) gwctcore.logCheck( l, logfilename, gwctcore.spacedOut("# INPUT | Target species:", sp) + ",".join(targets)) gwctcore.logCheck( l, logfilename, gwctcore.spacedOut( "# OUTPUT | Output directory created within input directory:", sp) +
filelist = os.listdir(indir); num_files = len(filelist); print gwctcore.getTime() + " | Creating main output directory:\t" + script_outdir; os.system("mkdir " + script_outdir); logfilename = os.path.join(script_outdir, "gwct.log"); logfile = open(logfilename, "w"); logfile.write(""); logfile.close(); main_header = "# Chromosome\tGeneID\tAlignLen\tPosition\tAncAlleles\tTargetAlleles\n"; uniq_header = "# Chromosome\tGeneID\tAlignLen\tPosition\tBackgroundAlleles\tTargetAlleles\n"; l = 1; sp = 65; gwctcore.logCheck(l, logfilename, "# ======================================================================="); gwctcore.logCheck(l, logfilename, "#\t\tGWCT: Genome-Wide Convergence Tester"); gwctcore.logCheck(l, logfilename, "#\t\t\t" + gwctcore.getDateTime()); gwctcore.logCheck(l, logfilename, gwctcore.spacedOut("# INPUT | Using ancestral reconstructions in:", sp) + indir); if orig_targets != "": orig_targets = orig_targets.split(" "); for t in xrange(len(orig_targets)): if orig_targets[t].find(",") != -1: orig_targets[t] = orig_targets[t].split(","); if prob_thresh == 0: convfilename = os.path.join(script_outdir, "conv_sites.txt"); divfilename = os.path.join(script_outdir, "div_sites.txt"); elif prob_thresh != 0: convfilename = os.path.join(script_outdir, "conv_sites_" + str(prob_thresh) + ".txt"); divfilename = os.path.join(script_outdir, "div_sites_" + str(prob_thresh) + ".txt"); gwctcore.filePrep(convfilename, main_header);
print gwctcore.getTime( ) + " | Creating main output directory:\t" + script_outdir os.system("mkdir " + script_outdir) logfilename = os.path.join(script_outdir, "gwct.log") logfile = open(logfilename, "w") logfile.write("") logfile.close() main_header = "# Chromosome\tGeneID\tAlignLen\tPosition\tAncAlleles\tTargetAlleles\n" uniq_header = "# Chromosome\tGeneID\tAlignLen\tPosition\tBackgroundAlleles\tTargetAlleles\n" l = 1 sp = 65 gwctcore.logCheck( l, logfilename, "# =======================================================================" ) gwctcore.logCheck(l, logfilename, "#\t\tGWCT: Genome-Wide Convergence Tester") gwctcore.logCheck(l, logfilename, "#\t\t\t" + gwctcore.getDateTime()) gwctcore.logCheck( l, logfilename, gwctcore.spacedOut("# INPUT | Using ancestral reconstructions in:", sp) + indir) if orig_targets != "": orig_targets = orig_targets.split(" ") for t in xrange(len(orig_targets)): if orig_targets[t].find(",") != -1: orig_targets[t] = orig_targets[t].split(",") if prob_thresh == 0: convfilename = os.path.join(script_outdir, "conv_sites.txt") divfilename = os.path.join(script_outdir, "div_sites.txt")