# 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
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")
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="",
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)