X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=erange.git;a=blobdiff_plain;f=makewiggle.py;fp=makewiggle.py;h=7440a796f73038130abb89ef593df425ac2921f6;hp=95b0634bc2ec6bf804e955a1926866a9ceb28c5c;hb=0d3e3112fd04c2e6b44a25cacef1d591658ad181;hpb=5e4ae21098dba3d1edcf11e7279da0d84c3422e4 diff --git a/makewiggle.py b/makewiggle.py index 95b0634..7440a79 100755 --- a/makewiggle.py +++ b/makewiggle.py @@ -2,10 +2,12 @@ # makewiggle.py # ENRAGE # -import sys, optparse -from commoncode import readDataset +import sys +import optparse +import ReadDataset +from commoncode import getConfigParser, getConfigOption, getConfigBoolOption, getConfigIntOption, getConfigFloatOption -print "%prog: version 6.7" +print "makewiggle: version 6.8" try: import psyco @@ -20,6 +22,25 @@ def main(argv=None): usage = "usage: python %s name rdsfile outfilename [options]" + parser = getParser(usage) + (options, args) = parser.parse_args(argv[1:]) + + if len(args) < 3: + print usage + sys.exit(1) + + name = args[0] + hitfilename = args[1] + outfilename = args[2] + + makewiggle(name, hitfilename, outfilename, options.doNormalize, options.color, options.altColor, + options.limitChrom, options.shift, options.doSplit, options.listfilename, options.listPrefix, + options.group, options.startPriority, options.skipRandom, options.withMulti, + options.withSplices, options.doSingle, options.cachePages, options.enforceChr, options.strand, + options.chunk) + + +def getParser(usage): parser = optparse.OptionParser(usage=usage) parser.add_option("--raw", action="store_false", dest="doNormalize") parser.add_option("--color", dest="color") @@ -39,27 +60,35 @@ def main(argv=None): parser.add_option("--enforceChr", action="store_true", dest="enforceChr") parser.add_option("--stranded", dest="strand") parser.add_option("--maxchunk", type="int", dest="chunk") - parser.set_defaults(doNormalize=True, color=None, altColor="", limitChrom=None, - shift=0, doSplit=False, listfilename=None, listPrefix="", - group="", startPriority=0.01, skipRandom=False, withMulti=True, - withSplices=False, doSingle=False, cachePages=-1, enforceChr=False, - strand=None, chunk=20) - - (options, args) = parser.parse_args(argv[1:]) - - if len(args) < 3: - print usage - sys.exit(1) - - name = args[0] - hitfilename = args[1] - outfilename = args[2] - makewiggle(name, hitfilename, outfilename, options.doNormalize, options.color, options.altColor, - options.limitChrom, options.shift, options.doSplit, options.listfilename, options.listPrefix, - options.group, options.startPriority, options.skipRandom, options.withMulti, - options.withSplices, options.doSingle, options.cachePages, options.enforceChr, options.strand, - options.chunk) + configParser = getConfigParser() + section = "makewiggle" + doNormalize = getConfigBoolOption(configParser, section, "doNormalize", True) + color = getConfigOption(configParser, section, "color", None) + altColor = getConfigOption(configParser, section, "altColor", "") + limitChrom = getConfigOption(configParser, section, "limitChrom", None) + shift = getConfigIntOption(configParser, section, "shift", 0) + doSplit = getConfigBoolOption(configParser, section, "doSplit", False) + listfilename = getConfigOption(configParser, section, "listfilename", None) + listPrefix = getConfigOption(configParser, section, "listPrefix", "") + group = getConfigOption(configParser, section, "group", "") + startPriority = getConfigFloatOption(configParser, section, "startPriority", 0.01) + skipRandom = getConfigBoolOption(configParser, section, "skipRandom", False) + withMulti = getConfigBoolOption(configParser, section, "withMulti", True) + withSplices = getConfigBoolOption(configParser, section, "withSplices", False) + doSingle = getConfigBoolOption(configParser, section, "doSingle", False) + cachePages = getConfigIntOption(configParser, section, "cachePages", -1) + enforceChr = getConfigBoolOption(configParser, section, "enforceChr", False) + strand = getConfigOption(configParser, section, "strand", None) + chunk = getConfigIntOption(configParser, section, "chunk", 20) + + parser.set_defaults(doNormalize=doNormalize, color=color, altColor=altColor, limitChrom=limitChrom, + shift=shift, doSplit=doSplit, listfilename=listfilename, listPrefix=listPrefix, + group=group, startPriority=startPriority, skipRandom=skipRandom, withMulti=withMulti, + withSplices=withSplices, doSingle=doSingle, cachePages=cachePages, enforceChr=enforceChr, + strand=strand, chunk=chunk) + + return parser def makewiggle(name, hitfilename, outfilename, doNormalize=True, color=None, altColor="", @@ -110,7 +139,7 @@ def makewiggle(name, hitfilename, outfilename, doNormalize=True, color=None, alt print "Will shift reads by +/- %d bp according to their sense" % shift name += "shift=%d" % shift - hitRDS = readDataset(hitfilename, verbose=True, cache=doCache) + hitRDS = ReadDataset.ReadDataset(hitfilename, verbose=True, cache=doCache) if cachePages > hitRDS.getDefaultCacheSize(): hitRDS.setDBcache(cachePages)