Skip to content

Commit

Permalink
round mid point to int
Browse files Browse the repository at this point in the history
  • Loading branch information
yezhengSTAT committed Dec 1, 2019
1 parent 76d23ca commit ef8a240
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions bin/KR_norm_mHiC.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,12 @@ def writeInteraction(matrix, filename, outdir, revFragsDic, chrNum, resolution):
for i in range(len(row)):
chr1, mid1 = revFragsDic[row[i]].split("=")
chr2, mid2 = revFragsDic[col[i]].split("=")
matrixFile.write(("%s\t%s\t%s\t%s\t%.4f\n") % (chr1, mid1, chr2, mid2, values[i]))
matrixFile.write(("%s\t%d\t%s\t%d\t%.4f\n") % (chr1, mid1, chr2, mid2, values[i]))
else:
for i in range(len(row)):
mid1 = row[i] * resolution + resolution/2
mid2 = col[i] * resolution + resolution/2
matrixFile.write(("%s\t%s\t%s\t%s\t%.4f\n") % (chrNum, mid1, chrNum, mid2, values[i]))
matrixFile.write(("%s\t%d\t%s\t%d\t%.4f\n") % (chrNum, mid1, chrNum, mid2, values[i]))

def writeBias(bias, filename, outdir, revFragsDicAll, chrNum, resolution):

Expand All @@ -373,15 +373,15 @@ def writeBias(bias, filename, outdir, revFragsDicAll, chrNum, resolution):
for i in range(len(bias)):
chr, mid = revFragsDicAll[i].split("=")
if bias[i, 0] != -1:
biasWOzero.write("\t".join([str(chr), str(mid), str(bias[i, 0])]) + "\n")
biasWzero.write("\t".join([str(chr), str(mid), str(bias[i, 0])]) + "\n")
biasWOzero.write("\t".join([str(chr), str(int(mid)), str(bias[i, 0])]) + "\n")
biasWzero.write("\t".join([str(chr), str(int(mid)), str(bias[i, 0])]) + "\n")

else:
for i in range(len(bias)):
mid = i * resolution + resolution/2
if bias[i, 0] != -1:
biasWOzero.write("\t".join([str(chrNum), str(mid), str(bias[i, 0])]) + "\n")
biasWzero.write("\t".join([str(chrNum), str(mid), str(bias[i, 0])]) + "\n")
biasWOzero.write("\t".join([str(chrNum), str(int(mid)), str(bias[i, 0])]) + "\n")
biasWzero.write("\t".join([str(chrNum), str(int(mid)), str(bias[i, 0])]) + "\n")


biasWOzero.close()
Expand Down

0 comments on commit ef8a240

Please sign in to comment.