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:
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:
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)
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: