"have this increment: ex: #>10000 " "Default: 10000 ") ], [ "counts", "counts", argflag, False, ("Graph counts instead of bases ie. number of reads") ], [ "out", "out", str, "cellstats.pdf", ("Output filename. Default: 'cellstats.pdf'") ]] arguments = map(CLArgument._make, argument_list) if not len(sys.argv) > 1: sys.exit(getHelpStr(description, arguments) + "\n") (p_arg_map, args_remaining) = parseArgs(sys.argv[1:], arguments) if not len(args_remaining) >= 1: sys.exit(getHelpStr(description, arguments) + "\n") title = args_remaining[0] infiles = args_remaining[1:] cellnames = map(lambda f: "_".join(f.split(".")[0].split("_")[:2]), infiles) fit_gen = lambda filename: fileIterator(filename, lineItemIterator) file_iterators = map(fit_gen, infiles)
from seqio import iteratorFromExtension, seqlen, recordToString from nucio import fileIterator from args import parseArgs, getHelpStr, CLArgument description = ( "Usage: length_filter.py [options] min_length(int) in1.{fa.fq} [in2.{fa,fq} ...]\n\n" "Filter reads by their lengths" ) argument_list = [["maxlen", "maxlen", int, -1, "Maximum length of reads"]] arguments = map(CLArgument._make, argument_list) if not len(sys.argv) > 2: sys.exit(getHelpStr(description, arguments) + "\n") (p_arg_map, args_remaining) = parseArgs(sys.argv[1:], arguments) minlen = int(args_remaining[0]) files = args_remaining[1:] if not all(map(os.path.exists, files)): sys.exit("Not all files exist") file_readers = starmap(fileIterator, zip(files, map(iteratorFromExtension, files))) filt_cond = lambda record: seqlen(record) > minlen if p_arg_map["maxlen"] > 1:
description = ("lengthhist.py [options] title alginments.m4 [alignments2.m4...]\n" "Plot Make histograms from alignment (nucmer show-coords) " "files") argument_list = [["labels","labels",arglist,["Ectools","PacbioToCA"], "Labels for each dataset"], ["ymax", "ymax", int, -1, "Maximum Y-value"], ["lenfiles", "lenfiles", int, -1, ("Input files are just a column of lengths, " "argument specifies the column")]] args = map(CLArgument._make, argument_list) (parg_map, args_remaining) = parseArgs(sys.argv[1:],args) if not len(args_remaining) >= 3: sys.exit(getHelpStr(description,args) + "\n") title = args_remaining[0] igetter = attrgetter("qseqlength") flens = [] for fname in args_remaining[1:]: with open(fname) as fh: if parg_map["lenfiles"] < 0: records = lineRecordIterator(fh, M4Record, M4RecordTypes) flens.append( map(igetter, records) ) else: getter = itemgetter(parg_map["lenfiles"]) flens.append( map(int, imap(getter, lineItemIterator(fh) ))) pp = PdfPages("hist.pdf")