def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" fileListFile = "" fileList = [] i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: fileList.append(argv[i]) isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in [ "-outpath", "--outpath", ]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-m", "--m"]: (g_params['method'], i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-md5", "--md5"]: (tmpstr, i) = myfunc.my_getopt_str(argv, i) if tmpstr.lower() == "yes": g_params['isUseMD5'] = True elif tmpstr.lower() == "no": g_params['isUseMD5'] = False else: print >> sys.stderr, "Bad syntax. option -md5 must be followed by yes or no" return 1 elif argv[i] in ["-l", "--l"]: (fileListFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: fileList.append(argv[i]) i += 1 if outpath != "" and not os.path.exists(outpath): cmd = ["mkdir", "-p", outpath] try: subprocess.check_call(cmd) except subprocess.CalledProcessError, e: print e raise
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outfile = "" infile = "" gramfile = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: infile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-gram", "--gram"]: (gramfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: infile = argv[i] i += 1 if myfunc.checkfile(infile) != 0: return 1 if myfunc.checkfile(gramfile) != 0: return 1 grampairlist = myfunc.ReadPairList(gramfile) gramMapDict = {} for tup in grampairlist: gramMapDict[tup[0]] = tup[1] gi2taxidpairlist = myfunc.ReadPairList(infile) fpout = myfunc.myopen(outfile, sys.stdout, "w", False) for tup in gi2taxidpairlist: try: fpout.write("%s\t%s\t%s\n" % (tup[0], tup[1], gramMapDict[tup[1]])) except KeyError: fpout.write("%s\t%s\t%s\n" % (tup[0], tup[1], "NA")) myfunc.myclose(fpout)
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "./" outfile = "" fileListFile = "" fileList = [] i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: fileList.append(argv[i]) isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-l", "--l"] : (fileListFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: fileList.append(argv[i]) i += 1 # if infile == "": # print >> sys.stderr, "infile not set" # print >> sys.stderr, usage_short # return 1 # elif not os.path.exists(infile): # print >> sys.stderr, "infile %s does not exist"%(infile) # return 1 if fileListFile != "": fileList += myfunc.ReadIDList(fileListFile) print "outfile = %s"%(outfile) print "Number of ID =", len(fileList) print "They are:" for i in xrange(len(fileList)): print "%d --> %s" %(i, fileList[i])
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" fileListFile = "" fileList = [] i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: fileList.append(argv[i]) isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-e", "--e"]: (g_params['evalue_threshold'], i) = myfunc.my_getopt_float(argv, i) elif argv[i] in ["-l", "--l"]: (fileListFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 elif argv[i] in ["-overwrite", "--overwrite", "-force", "--force"]: g_params['isOverwrite'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: fileList.append(argv[i]) i += 1 if fileListFile != "": fileList += myfunc.ReadIDList(fileListFile) if len(fileList) < 1: print >> sys.stderr, "%s: no input file is set. exit" % (sys.argv[0]) return 1 if outpath != "" and not os.path.exists(): cmd = ["mkdir", "-p", outpath] subprocess.check_output(cmd) for i in xrange(len(fileList)): Build_seqid2pfamid(fileList[i], outpath)
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" fileListFile = "" fileList = [] i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: fileList.append(argv[i]) isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath",]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-m", "--m"]: (g_params['method'], i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-md5", "--md5"]: (tmpstr, i) = myfunc.my_getopt_str(argv, i) if tmpstr.lower() == "yes": g_params['isUseMD5'] = True elif tmpstr.lower() == "no": g_params['isUseMD5'] = False else: print >> sys.stderr, "Bad syntax. option -md5 must be followed by yes or no" return 1 elif argv[i] in ["-l", "--l"] : (fileListFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: fileList.append(argv[i]) i += 1 if outpath != "" and not os.path.exists(outpath): cmd = ["mkdir","-p",outpath] try: subprocess.check_call(cmd) except subprocess.CalledProcessError, e: print e raise
def main(g_params): #{{{ # Check argv numArgv = len(sys.argv) if numArgv < 2: PrintHelp() return 1 outfile = "" fileList = [] fileListFile = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: fileList.append(sys.argv[i]) isNonOptionArg = False i += 1 elif sys.argv[i] == "--": isNonOptionArg = True i += 1 elif sys.argv[i][0] == "-": if sys.argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif sys.argv[i] in ["-l", "--l"]: fileListFile, i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in ["-o", "--o", "-outfile"]: outfile, i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in ["-evalue", "--evalue"]: g_params['evalue_th'], i = myfunc.my_getopt_float(sys.argv, i) elif sys.argv[i] in ["-seqidt", "--seqidt"]: g_params['seqidt_th'], i = myfunc.my_getopt_float(sys.argv, i) elif sys.argv[i] in ["-round", "--round"]: g_params['iteration'] = myfunc.my_getopt_int(sys.argv, i) else: print >> sys.stderr, ("Error! Wrong argument: '%s'" % sys.argv[i]) return 1 else: fileList.append(sys.argv[i]) i += 1 if fileListFile != "": fileList += myfunc.ReadIDList(fileListFile, delim="\n") if len(fileList) < 1: print >> sys.stderr, "No input set. exit" return 1 fpout = myfunc.myopen(outfile, sys.stdout, "w", False) for infile in fileList: BlastM9toPairlist(infile, fpout) myfunc.myclose(fpout)
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outfile = "" idListFile = "" idList = [] i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: idList.append(argv[i]) i += 1 isNonOptionArg = False elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-l", "--l", "-list"]: (idListFile, i) = myfunc.my_getopt_str(argv, i) else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: idList.append(argv[i]) i += 1 if idListFile != "": idList += myfunc.ReadIDList(idListFile) numID = len(idList) if numID < 1: print >> sys.stderr, "No ID set. exit" return 1 params = {} params['from'] = 'P_GI' params['to'] = 'ID' # to uniprot id params['format'] = 'tab' params['query'] = " ".join(idList) fpout = myfunc.myopen(outfile, sys.stdout, "w", False) GIID2UniprotID(params, fpout) myfunc.myclose(fpout)
def main(g_params): # Check argv numArgv = len(sys.argv) if numArgv < 2: PrintHelp() return 1 outFile = "" inFile = "" begin = 0 end = 999999999 method = 2 i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: isNonOptionArg = False i = i + 1 elif sys.argv[i] == "--": isNonOptionArg = True i = i + 1 elif sys.argv[i][0] == "-": if sys.argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif sys.argv[i] in ["-i", "--i", "--infile"]: inFile, i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in ["-b", "--b", "--begin"]: begin, i = myfunc.my_getopt_int(sys.argv, i) elif sys.argv[i] in ["-e", "--e", "--end"]: end, i = myfunc.my_getopt_int(sys.argv, i) elif sys.argv[i] in ["-o", "--o", "--outfile"]: outFile, i = myfunc.my_getopt_str(sys.argv, i) else: print >> sys.stderr, ("Error! Wrong argument:%s" % sys.argv[i]) return 1 else: inFile = sys.argv[i] i += 1 if myfunc.checkfile(inFile, "Input file") != 0: return 1 fpout = myfunc.myopen(outFile, sys.stdout, "w", False) if method == 1: CatFasta(inFile, begin, end, fpout) else: CatFasta2(inFile, begin, end, fpout) myfunc.myclose(fpout) return 0
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "./" outfile = "" fileListFile = "" fileList = [] pfamDefFile = "%s/data/pfam/pfam26.0/Pfam-A.clans.tsv"%(DATADIR3) i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: fileList.append(argv[i]) isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-l", "--l"] : (fileListFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: fileList.append(argv[i]) i += 1 if fileListFile != "": fileList += myfunc.ReadIDList(fileListFile) (pfamidDefDict, clanidDefDict) = ReadPfamDefFile(pfamDefFile) fpout = myfunc.myopen(outfile, sys.stdout, "w", False) for i in xrange(len(fileList)): CountUniquePairInvertedInfo(fileList[i], pfamidDefDict, fpout) myfunc.myclose(fpout)
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" pfamid2seqidFile = "" topodb = "" seqdb = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-pfamid2seqid", "--pfamid2seqid"]: (pfamid2seqidFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-seqdb", "--seqdb"]: (seqdb, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-topodb", "--topodb"]: (topodb, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 if outpath == "": print >> sys.stderr, "Error! outpath not set. Exit" print usage_short return 1 elif not os.path.exists(outpath): try: subprocess.check_output(["mkdir", "-p", outpath]) except subprocess.CalledProcessError, e: print e return 1
def main():#{{{ numArgv=len(sys.argv) if numArgv < 2: PrintHelp() return 1 argv = sys.argv topofile = "" sigpepfile = "" outfile = "" isQuiet = False isDeleteSeqWithSignalPeptide = False i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: isNonOptionArg = False i += 1 elif sys.argv[i] == "--": isNonOptionArg=True i += 1 elif sys.argv[i][0] == "-": if sys.argv[i] in [ "-h", "--help"]: PrintHelp() return 1 elif argv[i] in [ '-o', '--o', "-outfile", "--outfile"]: outfile, i = myfunc.my_getopt_str(argv, i) elif argv[i] in ['-topo', '--topo']: topofile, i = myfunc.my_getopt_str(argv, i) elif argv[i] in ['-sig', '--sig']: sigpepfile, i = myfunc.my_getopt_str(argv, i) elif argv[i] == "-q": isQuiet=True; i += 1 elif argv[i] in ["-deleteseq", "--deleteseq"]: isDeleteSeqWithSignalPeptide=True; i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 if myfunc.checkfile(topofile, 'topofile') != 0: return 1 if myfunc.checkfile(sigpepfile, 'sigpepfile') != 0: return 1 sigpepDict = lcmp.ReadSignalPDict(sigpepfile) FilterSignalPeptide(topofile, sigpepDict, outfile, isDeleteSeqWithSignalPeptide) return 0
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" outfile = "" fileListFile = "" fileList = [] i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: fileList.append(argv[i]) isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-l", "--l"]: (fileListFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: fileList.append(argv[i]) i += 1 if fileListFile != "": fileList += myfunc.ReadIDList(fileListFile) if outpath != "" and not os.path.exists(outpath): os.system("mkdir -p %s" % (outpath)) for i in xrange(len(fileList)): ExcludeConsensus(fileList[i], outpath)
def main(): #{{{ numArgv = len(sys.argv) if numArgv < 2: PrintHelp() return 1 outFile = "" inFile = "" N = 999999999 rand_seed = None i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: isNonOptionArg = False i = i + 1 elif sys.argv[i] == "--": isNonOptionArg = True i = i + 1 elif sys.argv[i][0] == "-": if sys.argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif sys.argv[i] in ["-i", "--infile"]: inFile, i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in ["-n", "--n"]: N, i = myfunc.my_getopt_int(sys.argv, i) elif sys.argv[i] in ["-seed", "--seed"]: rand_seed, i = myfunc.my_getopt_int(sys.argv, i) elif sys.argv[i] in ["-o", "--outfile"]: outFile, i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in ["-bs", "--block-size", "-block-size"]: BLOCK_SIZE, i = myfunc.my_getopt_int(sys.argv, i) if BLOCK_SIZE < 0: print("Error! BLOCK_SIZE should >0", file=sys.stderr) return 1 else: print(("Error! Wrong argument:%s" % sys.argv[i]), file=sys.stderr) return 1 else: inFile = sys.argv[i] i += 1 if myfunc.checkfile(inFile, "Input file") != 0: return 1 fpout = myfunc.myopen(outFile, sys.stdout, "w", False) RandFasta(inFile, N, rand_seed, fpout) myfunc.myclose(fpout)
def main():#{{{ numArgv=len(sys.argv) if numArgv < 2: PrintHelp() return 1 outFile="" inFile="" N=999999999 rand_seed=None i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: isNonOptionArg=False i = i + 1 elif sys.argv[i] == "--": isNonOptionArg=True i = i + 1 elif sys.argv[i][0] == "-": if sys.argv[i] in [ "-h", "--help"]: PrintHelp() return 1 elif sys.argv[i] in ["-i", "--infile"]: inFile, i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in [ "-n" , "--n"]: N,i = myfunc.my_getopt_int(sys.argv, i) elif sys.argv[i] in [ "-seed" , "--seed"]: rand_seed, i = myfunc.my_getopt_int(sys.argv, i) elif sys.argv[i] in [ "-o" , "--outfile"]: outFile,i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in [ "-bs" , "--block-size" , "-block-size"]: BLOCK_SIZE, i = myfunc.my_getopt_int(sys.argv, i) if BLOCK_SIZE < 0: print >> sys.stderr,"Error! BLOCK_SIZE should >0" return 1 else: print >> sys.stderr,("Error! Wrong argument:%s" % sys.argv[i]) return 1 else: inFile = sys.argv[i] i+=1 if myfunc.checkfile(inFile, "Input file") != 0: return 1 fpout = myfunc.myopen(outFile, sys.stdout, "w", False) RandFasta(inFile, N, rand_seed, fpout) myfunc.myclose(fpout)
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 resultdir = "" outfile = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-resultdir", "--resultdir"]: (resultdir, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-l", "--l"]: (fileListFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 if resultdir == "": print >> sys.stderr, "%s: resultdir not set. exit" % (sys.argv[0]) return 1 elif not os.path.exists(resultdir): print >> sys.stderr, "%s: resultdir %s does not exist. exit" % ( sys.argv[0], resultdir) return 1 CalculateQueue(resultdir, outfile)
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outfile = "" infile = "" mapfile = "" i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: infile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-map", "--map", "-mapfile"]: (mapfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: infile = argv[i] i += 1 if myfunc.checkfile(infile) != 0: return 1 if myfunc.checkfile(mapfile) != 0: return 1 clanid2pfamidDict = myfunc.ReadFam2SeqidMap(mapfile) pfamPercentTMDict = ReadPercentTM(infile) fpout = myfunc.myopen(outfile, sys.stdout, "w", False) GetPercentTMOfClan(pfamPercentTMDict, clanid2pfamidDict, fpout) myfunc.myclose(fpout)
def main(g_params): # {{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 resultdir = "" outfile = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: print >>sys.stderr, "Error! Wrong argument:", argv[i] return 1 isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-resultdir", "--resultdir"]: (resultdir, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-l", "--l"]: (fileListFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params["isQuiet"] = True i += 1 else: print >>sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: print >>sys.stderr, "Error! Wrong argument:", argv[i] return 1 if resultdir == "": print >>sys.stderr, "%s: resultdir not set. exit" % (sys.argv[0]) return 1 elif not os.path.exists(resultdir): print >>sys.stderr, "%s: resultdir %s does not exist. exit" % (sys.argv[0], resultdir) return 1 CalculateQueue(resultdir, outfile)
def main(): #{{{ numArgv = len(sys.argv) if numArgv < 2: PrintHelp() return 1 argv = sys.argv outfile = "" infile = "" output_format = "mfa" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: infile = sys.argv[i] isNonOptionArg = False i = i + 1 elif sys.argv[i] == "--": isNonOptionArg = True i = i + 1 elif sys.argv[i][0] == "-": if sys.argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif sys.argv[i] in ["-o", "--o"]: outfile, i = myfunc.my_getopt_str(argv, i) elif sys.argv[i] in ["-of", "--of"]: output_format, i = myfunc.my_getopt_str(argv, i) else: print >> sys.stderr, ("Error! Wrong argument:%s" % argv[i]) return 1 else: infile = argv[i] i += 1 if myfunc.checkfile(infile, "MSA file") != 0: return 1 fpout = myfunc.myopen(outfile, sys.stdout, "w", False) # detect the format of mpa files, the old format MPA2MSA(infile, output_format, fpout) myfunc.myclose(fpout)
def main(g_params): #{{{#{{{ # Check argv numArgv = len(sys.argv) if numArgv < 2: PrintHelp() return 1 outfile = "" infile = "" BLOCK_SIZE = 100000 isPrintID = False isJustPrintSum = False i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: isNonOptionArg = False infile = sys.argv[i] i = i + 1 elif sys.argv[i] == "--": isNonOptionArg = True i = i + 1 elif sys.argv[i][0] == "-": if sys.argv[i] in ["-h", "--help"]: PrintHelp() return 0 elif sys.argv[i] in ["-i", "--i", "-printid", "--printid"]: isPrintID = True i += 1 elif sys.argv[i] in ["-just-print-sum", "--just-print-sum"]: isJustPrintSum = True i += 1 elif sys.argv[i] in ["-o", "--o", "-outfile", "--outfile"]: outfile, i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in ["-bs", "--bs", "-block-size", "--block-size"]: BLOCK_SIZE, i = myfunc.my_getopt_int(sys.argv, i) if BLOCK_SIZE < 0: print("Error! BLOCK_SIZE should >0", file=sys.stderr) return 1 else: print(("Error! Wrong argument:%s" % sys.argv[i]), file=sys.stderr) return 1 else: infile = sys.argv[i] i += 1 if myfunc.checkfile(infile) != 0: return 1 fpout = myfunc.myopen(outfile, sys.stdout, "w", False) status = Getseqlen(infile, isPrintID, isJustPrintSum, BLOCK_SIZE, fpout) myfunc.myclose(fpout) return status
def main(g_params):#{{{#{{{ # Check argv numArgv=len(sys.argv) if numArgv < 2: PrintHelp() return 1 outfile = "" infile = "" BLOCK_SIZE = 100000 isPrintID = False isJustPrintSum = False i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: isNonOptionArg=False infile = sys.argv[i] i = i + 1 elif sys.argv[i] == "--": isNonOptionArg=True i = i + 1 elif sys.argv[i][0] == "-": if sys.argv[i] in ["-h", "--help"]: PrintHelp() return 0 elif sys.argv[i] in ["-i", "--i", "-printid", "--printid"]: isPrintID = True i += 1 elif sys.argv[i] in ["-just-print-sum", "--just-print-sum"]: isJustPrintSum = True i += 1 elif sys.argv[i] in [ "-o", "--o", "-outfile", "--outfile"]: outfile, i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in [ "-bs", "--bs", "-block-size", "--block-size"]: BLOCK_SIZE, i = myfunc.my_getopt_int(sys.argv, i) if BLOCK_SIZE < 0: print >> sys.stderr,"Error! BLOCK_SIZE should >0" return 1 else: print >> sys.stderr,("Error! Wrong argument:%s" % sys.argv[i]) return 1 else: infile=sys.argv[i] i += 1 if myfunc.checkfile(infile) != 0: return 1 fpout = myfunc.myopen(outfile, sys.stdout, "w", False) status = Getseqlen(infile, isPrintID, isJustPrintSum, BLOCK_SIZE, fpout) myfunc.myclose(fpout) return status
def main(g_params): # Check argv numArgv=len(sys.argv) if numArgv < 2: PrintHelp() return 1 outFile = "" inFile = "" begin = 0 end = 999999999 method = 2 i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: isNonOptionArg=False i = i + 1 elif sys.argv[i] == "--": isNonOptionArg=True i = i + 1 elif sys.argv[i][0] == "-": if sys.argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif sys.argv[i] in ["-i", "--i", "--infile"]: inFile, i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in ["-b", "--b", "--begin"]: begin, i = myfunc.my_getopt_int(sys.argv, i) elif sys.argv[i] in ["-e", "--e", "--end"]: end, i = myfunc.my_getopt_int(sys.argv, i) elif sys.argv[i] in ["-o" , "--o","--outfile"]: outFile, i = my_getopt_str(sys.argv,i ) else: print >> sys.stderr,("Error! Wrong argument:%s" % sys.argv[i]) return 1 else: inFile=sys.argv[i] i+=1 if myfunc.checkfile(inFile, "Input file") != 0: return 1 fpout = myfunc.myopen(outFile, sys.stdout, "w", False) if method == 1: CatFasta(inFile,begin, end, fpout) else: CatFasta2(inFile,begin, end, fpout) myfunc.myclose(fpout) return 0
def main(g_params): #{{{ argv = sys.argv outpath = '' numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 fileList = [] method = 0 i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: isNonOptionArg = False fileList.append(argv[i]) i = i + 1 elif argv[i] == "--": isNonOptionArg = True i = i + 1 elif argv[i][0] == "-": if argv[i] == "-h" or argv[i] == "--help": PrintHelp() sys.exit(0) elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-m", "--m"]: (method, i) = myfunc.my_getopt_int(argv, i) else: print >> sys.stderr, ("Error! Wrong argument:%s" % argv[i]) return 1 else: fileList.append(argv[i]) i += 1 if len(fileList) < 1: print >> sys.stderr, "No input set" return 1 cnt = 0 for treefile in fileList: print "================== ", cnt, treefile, " ====================" if method == 0: Itol_Tree_m0(treefile, outpath, method) elif method == 1: Itol_Tree_m1(treefile, outpath, method) cnt += 1
def main(g_params): #{{{ argv = sys.argv datapath = '' ext = "" outpath = '' fileList = [] fileListFile = '' i = 1 numArgv = len(argv) if numArgv < 2: PrintHelp() return () isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: isNonOptionArg = False fileList.append(argv[i]) i = i + 1 elif argv[i] == "--": isNonOptionArg = True i = i + 1 elif argv[i][0] == "-": if argv[i] == "-h" or argv[i] == "--help": PrintHelp() return (0) elif argv[i] == "-outpath" or argv[i] == "--outpath": (outpath, i) = myfunc.my_getopt_str(argv, i) else: print(("Error! Wrong argument:%s" % argv[i]), file=sys.stderr) return (1) else: fileList.append(argv[i]) i += 1 if fileListFile != "": fileList += myfunc.ReadIDList(fileListFile) if len(fileList) <= 0: print("No input set. Exit", file=sys.stderr) return (1) else: cnt = 0 for treefile in fileList: print("================== ", cnt, treefile, " ====================") GetTreeListOrder(treefile, outpath) cnt += 1
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" infile = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: infile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: infile = argv[i] i += 1 if myfunc.checkfile(infile) != 0: return 1 if outpath == "": print >> sys.stderr, "outpath not set" elif not os.path.exists(outpath): os.system("mkdir -p %s" % (outpath)) SplitPfamFasta(infile, outpath)
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outfile = "" infile = "" i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: infile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: infile = argv[i] i += 1 if myfunc.checkfile(infile) != 0: return 1 fpout = myfunc.myopen(outfile, sys.stdout, "w", False) goancDict = myfunc.myclose(fpout)
def main(): #{{{ numArgv = len(sys.argv) if numArgv < 2: PrintHelp() return 1 argv = sys.argv outfile = "" infile = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: infile = sys.argv[i] isNonOptionArg = False i = i + 1 elif sys.argv[i] == "--": isNonOptionArg = True i = i + 1 elif sys.argv[i][0] == "-": if sys.argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif sys.argv[i] in ["-o", "--o"]: outfile, i = myfunc.my_getopt_str(argv, i) else: print >> sys.stderr, ("Error! Wrong argument:%s" % argv[i]) return 1 else: infile = argv[i] i += 1 if myfunc.checkfile(infile) != 0: return 1 return ReWriteFasta(infile, outfile)
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outfile = "" outfile_with_famid = "" outfile_with_pdb = "" outfile_fam2seqmap = "" idListFile = "" mapfile = "%s%s%s" % ( DATADIR3, os.sep, "wk/MPTopo/pfamAna_refpro/pfammap_from_uniprot/refpro20120604-celluar.selmaxlength-m1.nr100.filter.fragmented.clanid2seqid" ) restrictIDListFile = "" idList = [] maxseq_for_fam = 200 maxpair_for_fam = 300 method = 0 rand_seed = None pdbtospFile = "" isOnlyPDB = False i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: idList.append(argv[i]) isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile", "--outfile"]: outfile, i = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-outwithfamid", "--outwithfamid"]: outfile_with_famid, i = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-outfam2seqmap", "--outfam2seqmap"]: outfile_fam2seqmap, i = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-outwithpdb", "--outwithpdb"]: outfile_with_pdb, i = myfunc.my_getopt_str(argv, i) elif argv[i] in [ "-tmprolist", "--tmprolist", "-restrictlist", "--restrictlist" ]: restrictIDListFile, i = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-mapfile", "--mapfile"]: mapfile, i = myfunc.my_getopt_str(argv, i) elif (argv[i] in ["-pdbtosp", "--pdbtosp"]): pdbtospFile, i = myfunc.my_getopt_str(argv, i) elif sys.argv[i] in ["-seed", "--seed"]: rand_seed, i = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-l", "--l"]: idListFile, i = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-maxseq", "--maxseq"]: maxseq_for_fam, i = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-maxpair", "--maxpair"]: maxpair_for_fam, i = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-m", "--m", "-method", "--method"]: method, i = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-q"]: g_params['isQuiet'] = True i += 1 elif argv[i] in ["-onlypdb", "--onlypdb"]: g_params['isOnlyPDB'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: idList.append(argv[i]) i += 1 if os.path.exists(idListFile): idList += myfunc.ReadIDList(idListFile) if len(idList) < 1: print >> sys.stderr, "no ID set. exit" return 1 if myfunc.checkfile(mapfile, "idMapFile") != 0: return 1 idMapDict = myfunc.ReadFam2SeqidMap(mapfile) # Read in pdbtosp map if pdbtospFile != "": (pdb2uniprotMap, uniprot2pdbMap) =\ myfunc.ReadPDBTOSP(pdbtospFile) g_params['uniprotidlist_with_pdb'] = set(uniprot2pdbMap.keys()) g_params['uniprot2pdbMap'] = uniprot2pdbMap if g_params['isOnlyPDB'] == True: if pdbtospFile == "": print >> sys.stderr, "onlypdb is true but pdbtospFile is not set. exit." return 1 elif g_params['uniprotidlist_with_pdb'] == set([]): print >> sys.stderr, "onlypdb is true but uniprotidlist_with_pdb is empty. exit." return 1 restrictIDSet = set([]) if restrictIDListFile != "": restrictIDSet = set(myfunc.ReadIDList(restrictIDListFile)) fpout = myfunc.myopen(outfile, sys.stdout, "w", False) fpout_withfamid = myfunc.myopen(outfile_with_famid, None, "w", False) fpout_withpdb = myfunc.myopen(outfile_with_pdb, None, "w", False) fpout_fam2seqmap = myfunc.myopen(outfile_fam2seqmap, None, "w", False) if method == 0: GeneratePairWithinFam_m_0(idList, idMapDict, restrictIDSet, maxseq_for_fam, rand_seed, fpout, fpout_withfamid) elif method == 1: GeneratePairWithinFam_m_1(idList, idMapDict, restrictIDSet, maxpair_for_fam, rand_seed, fpout, fpout_withfamid, fpout_fam2seqmap) elif method == 2: #all to all GeneratePairWithinFam_m_2(idList, idMapDict, restrictIDSet, fpout, fpout_withfamid, fpout_withpdb) myfunc.myclose(fpout) myfunc.myclose(fpout_withfamid) myfunc.myclose(fpout_withpdb) myfunc.myclose(fpout_fam2seqmap) return 0
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outfile = "" idListFile = "" euk = "" gram_pos = "" gram_neg = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: idListFile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-euk", "--euk"]: (euk, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-gram+", "--gram+"]: (gram_pos, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-gram-", "--gram-"]: (gram_neg, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: idListFile = argv[i] i += 1 if myfunc.checkfile(idListFile, "idListFile") != 0: return 1 if myfunc.checkfile(euk, "euk") != 0: return 1 if myfunc.checkfile(gram_pos, "gram_pos") != 0: return 1 if myfunc.checkfile(gram_neg, "gram_neg") != 0: return 1 idList = myfunc.ReadIDList(idListFile) set_euk_idlist = set(myfunc.ReadIDList(euk)) set_gram_pos_idlist = set(myfunc.ReadIDList(gram_pos)) set_gram_neg_idlist = set(myfunc.ReadIDList(gram_neg)) fpout = myfunc.myopen(outfile, sys.stdout, "w", False) NCBI_TaxID = "" for i in xrange(len(idList)): seqid = idList[i] cls = "" if seqid in set_euk_idlist: cls = "euk" elif seqid in set_gram_pos_idlist: cls = "gram+" elif seqid in set_gram_neg_idlist: cls = "gram-" else: cls = "NA" print >> fpout, "%s\t%s\t%s" % (seqid, NCBI_TaxID, cls) myfunc.myclose(fpout)
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" modelfile = "" seqfile = "" tmpdir = "" email = "" jobid = "" isKeepFiles = "no" isRepack = "yes" targetlength = None i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: modelfile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-tmpdir", "--tmpdir"] : (tmpdir, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-jobid", "--jobid"] : (jobid, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-fasta", "--fasta"] : (seqfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-k", "--k"] : (isKeepFiles, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-r", "--r"] : (isRepack, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-t", "--t"] : (targetlength, i) = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-baseurl", "--baseurl"] : (g_params['base_www_url'], i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-email", "--email"] : (email, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 elif argv[i] in ["-force", "--force"]: g_params['isForceRun'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: modelfile = argv[i] i += 1 if jobid == "": print >> sys.stderr, "%s: jobid not set. exit"%(sys.argv[0]) return 1 if myfunc.checkfile(modelfile, "modelfile") != 0: return 1 if outpath == "": print >> sys.stderr, "outpath not set. exit" return 1 elif not os.path.exists(outpath): try: subprocess.check_output(["mkdir", "-p", outpath]) except subprocess.CalledProcessError, e: print >> sys.stderr, e return 1
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outfile = "" msafile = "" topofile = "" topodb = "" isIgnoreBadseq = True method_match = 1 i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: print("Error! Wrong argument:", argv[i], file=sys.stderr) return 1 isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-msa", "--msa"]: (msafile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-topo", "--topo"]: (topofile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-m", "--m"]: (method_match, i) = myfunc.my_getopt_int(argv, i) if method_match not in [0, 1]: print("method_match %d not in [0,1]" % method_match, file=sys.stderr) return 1 elif argv[i] in ["-topodb", "--topodb"]: (topodb, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in [ "-ig", "--ig", "-ignore-badseq", "--ignore-badseq" ]: (tmpss, i) = myfunc.my_getopt_str(argv, i) if tmpss[0].lower() == "y": isIgnoreBadseq = True else: isIgnoreBadseq = False elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print("Error! Wrong argument:", argv[i], file=sys.stderr) return 1 else: print("Error! Wrong argument:", argv[i], file=sys.stderr) return 1 if myfunc.checkfile(msafile) != 0: return 1 if topodb != "": if not os.path.exists(topodb + '0.db'): print("topodb %s does not exist" % (topodb), file=sys.stderr) return 1 else: return MatchMSATopo_using_topodb(msafile, topodb, isIgnoreBadseq, method_match, outfile) elif topofile != "": if not os.path.exists(topofile): print("topofile %s does not exist" % (topofile), file=sys.stderr) return 1 else: return MatchMSATopo_using_topofile(msafile, topofile, isIgnoreBadseq, method_match, outfile) else: print("neither topofile nor topodb is set. exit", file=sys.stderr) return 1 return 0
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 rmsg = "" outpath = "" jobid = "" datapath = "" numseq = -1 numseq_this_user = -1 email = "" host_ip = "" base_www_url = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: print >> g_params['fperr'], "Error! Wrong argument:", argv[i] return 1 isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-email", "--email"]: (email, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-host", "--host"]: (host_ip, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-nseq", "--nseq"]: (numseq, i) = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-nseq-this-user", "--nseq-this-user"]: (numseq_this_user, i) = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-baseurl", "--baseurl"]: (base_www_url, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-jobid", "--jobid"]: (jobid, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-datapath", "--datapath"]: (datapath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-force", "--force"]: g_params['isForceRun'] = True i += 1 elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> g_params['fperr'], "Error! Wrong argument:", argv[i] return 1 else: print >> g_params['fperr'], "Error! Wrong argument:", argv[i] return 1 if outpath == "": print >> g_params['fperr'], "outpath not set. exit" return 1 elif not os.path.exists(outpath): cmd = ["mkdir", "-p", outpath] try: rmsg = subprocess.check_output(cmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError, e: print e print rmsg return 1
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outfile = "" datapath = "" idListFile = "" idList = [] ext = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: idList.append(argv[i]) isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-ext", "--ext"]: (ext, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-datapath", "--datapath"]: (datapath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-l", "--l"]: (idListFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: idList.append(argv[i]) i += 1 if ext == "": print >> sys.stderr, "file extension not set. exit" return 1 if datapath == "": print >> sys.stderr, "datapath not set. exit" return 1 elif not os.path.exists(datapath): print >> sys.stderr, "datapath %s does not exist. exit" % (datapath) return 1 if idListFile != "": idList += myfunc.ReadIDList(idListFile) if len(idList) < 1: print >> sys.stderr, "No input set. exit" return 1 fpout = sys.stdout if outfile != "": fpout = myfunc.myopen(outfile, sys.stdout, "w", False) id2pathmapfile = "%s%s%s" % (datapath, os.sep, "id2pathmap.txt") id2pathMapDict = myfunc.ReadIDPathMapDict(id2pathmapfile) for idd in idList: filename = ID2File(idd, datapath, id2pathMapDict, ext) if filename != "": print >> fpout, filename if outfile != "": myfunc.myclose(fpout)
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" infile = "" tmpdir = "" email = "" jobid = "" i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: infile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-tmpdir", "--tmpdir"] : (tmpdir, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-jobid", "--jobid"] : (jobid, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-baseurl", "--baseurl"] : (g_params['base_www_url'], i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-email", "--email"] : (email, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 elif argv[i] in ["-force", "--force"]: g_params['isForceRun'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: infile = argv[i] i += 1 if jobid == "": print >> sys.stderr, "%s: jobid not set. exit"%(sys.argv[0]) return 1 g_params['jobid'] = jobid # create a lock file in the resultpath when run_job.py is running for this # job, so that daemon will not run on this folder lockname = "runjob.lock" lock_file = "%s/%s/%s"%(path_result, jobid, lockname) g_params['lockfile'] = lock_file fp = open(lock_file, 'w') try: fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: print >> sys.stderr, "Another instance of %s is running"%(progname) return 1 if myfunc.checkfile(infile, "infile") != 0: return 1 if outpath == "": print >> sys.stderr, "outpath not set. exit" return 1 elif not os.path.exists(outpath): cmd = ["mkdir", "-p", outpath] (t_isCmdSuccess, t_runtime) = webcom.RunCmd(cmd, gen_logfile, gen_errfile) if not t_isCmdSuccess: return 1 if tmpdir == "": print >> sys.stderr, "tmpdir not set. exit" return 1 elif not os.path.exists(tmpdir): cmd = ["mkdir", "-p", tmpdir] (t_isCmdSuccess, t_runtime) = webcom.RunCmd(cmd, gen_logfile, gen_errfile) if not t_isCmdSuccess: return 1 numseq = myfunc.CountFastaSeq(infile) g_params['debugfile'] = "%s/debug.log"%(outpath) return RunJob(infile, outpath, tmpdir, email, jobid, g_params)
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "./" listfile = "" hhprofilepathList = [] hhalignpathList = [] nonPosArgList = [] i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: nonPosArgList.append(argv[i]) isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in [ "-hhprofile", "--hhprofile", "-hhprofile1", "--hhprofile1" ]: (ss, i) = myfunc.my_getopt_str(argv, i) hhprofilepathList.append(ss) elif argv[i] in ["-hhalign", "--hhalign"]: (ss, i) = myfunc.my_getopt_str(argv, i) hhalignpathList.append(ss) elif argv[i] in ["-l", "--l"]: (listfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-hhopt", "--hhopt"]: g_params['hhalignopt'] = argv[i + 1] i += 2 elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 elif argv[i] in ["-outpng", "--outpng"]: g_params['isOutputPNG'] = True i += 1 elif argv[i] in ["-outhfa", "--outhfa"]: g_params['isOutputHFA'] = True i += 1 elif argv[i] in ["-overwrite", "-forcewrite", "--forcewrite"]: g_params['isForceOverWrite'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: nonPosArgList.append(argv[i]) i += 1 if len(hhprofilepathList) < 1: print >> sys.stderr, "hhprofilepath not set. exit" return 1 pairlist = [] if len(nonPosArgList) == 2: pairlist.append((nonPosArgList[0], nonPosArgList[1])) elif len(nonPosArgList) > 0: msg = "Wrong number of non positional argument (%d)" print >> sys.stderr, msg % (len(nonPosArgList)) return 1 if listfile != "": pairlist += myfunc.ReadPairList(listfile) numpair = len(pairlist) if numpair <= 0: print >> sys.stderr, "input pair is 0, exit" return 1 if not os.path.exists(outpath): try: os.makedirs(outpath) except OSError: pass if not os.path.exists(outpath): print >> sys.stderr, "failed to created outpath %s" % (outpath) return 1 # read in hhprofile dict hhprofilepathMapDictList = [] for hhprofilepath in hhprofilepathList: hhprofilemapfile = hhprofilepath + os.sep + "id2pathmap.txt" if not os.path.exists(hhprofilemapfile): print >> sys.stderr, "hhprofilemapfile not exist. exit" hhprofilepathMapDictList.append({}) else: hhprofilepathMapDictList.append( ReadSeqPathMapDict(hhprofilemapfile)) #print #print hhprofilemapfile #print ReadSeqPathMapDict(hhprofilemapfile) # read in index dictionary for hhalign result file hhalignpathMapDictList = [] if len(hhalignpathList) > 0: g_params['isUsePreBuildHHalignResult'] = True for hhalignpath in hhalignpathList: hhalignmapfile = hhalignpath + os.sep + "id2pathmap.txt" if not os.path.exists(hhalignmapfile): print >> sys.stderr, "hhalignmapfile not exist. exit" hhalignpathMapDictList.append({}) else: hhalignpathMapDictList.append( ReadSeqPathMapDict(hhalignmapfile)) RunHHAlignPairwise(pairlist, hhprofilepathList, hhprofilepathMapDictList, hhalignpathList, hhalignpathMapDictList, outpath) return 0
def main(g_params): #{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outfile = "" infile = "" gramPositiveFile = "" gramNegativeFile = "" eukFile = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: infile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-o", "--o", "-outfile"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-gram+", "--gram+"]: (gramPositiveFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-gram-", "--gram-"]: (gramNegativeFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-euk", "--euk"]: (eukFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 elif argv[i] in ["-debug", "--debug"]: g_params['isDEBUG'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: infile = argv[i] i += 1 if myfunc.checkfile(infile, "taxidwithtaxoFile") != 0: return 1 if myfunc.checkfile(gramPositiveFile, "gramPositiveFile") != 0: return 1 if myfunc.checkfile(gramNegativeFile, "gramNegativeFile") != 0: return 1 if myfunc.checkfile(eukFile, "eukFile") != 0: return 1 gramPositiveDict = ReadSignalPFile(gramPositiveFile) gramNegativeDict = ReadSignalPFile(gramNegativeFile) eukDict = ReadSignalPFile(eukFile) fpout = myfunc.myopen(outfile, sys.stdout, "w", False) hdl = myfunc.ReadLineByBlock(infile) if hdl.failure: return 1 lines = hdl.readlines() while lines != None: for line in lines: strs = line.split("\t") if len(strs) == 3: seqid = strs[0].strip() taxo = strs[2].strip() info = "" try: if taxo == "Gram+" or taxo == "gram+": info = gramPositiveDict[seqid] elif taxo == "Gram-" or taxo == "gram-": info = gramNegativeDict[seqid] elif taxo == "Euk" or taxo == "euk": info = eukDict[seqid] if g_params['isDEBUG']: print >> sys.stderr, "%s: %s" % (seqid, taxo) except KeyError: info = "" if info != "": fpout.write("%s\n" % info) lines = hdl.readlines() hdl.close() myfunc.myclose(fpout)
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "./" tableinfoFile = "" hhprofilepathList = [] hhsearchpathList = [] dupfile = "" topofile = "" # /data3/wk/MPTopo/pfamAna_refpro/pred_topcons_single_method4/refpro20120604-celluar.selmaxlength-m1.topcons-single_topcons_single.m1.agree-44.topo i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: tableinfoFile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-hhprofile", "--hhprofile", "-hhprofile1", "--hhprofile1"] : (ss, i) = myfunc.my_getopt_str(argv, i) hhprofilepathList.append(ss) elif argv[i] in ["-hhsearch", "--hhsearch"] : (ss, i) = myfunc.my_getopt_str(argv, i) hhsearchpathList.append(ss) elif argv[i] in ["-dupfile", "--dupfile"] : (dupfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-topofile", "--topofile"] : (topofile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-l", "--l"] : (tableinfoFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True; i += 1 elif argv[i] in ["-overwrite", "-forcewrite", "--forcewrite"]: g_params['isForceOverWrite'] = True; i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: tableinfoFile = argv[i] i += 1 if tableinfoFile == "": print >> sys.stderr, "tableinfoFile not set. exit" return 1 if len(hhprofilepathList) < 1: print >> sys.stderr, "hhprofilepath not set. exit" return 1 if not os.path.exists(outpath): os.makedirs(outpath) if not os.path.exists(outpath): print >> sys.stderr, "failed to created outpath %s"%(outpath) return 1 topoDict = {} if topofile != "": (idList, topoList) = myfunc.ReadFasta_without_annotation(topofile) for i in xrange(len(idList)): topoDict[idList[i]] = topoList[i] if dupfile != "" and topoDict == {}: print >> sys.stderr, "Error! topoDict is empty when dupfile"\ "is set. Exit" return 1 # read in hhprofile dict hhprofilepathMapDictList = [] for hhprofilepath in hhprofilepathList: hhprofilemapfile = hhprofilepath + os.sep + "id2pathmap.txt" if not os.path.exists(hhprofilemapfile): print >> sys.stderr, "hhprofilemapfile not exist. exit" hhprofilepathMapDictList.append({}) else: hhprofilepathMapDictList.append(ReadSeqPathMapDict(hhprofilemapfile)) #print #print hhprofilemapfile #print ReadSeqPathMapDict(hhprofilemapfile) # read in index dictionary for hhsearch result file hhsearchpathMapDictList = [] if len(hhsearchpathList) > 0: g_params['isUsePreBuildHHSearchResult'] = True for hhsearchpath in hhsearchpathList: hhsearchmapfile = hhsearchpath + os.sep + "id2pathmap.txt" if not os.path.exists(hhsearchmapfile): print >> sys.stderr, "hhsearchmapfile not exist. exit" hhsearchpathMapDictList.append({}) else: hhsearchpathMapDictList.append(ReadSeqPathMapDict(hhsearchmapfile)) RunHHSearchPairwise(tableinfoFile, hhprofilepathList, hhprofilepathMapDictList, hhsearchpathList, hhsearchpathMapDictList, topoDict, outpath, dupfile) return 0
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 datapath = "." outpath = './' idList = [] idListFile = '' treefile = "" fastafile = "" i = 1; isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: isNonOptionArg=False; idList.append(sys.argv[i]) i = i + 1; elif sys.argv[i] == "--": isNonOptionArg=True; i = i + 1; elif sys.argv[i][0] == "-": if sys.argv[i] in [ "-h", "--help"]: PrintHelp(); return 1 elif sys.argv[i] in [ "-datapath", "--datapath"]: datapath = sys.argv[i+1] i += 2; elif argv[i] in [ "-m", "--m", "-method", "--method"]: g_params['method'], i = myfunc.my_getopt_str(sys.argv, i) elif sys.argv[i] in [ "-treefile", "--treefile"]: treefile = sys.argv[i+1] i += 2; elif sys.argv[i] in [ "-fastafile", "--fastafile"]: fastafile = sys.argv[i+1] i += 2; elif sys.argv[i] in [ "-l", "--l"]: idListFile = sys.argv[i+1] i = i + 2; elif sys.argv[i] in ["-outpath", "--outpath"]: outpath = sys.argv[i+1]; i = i + 2; else: print(("Error! Wrong argument:%s" % sys.argv[i]), file=sys.stderr); return 1 else: idList.append(sys.argv[i]); i+=1; if idListFile != "": idList += myfunc.ReadIDList(idListFile) if len(idList) > 0: os.system("mkdir -p %s"%outpath) cnt = 0 for pfamid in idList: print("================== ", cnt , pfamid, " ====================") if g_params['method'] == "0": Itol_Tree_m0(pfamid, datapath, outpath) elif g_params['method'] == "1": Itol_Tree_m1(pfamid, datapath, outpath) elif g_params['method'] == "sd1": Itol_Tree_m_sd1(pfamid, datapath, outpath) elif g_params['method'] == "sd2": Itol_Tree_m_sd2(pfamid, datapath, outpath) elif g_params['method'] == "sd3": Itol_Tree_m_sd3(pfamid, datapath, outpath) cnt += 1 if treefile != "": if g_params['method'] == "linear": Itol_Tree_linear(treefile, fastafile, outpath)
def main(g_params): #{{{ argv = sys.argv numArgv = len(sys.argv) if numArgv < 2: PrintHelp() return 1 infile = "" outpath = "./" isQuiet = False tableinfoFile = "" cmpclassList = [] restrictIDListFile = "" signalpFile = "" dupFile = "" outfile = "" i = 1 isNonOptionArg = False while i < numArgv: if isNonOptionArg == True: infile = sys.argv[i] isNonOptionArg = False i += 1 elif sys.argv[i] == "--": isNonOptionArg = True i += 1 elif sys.argv[i][0] == "-": if sys.argv[i] in ["-h", "--help"]: PrintHelp() sys.exit() elif argv[i] in ["-o", "--o"]: (outfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-cmpclass", "--cmpclass"]: (tmpstr, i) = myfunc.my_getopt_str(argv, i) cmpclassList.append(tmpstr) elif argv[i] in ["-signalp", "--signalp"]: (signalpFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-restrictidlist", "--restrictidlist"]: (restrictIDListFile, i) = myfunc.my_getopt_str(argv, i) g_params['isRestrictIDListSet'] = True elif argv[i] in ["-dup", "--dup", "-dupfile", "--dupfile"]: (dupFile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-rmsp", "--rmsp"]: g_params['isRemoveSignalP'] = True i += 1 elif argv[i] in ["-rmdup", "--rmdup"]: g_params['isRemoveDup'] = True i += 1 elif argv[i] in ["-seq2fammap", "--seq2fammap"]: (seq2famMapfile, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-seqidttype", "--seqidttype"]: g_params['seqidttype'], i = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-tableinfo", "--tableinfo"]: tableinfoFile, i = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-min-seqidt", "--min-seqidt"]: g_params['minSeqIDT'], i = myfunc.my_getopt_float(argv, i) elif argv[i] in ["-max-seqidt", "--max-seqidt"]: g_params['maxSeqIDT'], i = myfunc.my_getopt_float(argv, i) elif argv[i] in ["-evodist", "--evodist"]: g_params['isEvodist'] = True i += 1 elif argv[i] in ["-alignrange", "--alignrange"]: g_params['alignrange'], i = myfunc.my_getopt_str(argv, i) if not g_params['alignrange'] in ['all', 'full', 'part']: print >> sys.stderr, "alignrange must be one of [all, full, part]" return 1 else: if g_params['alignrange'] == 'full': g_params['alignrange'] = 'FULL_ALIGNED' elif g_params['alignrange'] == 'part': g_params['alignrange'] = 'PART_ALIGNED' elif argv[i] in ["-debug", "--debug"]: if argv[i + 1][0].lower() == 'y': g_params['isDEBUG'] = True else: g_params['isDEBUG'] = False i += 2 elif argv[i] in [ "-debug-unmapped-position", "--debug-unmapped-position" ]: DEBUG_UNMAPPED_TM_POSITION = 1 i += 2 elif sys.argv[i] == "-q": isQuiet = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", sys.argv[i] return -1 else: infile = sys.argv[i] i += 1 if infile == "": print >> sys.stderr, "infile not set. Exit." return -1 elif not os.path.exists(infile): print >> sys.stderr, "infile %s does not exists. Exit." % infile try: fpin = open(infile, "rb") except IOError: print >> sys.stderr, "Failed to open input file %s" % (infile) return -1 pairalnStat = {} if g_params['seqidttype'] != 0: if tableinfoFile == "" or not os.path.exists(tableinfoFile): print >> sys.stderr, "tableinfoFile must be set when seqidttype is set to 1 or 2" print >> sys.stderr, "but seqidttype = %d is set. Exit." % g_params[ 'seqidttype'] return -1 pairalnStat = lcmp.ReadPairAlnTableInfo(tableinfoFile) rootname = os.path.basename(os.path.splitext(infile)[0]) binpath = os.path.dirname(sys.argv[0]) signalpDict = {} if signalpFile != "": signalpDict = lcmp.ReadSignalPDict(signalpFile) if signalpDict != {}: g_params['isSignalPSet'] = True dupPairList = [] if dupFile != "": dupPairList = lcmp.ReadDupPairList(dupFile) if len(dupPairList) > 0: g_params['isDupSet'] = True dupPairSet = set(dupPairList) restrictIDSet = set([]) if restrictIDListFile != "": restrictIDSet = set(myfunc.ReadIDList(restrictIDListFile)) rltyDict = {} fpout = myfunc.myopen(outfile, sys.stdout, "w", False) unprocessedBuffer = "" cntTotalReadInRecord = 0 cntTotalOutputRecord = 0 isEOFreached = False while 1: buff = fpin.read(BLOCK_SIZE) if buff == "": isEOFreached = True buff = unprocessedBuffer + buff pairCmpRecordList = [] unprocessedBuffer = lcmp.ReadPairCmpResultFromBuffer( buff, pairCmpRecordList) AddTableInfo(pairCmpRecordList, pairalnStat) AddSignalPInfo(pairCmpRecordList, signalpDict) AddDupInfo(pairCmpRecordList, dupPairSet) cntTotalReadInRecord += len(pairCmpRecordList) pairCmpRecordList = FilterPairCmpResult(pairCmpRecordList, cmpclassList, rltyDict, restrictIDSet) if len(pairCmpRecordList) > 0: lcmp.WritePairCmpRecord(pairCmpRecordList, cntTotalOutputRecord, fpout) cntTotalOutputRecord += len(pairCmpRecordList) if isEOFreached == True: break fpin.close() print "cntTotalReadInRecord =", cntTotalReadInRecord print "cntTotalOutputRecord =", cntTotalOutputRecord myfunc.myclose(fpout) return 0
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 rmsg = "" outpath = "" jobid = "" datapath = "" numseq = -1 numseq_this_user = -1 email = "" host_ip = "" base_www_url = "" i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: print >> g_params['fperr'], "Error! Wrong argument:", argv[i] return 1 isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-email", "--email"]: (email, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-host", "--host"]: (host_ip, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-nseq", "--nseq"]: (numseq, i) = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-nseq-this-user", "--nseq-this-user"]: (numseq_this_user, i) = myfunc.my_getopt_int(argv, i) elif argv[i] in ["-baseurl", "--baseurl"]: (base_www_url, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-jobid", "--jobid"] : (jobid, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-datapath", "--datapath"] : (datapath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-force", "--force"]: g_params['isForceRun'] = True i += 1 elif argv[i] in ["-runlocal", "--runlocal"]: g_params['isRunLocal'] = True i += 1 elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> g_params['fperr'], "Error! Wrong argument:", argv[i] return 1 else: print >> g_params['fperr'], "Error! Wrong argument:", argv[i] return 1 if outpath == "": print >> g_params['fperr'], "outpath not set. exit" return 1 elif not os.path.exists(outpath): cmd = ["mkdir", "-p", outpath] try: rmsg = subprocess.check_output(cmd, stderr=subprocess.STDOUT) except subprocess.CalledProcessError, e: print e print rmsg return 1
def main(g_params):#{{{ argv = sys.argv numArgv = len(argv) if numArgv < 2: PrintHelp() return 1 outpath = "" infile = "" tmpdir = "" email = "" jobid = "" i = 1 isNonOptionArg=False while i < numArgv: if isNonOptionArg == True: infile = argv[i] isNonOptionArg = False i += 1 elif argv[i] == "--": isNonOptionArg = True i += 1 elif argv[i][0] == "-": if argv[i] in ["-h", "--help"]: PrintHelp() return 1 elif argv[i] in ["-outpath", "--outpath"]: (outpath, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-tmpdir", "--tmpdir"] : (tmpdir, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-jobid", "--jobid"] : (jobid, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-baseurl", "--baseurl"] : (g_params['base_www_url'], i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-email", "--email"] : (email, i) = myfunc.my_getopt_str(argv, i) elif argv[i] in ["-q", "--q"]: g_params['isQuiet'] = True i += 1 else: print >> sys.stderr, "Error! Wrong argument:", argv[i] return 1 else: infile = argv[i] i += 1 if jobid == "": print >> sys.stderr, "%s: jobid not set. exit"%(sys.argv[0]) return 1 if myfunc.checkfile(infile, "infile"): return 1 if outpath == "": print >> sys.stderr, "outpath not set. exit" return 1 elif not os.path.exists(outpath): try: myfunc.check_output(["mkdir", "-p", outpath]) except subprocess.CalledProcessError, e: print >> sys.stderr, e return 1