development release: conversion of ReadDataset to use BAM files
[erange.git] / normalizeFinalExonic.py
index 6c1ae3323555722deea8bf91c5254ceb310560cb..6b47a208122ed7d24638dfab16cf3862ffaf214f 100755 (executable)
@@ -15,7 +15,7 @@ def main(argv=None):
     if not argv:
         argv = sys.argv
 
-    usage = "usage: python %prog rdsfile expandedRPKMfile multicountfile outfile [--multifraction] [--multifold] [--minrpkm minThreshold] [--cache] [--withGID]"
+    usage = "usage: python normalizeFinalExonic rdsfile expandedRPKMfile multicountfile outfile [--multifraction] [--multifold] [--minrpkm minThreshold] [--cache] [--withGID]"
 
     parser = makeParser(usage)
     (options, args) = parser.parse_args(argv[1:])
@@ -29,7 +29,13 @@ def main(argv=None):
     multicountfile = args[2]
     outfilename = args[3]
 
-    normalizeFinalExonic(rdsfilename, expandedRPKMfile, multicountfile, outfilename,
+    readCounts = {}
+    RDS = ReadDataset.ReadDataset(rdsfilename, verbose=True, cache=options.doCache, reportCount=False)
+    readCounts["uniq"] = RDS.getUniqsCount()
+    readCounts["splice"] = RDS.getSplicesCount()
+    readCounts["multi"] = RDS.getMultiCount()
+
+    normalizeFinalExonic(readCounts, expandedRPKMfile, multicountfile, outfilename,
                          options.reportFraction, options.reportFold, options.minThreshold,
                          options.doCache, options.writeGID)
 
@@ -56,7 +62,7 @@ def makeParser(usage=""):
     return parser
 
 
-def normalizeFinalExonic(rdsfilename, expandedRPKMfilename, multicountfilename, outfilename,
+def normalizeFinalExonic(readCounts, expandedRPKMfilename, multicountfilename, outfilename,
                          reportFraction=False, reportFold=False, minThreshold=0., doCache=False,
                          writeGID=False):
 
@@ -69,10 +75,9 @@ def normalizeFinalExonic(rdsfilename, expandedRPKMfilename, multicountfilename,
     elif reportFold:
         print "reporting fold contribution of multireads"
 
-    RDS = ReadDataset.ReadDataset(rdsfilename, verbose=True, cache=doCache, reportCount=False)
-    uniqcount = RDS.getUniqsCount()
-    splicecount = RDS.getSplicesCount()
-    multicount = RDS.getMultiCount()
+    uniqcount = readCounts["uniq"]
+    splicecount = readCounts["splice"]
+    multicount = readCounts["multi"]
     countDict = {}
     multicountDict = {}
     lengthDict = {}