return results_dict ############################################ #Main Block ############################################ starttime = gc.getLogTime() indir, orig_targets, pairwise, prob_thresh, num_threads, output = optParse() if platform.system() == "Windows" and num_threads != 1: print "\n** Warning! Multi-processing not currently supported on Windows. Switching to serial version (1 process).\n" num_threads = 1 outdir = gc.defaultOut(output, indir, "-gwct") print gc.getTime() + " | + Creating main output directory:\t" + outdir os.system("mkdir " + outdir) ancdir = os.path.join(indir, "anc-seqs-fa") if not os.path.isdir(ancdir): ancdir = os.path.join(indir, "anc_seqs_fa") if not os.path.isdir(ancdir): sys.exit( gc.errorOut( 9, "Cannot find anc-seqs-fa directory within input directory.")) filelist = os.listdir(ancdir) filelist = [f for f in filelist if "ancprobs" in f] num_files = len(filelist) if prob_thresh == 0: convfilename = os.path.join(outdir, "conv-sites.txt") divfilename = os.path.join(outdir, "div-sites.txt")
indir = os.path.dirname(os.path.realpath(ins)); indir, script_outdir = gwctcore.getOutdir(indir, "run_codeml", starttime, outdir_suffix); outdir = os.path.join(script_outdir, "codeml_out"); if aopt == 1: ancdir = os.path.join(script_outdir, "anc_seqs_fa"); filelist = [ins]; else: 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);
elif errorflag == 1: parser.print_help(); sys.exit(); ############################################ #Main Block ############################################ starttime = gwctcore.getLogTime(); indir, targets, suffix = optParse(0); 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));
print indir; inslist = os.listdir(indir); if unique != 1: for each in inslist: if each.find("run_codeml") != -1 or each.find("codeml_combined") != -1: #indir = indir + each + "/anc_seqs_fa/"; indir = os.path.join(indir, each, "anc_seqs_fa"); orig_filelist = os.listdir(indir); filelist = [f for f in orig_filelist if f.find("ancprobs") != -1]; num_files = len(filelist); break; elif unique == 1: 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);
indir, path, treefile, prune, v, output = optParse(); # Get input options. file_flag = 0; outdir = gc.defaultOut(output, indir, "-gwct-codeml"); print "+ Creating main output directory:\t" + outdir; os.system("mkdir " + outdir); codemldir = os.path.join(outdir, "codeml-out"); ancdir = os.path.join(outdir, "anc-seqs-fa"); logfilename = os.path.join(outdir, "gwct-codeml.log"); # Set output file and directory info. gc.printWrite(logfilename, "Program call: " + " ".join(sys.argv)); pad = 50; print gc.spacedOut(gc.getTime() + " | Creating main output directory:", pad) + outdir; os.system("mkdir " + outdir); gc.printWrite(logfilename, "======================================================================="); gc.printWrite(logfilename, "\tRunning codeml to reconstruct ancestral sequences"); gc.printWrite(logfilename, "\t\t\t" + gc.getDateTime()); gc.printWrite(logfilename, gc.spacedOut("Input directory (-i):", pad) + indir); gc.printWrite(logfilename, gc.spacedOut("PAML path (-p):", pad) + path); if treefile != "": gc.printWrite(logfilename, gc.spacedOut("Tree file (-t):", pad) + treefile); else: gc.printWrite(logfilename, gc.spacedOut("No tree file specified (-t):", pad) + "codeml will infer a tree for each gene."); if prune: gc.printWrite(logfilename, gc.spacedOut("--prune set", pad) + "Pruning the tree for each gene."); # if seqtype == 'codon': # gc.printWrite(logfilename, gc.spacedOut("INFO | Seqtype set to:", pad) + "codons"); # if seqtype == 'aa':
elif errorflag == 1: parser.print_help() sys.exit() ############################################ #Main Block ############################################ starttime = gwctcore.getLogTime() indir, targets, suffix = optParse(0) 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(
print indir inslist = os.listdir(indir) if unique != 1: for each in inslist: if each.find("run_codeml") != -1 or each.find("codeml_combined") != -1: #indir = indir + each + "/anc_seqs_fa/"; indir = os.path.join(indir, each, "anc_seqs_fa") orig_filelist = os.listdir(indir) filelist = [f for f in orig_filelist if f.find("ancprobs") != -1] num_files = len(filelist) break elif unique == 1: 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, "# =======================================================================" )