5fda6e8bf3df270b17862b82d875f1fd2cb3e7b7 chmalee Fri Apr 3 11:41:42 2020 -0700 Fixing ubuntu specific bug in expMatrixToBarchartBed, refs #25284 diff --git src/utils/expMatrixToBarchartBed/expMatrixToBarchartBed src/utils/expMatrixToBarchartBed/expMatrixToBarchartBed index c66c87c..3f0f45e 100755 --- src/utils/expMatrixToBarchartBed/expMatrixToBarchartBed +++ src/utils/expMatrixToBarchartBed/expMatrixToBarchartBed @@ -285,32 +285,32 @@ tpmCutoffs.append(tpmMedian[blockSizes*i]) # Sort the bed like file to prepare it for the join. sortedBedLikeFile = tempfile.NamedTemporaryFile( mode = "w+", bufsize = 1) cmd = "sort -k1 " + bedLikeFile.name + " > " + sortedBedLikeFile.name os.system(cmd) # Sort the coordinate file to prepare it for the join. sortedCoords = tempfile.NamedTemporaryFile( mode = "w+", bufsize = 1) cmd = "sort -k4 " + options.bedFile + " > " + sortedCoords.name os.system(cmd) # Join the bed-like file and the coordinate file, the awk accounts for any extra # fields that may be included, and keeps the file in standard bed 6+5 format joinedFile = tempfile.NamedTemporaryFile(mode="w+", bufsize=1) - cmd = "join -t $'\\t' -1 4 -2 1 " + sortedCoords.name + " " + sortedBedLikeFile.name + \ - " | awk -F'\t' -v OFS=\"\\t\" '{printf \"%s\\t%s\\t%s\\t%s\", $2,$3,$4,$1; " + \ + cmd = "join -t ' ' -1 4 -2 1 " + sortedCoords.name + " " + sortedBedLikeFile.name + \ + " | awk -F'\\t' -v OFS=\"\\t\" '{printf \"%s\\t%s\\t%s\\t%s\", $2,$3,$4,$1; " + \ "for (i=5;i<=NF;i++) {printf \"\\t%s\", $i}; printf\"\\n\";}' > " + joinedFile.name os.system(cmd) # Go through the joined file and re arrange the columns creating a bed 6+5+ file. # Also assign a scaled score 0 - 1000 to each tpm value. bedFile = tempfile.NamedTemporaryFile(mode="w+", bufsize=1) for line in joinedFile: splitLine = line.strip("\n").split("\t") # Drop sequences where start is greater than end. if (float(splitLine[1]) > float(splitLine[2])): sys.stderr.write("This transcript: " + splitLine[0] + " was dropped since chr end, " + \ splitLine[2] + ", is smaller than chr start, " + splitLine[1] + ".\n") continue score = str(determineScore(tpmCutoffs, float(splitLine[-3]))) if autoSql: