Esempio n. 1
0
    ["log", "log", argflag, False, "Turn on some logging"],
    ["out", "out", str, "stdout", "Output file"],
]

cl_arglist = map(CLArgument._make, arglist)
(arg_map, remaining_args) = parseArgs(sys.argv[1:], cl_arglist)

if not len(remaining_args) >= 3:
    sys.exit(getHelpStr(description, cl_arglist) + "\n")

log = logger(sys.stderr if arg_map["log"] else None)

ofh = sys.stdout if arg_map["out"] == "stdout" else open(arg_map["out"], "w")

log("Reading Positions from Files")
positions = getPositions(remaining_args)
chrom = positions[0].samples[0].ref


windowsize = arg_map["windowsize"]
stepsize = arg_map["stepsize"]
log("Computing Kruskal-Wallis test on windows of size %d and step %d" % (windowsize, stepsize))
testresults = []
for window in BSWindowGen(positions, windowsize, stepsize):

    covcheck = lambda c: c >= arg_map["mincov"]
    filt_pos = filter(lambda position: all(map(covcheck, map(baseCoverage, position.samples))), window.positions)

    if not len(filt_pos) >= arg_map["minwinsites"]:
        continue
Esempio n. 2
0
           ["pout", "pout", str, "out",
            "prefix for output file (Default: out)"]]

cl_arglist = map(CLArgument._make, arglist)
(arg_map, remaining_args) = parseArgs(sys.argv[1:], cl_arglist)

if not len(sys.argv) >= 4:
    sys.exit(getHelpStr(description, cl_arglist) + "\n")

log = logger(sys.stderr if arg_map["log"] else None)

regionfile = remaining_args[0]
methylfiles = remaining_args[1:]

log("Reading Positions from Files")
positions = getPositions(methylfiles)

pp = PdfPages(arg_map["pout"] + ".pdf")

regmk = lambda arr : Region._make(map(lambda t,v : t(v), RegionTypes, arr[:3]))
regit = lambda fh: iterApply(regmk, lineItemIterator(fh))

for region in fileIterator(regionfile, regit):
    if not region.chr == positions[0].samples[0].ref:
        raise Exception, "Regions are for a different Chromosome"
    
    log("Working on %s:%d-%d" % region)
    def searchexp(item):
        if item > region.end:
            return -1
        elif item < region.start: