X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=erange.git;a=blobdiff_plain;f=geneLocusBins.py;h=14cb2b5ee2b5617fba45f1a69ef94386784c0b11;hp=49745dc0c1361c2a8dbe4736c9c8630396fd93e4;hb=HEAD;hpb=77dccd7c98d8cdb60caaf178b1123df71ea662c9 diff --git a/geneLocusBins.py b/geneLocusBins.py index 49745dc..14cb2b5 100755 --- a/geneLocusBins.py +++ b/geneLocusBins.py @@ -138,7 +138,7 @@ def writeBins(gidList, geneinfoDict, gidBins, gidLen, outfilename, normalizeBins try: geneinfo = geneinfoDict[gid] symbol = geneinfo[0][0] - except KeyError: + except (KeyError, IndexError): pass else: symbol = gid @@ -154,6 +154,7 @@ def writeBins(gidList, geneinfoDict, gidBins, gidLen, outfilename, normalizeBins try: normalizedValue = 100. * binAmount / tagCount except ZeroDivisionError: + #TODO: this is the right way to refactor the original code, but I don't think this is the right answer normalizedValue = 100. * binAmount binAmount = normalizedValue @@ -167,4 +168,4 @@ def writeBins(gidList, geneinfoDict, gidBins, gidLen, outfilename, normalizeBins if __name__ == "__main__": - main(sys.argv) + main(sys.argv) \ No newline at end of file