ReadDataset.py - bug fix in parsing mismatches
authorSean Upchurch <sau@caltech.edu>
Fri, 23 Sep 2011 18:22:35 +0000 (11:22 -0700)
committerSean Upchurch <sau@caltech.edu>
Fri, 23 Sep 2011 18:22:35 +0000 (11:22 -0700)
getSNPs - crash bug fixed, removed blank lines from output

ReadDataset.py
getSNPs.py

index 71544ca2420d2489fca13452976d930a6c55a9c5..4b51471184777a1cfe0d650a51ead592873ce3a1 100644 (file)
@@ -833,8 +833,8 @@ class ReadDataset():
                             change_base = mismatch[change_len-1]
                             change_pos = int(mismatch[1:change_len-1])
                         elif sense == "-":
-                            change_from = getReverseComplement([mismatch[0]])
-                            change_base = getReverseComplement([mismatch[change_len-1]])
+                            change_from = getReverseComplement(mismatch[0])
+                            change_base = getReverseComplement(mismatch[change_len-1])
                             change_pos = readlen - int(mismatch[1:change_len-1]) + 1
 
                         firsthalf = int(lefthalf)-int(startpos)+1
@@ -866,8 +866,8 @@ class ReadDataset():
                         change_base = mismatch[change_len-1]
                         change_pos = int(mismatch[1:change_len-1])
                     elif sense == "-":
-                        change_from = getReverseComplement([mismatch[0]])
-                        change_base = getReverseComplement([mismatch[change_len-1]])
+                        change_from = getReverseComplement(mismatch[0])
+                        change_base = getReverseComplement(mismatch[change_len-1])
                         change_pos = readlen - int(mismatch[1:change_len-1]) + 1
 
                     change_at = start + change_pos - 1
index f5826751fdecdc3643967ea8e04df8331fbf94e3..4778644832ba9b3734687a92421dd60bbeee93a2 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()
@@ -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):