first pass cleanup of cistematic/genomes; change bamPreprocessing
[erange.git] / getSNPs.py
index f5826751fdecdc3643967ea8e04df8331fbf94e3..64948d405c523146e378c00fa4e204ca3ec75a4b 100755 (executable)
@@ -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)