From c4561c55cfa9726530c6777b6515c4ef66306b2f Mon Sep 17 00:00:00 2001 From: Sean Upchurch Date: Fri, 23 Sep 2011 11:22:35 -0700 Subject: [PATCH] ReadDataset.py - bug fix in parsing mismatches getSNPs - crash bug fixed, removed blank lines from output --- ReadDataset.py | 8 ++++---- getSNPs.py | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ReadDataset.py b/ReadDataset.py index 71544ca..4b51471 100644 --- a/ReadDataset.py +++ b/ReadDataset.py @@ -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 diff --git a/getSNPs.py b/getSNPs.py index f582675..4778644 100755 --- a/getSNPs.py +++ b/getSNPs.py @@ -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): -- 2.30.2