first pass cleanup of cistematic/genomes; change bamPreprocessing
[erange.git] / getSNPs.py
index f6071ae444be9ca294ac4c4ff39b50a74e3d0cb4..64948d405c523146e378c00fa4e204ca3ec75a4b 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()
@@ -175,7 +174,7 @@ def getMatchDict(rds, chrom, withSplices=True):
     for read in readDict[chrom]:
         start = read["start"]
         stop = read["stop"]
-        if finalDict.has_key(start):
+        if start in finalDict:
             finalDict[start].append(stop)
         else:
             finalDict[start] = [stop]
@@ -194,7 +193,7 @@ def getMatchDict(rds, chrom, withSplices=True):
                 start = read["startR"]
                 stop = read["stopR"]
 
-            if finalDict.has_key(start):
+            if start in finalDict:
                 finalDict[start].append(stop)
             else:
                 finalDict[start] = [stop]
@@ -212,16 +211,20 @@ def getMismatchDict(rds, chrom, withSplices=True):
         back = "%s:%s" % (str(start), change)
         uniqBaseDict = {change: 1}
         totalBaseDict = {change: 1}
-        if mismatchDict.has_key(change_at):
-            (uniqueReadCount, totalCount, back, uniqBaseDict, totalBaseDict) = mismatchDict[change_at]
+        if change_at in mismatchDict:
             pos = "%s:%s" % (str(start), change)
+            totalCount = mismatchDict[change_at]["totalCount"]
             totalCount += 1
-            if totalBaseDict.has_key(change): 
+            totalBaseDict = mismatchDict[change_at]["totalBaseDict"]
+            if change in totalBaseDict: 
                 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):
+                if change in uniqBaseDict:
                     uniqBaseDict[change] += 1 # dict contains total unique read counts
 
                 back = "%s,%s" % (back, pos)