X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=erange.git;a=blobdiff_plain;f=getSNPGeneInfo.py;fp=getSNPGeneInfo.py;h=edcb2ceae0103af5b810c4e98d5c0521544efd34;hp=307413b866e804e831e2288a14a6c0984a55b5bf;hb=0d3e3112fd04c2e6b44a25cacef1d591658ad181;hpb=5e4ae21098dba3d1edcf11e7279da0d84c3422e4 diff --git a/getSNPGeneInfo.py b/getSNPGeneInfo.py index 307413b..edcb2ce 100755 --- a/getSNPGeneInfo.py +++ b/getSNPGeneInfo.py @@ -16,9 +16,9 @@ import sys import optparse import string from cistematic.core import genesIntersecting, cacheGeneDB, uncacheGeneDB -from cistematic.core.geneinfo import geneinfoDB +from commoncode import getGeneInfoDict, getConfigParser, getConfigBoolOption, getConfigIntOption -print "%prog: version 4.5" +print "getSNPGeneInfo: version 4.6" def main(argv=None): if not argv: @@ -26,11 +26,7 @@ def main(argv=None): usage = "usage: python %prog genome snpsfile rpkmfile dbsnp_geneinfo_outfile [--cache] [--withoutsense] [--flank bp]" - parser = optparse.OptionParser(usage=usage) - parser.add_option("--cache", action="store_true", dest="cachePages") - parser.add_option("--withoutsense", action="store_false", dest="withSense") - parser.add_option("--flank", type="int", dest="flankBP") - parser.set_defaults(doCache=False, withSense=True, flankBP=0) + parser = makeParser(usage) (options, args) = parser.parse_args(argv[1:]) if len(args) < 4: @@ -45,6 +41,23 @@ def main(argv=None): writeSNPGeneInfo(genome, infilename, rpkmfilename, outfilename, options.doCache, options.withSense, options.flankBP) +def makeParser(usage=""): + parser = optparse.OptionParser(usage=usage) + parser.add_option("--cache", action="store_true", dest="cachePages") + parser.add_option("--withoutsense", action="store_false", dest="withSense") + parser.add_option("--flank", type="int", dest="flankBP") + + configParser = getConfigParser() + section = "getSNPGeneInfo" + doCache = getConfigBoolOption(configParser, section, "doCache", False) + withSense = getConfigBoolOption(configParser, section, "withSense", True) + flankBP = getConfigIntOption(configParser, section, "flankBP", 0) + + parser.set_defaults(doCache=doCache, withSense=withSense, flankBP=flankBP) + + return parser + + def writeSNPGeneInfo(genome, infilename, rpkmfilename, outfilename, doCache=False, withSense=True, flankBP=0): outList = getSNPGeneInfo(genome, infilename, rpkmfilename, doCache, withSense, flankBP) @@ -85,12 +98,9 @@ def getSNPGeneInfo(genome, infilename, rpkmfilename, doCache=False, withSense=Tr if doCache: cacheGeneDB(genome) - idb = geneinfoDB(cache=True) print "cached %s" % genome - else: - idb = geneinfoDB() - geneinfoDict = idb.getallGeneInfo(genome) + geneinfoDict = getGeneInfoDict(genome, cache=doCache) geneDict = {} if flankBP > 0: