diff --git a/tools/bigwig_outlier_bed/bigwig_outlier_bed.py b/tools/bigwig_outlier_bed/bigwig_outlier_bed.py
index e762021ea7f..c6f4a0bbec9 100644
--- a/tools/bigwig_outlier_bed/bigwig_outlier_bed.py
+++ b/tools/bigwig_outlier_bed/bigwig_outlier_bed.py
@@ -146,7 +146,7 @@ def processVals(self, bw, isTop):
else:
bwex = np.r_[False, bw <= self.bwbot, False]
bwexd = np.diff(bwex)
- bwexdnz = bwexd.nonzero()[0]
+ bwexdnz = bwexd.nonzero()[0] # start and end transition of each segment - nice!
bwregions = np.reshape(bwexdnz, (-1, 2))
return bwregions
@@ -155,10 +155,9 @@ def writeBed(self, bed, bedfname):
potentially multiple
"""
bed.sort()
- beds = ["%s\t%d\t%d\t%s\t%d" % x for x in bed]
with open(bedfname, "w") as bedf:
- bedf.write("\n".join(beds))
- bedf.write("\n")
+ for b in bed:
+ bedf.write("%s\t%d\t%d\t%s\t%d\n" % b)
def makeTableRow(self, bw, bwlabel, chr):
"""
@@ -194,7 +193,6 @@ def makeBed(self):
restab = []
bwlabels = self.bwlabels
bwnames = self.bwnames
- bwnames.sort()
reshead = "bigwig\tcontig\tn\tmean\tstd\tmin\tmax\tqtop\tqbot"
for i, bwname in enumerate(bwnames):
bwlabel = bwlabels[i].replace(" ", "")
@@ -251,8 +249,11 @@ def makeBed(self):
self.bwbot = np.quantile(bw, self.qlo)
bwlo = self.processVals(bw, isTop=False)
for j, seg in enumerate(bwlo):
+ seglen = seg[1] - seg[0]
if seg[1] - seg[0] >= self.bedwin:
- score = -1 * np.sum(bw[seg[0]:seg[1]]) / float(seglen)
+ score = (
+ -1 * np.sum(bw[seg[0]:seg[1]]) / float(seglen)
+ )
bedlo.append(
(
chr,
diff --git a/tools/bigwig_outlier_bed/bigwig_outlier_bed.xml b/tools/bigwig_outlier_bed/bigwig_outlier_bed.xml
index b9df7c5430f..8750a174a39 100644
--- a/tools/bigwig_outlier_bed/bigwig_outlier_bed.xml
+++ b/tools/bigwig_outlier_bed/bigwig_outlier_bed.xml
@@ -3,7 +3,7 @@
0.2.0
3.12.3
- 0
+ 1
topic_0157
@@ -25,13 +25,13 @@
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
@@ -125,7 +125,7 @@
-
+
@@ -134,24 +134,25 @@
-
-
-
-
+
+
+
+
-
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+