X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=erange.git;a=blobdiff_plain;f=altSpliceCounts.py;fp=altSpliceCounts.py;h=12077c1ec7d9d7e3ba499c67c99734a8a9a54157;hp=1517ef888c917bd92d4b22fabde6018c470c9581;hb=0d3e3112fd04c2e6b44a25cacef1d591658ad181;hpb=5e4ae21098dba3d1edcf11e7279da0d84c3422e4 diff --git a/altSpliceCounts.py b/altSpliceCounts.py index 1517ef8..12077c1 100755 --- a/altSpliceCounts.py +++ b/altSpliceCounts.py @@ -4,10 +4,12 @@ try: except: print 'psyco not running' -print 'version 3.6' +print "altSpliceCounts: version 3.7" -import sys, optparse -from commoncode import readDataset +import sys +import optparse +import ReadDataset +from commoncode import getConfigParser, getConfigOption def main(argv=None): if not argv: @@ -15,10 +17,7 @@ def main(argv=None): usage = "usage: python %s rdsfile outfilename [--cache pages]" - parser = optparse.OptionParser(usage=usage) - parser.add_option("--cache", type="int", dest="numCachePages", - help="number of cache pages to use [default: 100000]") - parser.set_defaults(numCachePages=None) + parser = makeParser(usage) (options, args) = parser.parse_args(argv[1:]) if len(args) < 2: @@ -38,12 +37,26 @@ def main(argv=None): altSpliceCounts(hitfile, outfilename, doCache, cachePages) +def makeParser(usage=""): + parser = optparse.OptionParser(usage=usage) + parser.add_option("--cache", type="int", dest="numCachePages", + help="number of cache pages to use [default: 100000]") + + configParser = getConfigParser() + section = "altSpliceCounts" + numCachePages = getConfigOption(configParser, section, "numCachePages", None) + + parser.set_defaults(numCachePages=numCachePages) + + return parser + + def altSpliceCounts(hitfile, outfilename, doCache=False, cachePages=100000): startDict = {} stopDict = {} resultDict = {} - hitRDS = readDataset(hitfile, verbose = True, cache=doCache) + hitRDS = ReadDataset.ReadDataset(hitfile, verbose = True, cache=doCache) if cachePages > hitRDS.getDefaultCacheSize(): hitRDS.setDBcache(cachePages) @@ -58,7 +71,9 @@ def altSpliceCounts(hitfile, outfilename, doCache=False, cachePages=100000): index = 0 for chrom in hitDict: - for (tagStart, lstop, rstart, tagStop) in hitDict[chrom]: + for read in hitDict[chrom]: + tagStart = read["startL"] + tagStop = read["stopR"] index += 1 length = tagStop - tagStart if length < readlen + 5: