X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=erange.git;a=blobdiff_plain;f=MakeBamFromRds.py;h=0b4946b1c3e9d4338da5e4a57b77791316ebad9b;hp=bfb48fde3fc0bebc9bdceaa1dc16f83dd566da59;hb=HEAD;hpb=0d3e3112fd04c2e6b44a25cacef1d591658ad181 diff --git a/MakeBamFromRds.py b/MakeBamFromRds.py index bfb48fd..0b4946b 100644 --- a/MakeBamFromRds.py +++ b/MakeBamFromRds.py @@ -22,13 +22,13 @@ import pysam import ReadDataset from commoncode import getConfigParser, getConfigOption, getConfigBoolOption, getConfigIntOption +VERSION = "1.0" def main(argv=None): if not argv: argv = sys.argv - verstring = "makeBamFromRds: version 1.0" - print verstring + print "makeBamFromRds: version %s" % VERSION doPairs = False @@ -134,7 +134,7 @@ def makeBamFromRds(rdsfile, outfilename, withUniqs=True, withMulti=True, for chrom in chromRemoveList: chromList.remove(chrom) - header = {"HD": {"VN": "1.0"}} + header = {"HD": {"VN": VERSION}} if referenceSequenceList: header["SQ"] = referenceSequenceList @@ -176,7 +176,7 @@ def processSpliceReads(RDS, outfile, chrom, withFlag, useFlagLike, readlength, d pass else: for read in spliceDict[chrom]: - if fastaSequenceDict.has_key(chrom): + if chrom in fastaSequenceDict: read["sense"], noncanonical = fixSpliceSense(fastaSequenceDict[chrom], read["startR"], read["stopL"], read["sense"]) noncanonicalSplices += noncanonical @@ -205,7 +205,7 @@ def writeBAMEntry(outfile, chrom, outputDict, readlength): alignedRead.rname = outfile.references.index(chrom) - if outputDict.has_key("startL"): + if "startL" in outputDict: startL = outputDict["startL"] - 1 stopL = outputDict["stopL"] - 1 startR = outputDict["startR"] - 1 @@ -217,6 +217,13 @@ def writeBAMEntry(outfile, chrom, outputDict, readlength): alignedRead.pos = outputDict["start"] - 1 alignedRead.cigar = [(0, readlength)] + #TODO: add sequence info + #cistematic.core.retrieveSequence(genome, chrom, start, stop, sense="F", db="") + #ooooo. let's do this with PyGr + + #TODO: add quality - max for each base, but default is to not include just like current + # rdsToFastq() sets everything to max + if paired: if pairID == "1": alignedRead.is_read1 = True @@ -227,7 +234,7 @@ def writeBAMEntry(outfile, chrom, outputDict, readlength): else: pass - if outputDict.has_key("mismatch"): + if "mismatch" in outputDict: mismatchTag = getMismatches(outputDict["mismatch"]) if mismatchTag: tagList.append(("MD", str(mismatchTag))) @@ -300,7 +307,7 @@ def fixSpliceSense(fastaSequence, startRight, stopLeft, sense=""): spliceJunction = string.join([leftJunctionSig, rightJunctionSig], "") spliceJunction = spliceJunction.upper() print spliceJunction - if spliceSense.has_key(spliceJunction): + if spliceJunction in spliceSense: sense = spliceSense[spliceJunction] else: noncanonical += 1