+def getParser(usage):
+ parser = optparse.OptionParser(usage=usage)
+ parser.add_option("--bins", type="int", dest="bins",
+ help="number of bins to use [default: 10]")
+ parser.add_option("--flank", type="int", dest="flankBP",
+ help="number of flanking BP on both upstream and downstream [default: 0]")
+ parser.add_option("--upstream", type="int", dest="upstreamBP",
+ help="number of upstream flanking BP [default: 0]")
+ parser.add_option("--downstream", type="int", dest="downstreamBP",
+ help="number of downstream flanking BP [default: 0]")
+ parser.add_option("--nocds", action="store_false", dest="doCDS",
+ help="do not CDS")
+ parser.add_option("--raw", action="store_false", dest="normalizeBins",
+ help="do not normalize results")
+ parser.add_option("--force", action="store_false", dest="limitNeighbor",
+ help="limit neighbor region")
+ parser.add_option("--regions", dest="acceptfile")
+ parser.add_option("--cache", action="store_true", dest="doCache",
+ help="use cache")
+
+ configParser = getConfigParser()
+ section = "geneLocusBins"
+ normalizeBins = getConfigBoolOption(configParser, section, "normalizeBins", True)
+ doCache = getConfigBoolOption(configParser, section, "doCache", False)
+ bins = getConfigIntOption(configParser, section, "bins", 10)
+ flankBP = getConfigOption(configParser, section, "flankBP", None)
+ upstreamBP = getConfigOption(configParser, section, "upstreamBP", None)
+ downstreamBP = getConfigOption(configParser, section, "downstreamBP", None)
+ doCDS = getConfigBoolOption(configParser, section, "doCDS", True)
+ limitNeighbor = getConfigBoolOption(configParser, section, "limitNeighbor", True)
+
+ parser.set_defaults(normalizeBins=normalizeBins, doCache=doCache, bins=bins, flankBP=flankBP,
+ upstreamBP=upstreamBP, downstreamBP=downstreamBP, doCDS=doCDS,
+ limitNeighbor=limitNeighbor)
+
+ return parser
+
+def geneLocusBins(genome, hitfile, outfilename, upstreamBp=0, downstreamBp=0, doFlank=False,
+ normalizeBins=True, doCache=False, bins=10, doCDS=True, limitNeighbor=True,
+ acceptfile=None):
+