ReadDataset.py - bug fix in parsing mismatches
[erange.git] / getSNPs.py
index f6071ae444be9ca294ac4c4ff39b50a74e3d0cb4..4778644832ba9b3734687a92421dd60bbeee93a2 100755 (executable)
@@ -75,7 +75,7 @@ def makeParser(usage=""):
     forceChr = getConfigBoolOption(configParser, section, "forceChr", False)
     cachePages = getConfigIntOption(configParser, section, "cachePages", 0)
 
-    parser.set_defaults(doSplices=True, forceChr=False, cachePages=0)
+    parser.set_defaults(doSplices=doSplices, forceChr=forceChr, cachePages=cachePages)
 
     return parser
 
@@ -90,8 +90,7 @@ def writeSNPsToFile(hitfile, uniqStartMin, totalRatioMin, outfilename, doCache,
     snpPropertiesList = getSNPs(hitfile, uniqStartMin, totalRatioMin, doCache, cachePages, doSplices, forceChr)
     for snpEntry in snpPropertiesList:
         outline = "%1.2f\t%1.2f\t%s\t%d\t%d\t%d\t\t%d\t%s\n" % snpEntry
-        print outline
-        outfile.write(outline + "\n")
+        outfile.write(outline)
         outfile.flush() 
 
     outfile.close()
@@ -213,12 +212,16 @@ def getMismatchDict(rds, chrom, withSplices=True):
         uniqBaseDict = {change: 1}
         totalBaseDict = {change: 1}
         if mismatchDict.has_key(change_at):
-            (uniqueReadCount, totalCount, back, uniqBaseDict, totalBaseDict) = mismatchDict[change_at]
             pos = "%s:%s" % (str(start), change)
+            totalCount = mismatchDict[change_at]["totalCount"]
             totalCount += 1
+            totalBaseDict = mismatchDict[change_at]["totalBaseDict"]
             if totalBaseDict.has_key(change): 
                 totalBaseDict[change] += 1
 
+            uniqBaseDict = mismatchDict[change_at]["uniqBaseDict"]
+            uniqueReadCount = mismatchDict[change_at]["uniqueReadCount"]
+            back = mismatchDict[change_at]["back"]
             if pos not in back:
                 uniqueReadCount += 1
                 if uniqBaseDict.has_key(change):