annotate bigwig_outlier_bed.py @ 1:8377a6abb4da draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
author iuc
date Sun, 21 Jul 2024 11:03:36 +0000
parents ebcd48f183b3
children 61946b8bd43b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
1 """
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
2 Ross Lazarus June 2024 for VGP
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
3 Bigwigs are great, but hard to reliably "see" small low coverage or small very high coverage regions.
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
4 Colouring in JB2 tracks will need a new plugin, so this code will find bigwig regions above and below a chosen percentile point.
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
5 0.99 and 0.01 work well in testing with a minimum span of 10 bp.
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
6 Multiple bigwigs **with the same reference** can be combined - bed segments will be named appropriately
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
7 Combining multiple references works but is silly because only display will rely on one reference so others will not be shown...
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
8 Tricksy numpy method from http://gregoryzynda.com/python/numpy/contiguous/interval/2019/11/29/contiguous-regions.html
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
9 takes about 95 seconds for a 17MB test wiggle
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
10 JBrowse2 bed normally displays ignore the score, so could provide separate low/high bed file outputs as an option.
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
11 Update june 30 2024: wrote a 'no-build' plugin for beds to display red/blue if >0/<0 so those are used for scores
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
12 Bed interval naming must be short for JB2 but needs input bigwig name and (lo or hi).
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
13 """
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
14
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
15 import argparse
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
16 import copy
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
17 import os
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
18 import sys
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
19 from pathlib import Path
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
20
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
21 import numpy as np
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
22 import pybigtools
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
23
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
24
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
25 class findOut:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
26
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
27 def __init__(self, args):
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
28 self.bwnames = args.bigwig
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
29 self.bwlabels = args.bigwiglabels
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
30 self.bedwin = args.minwin
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
31 self.outbeds = args.outbeds
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
32 self.bedouthi = args.bedouthi
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
33 self.bedoutlo = args.bedoutlo
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
34 self.bedouthilo = args.bedouthilo
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
35 self.tableoutfile = args.tableoutfile
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
36 self.bedwin = args.minwin
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
37 self.qhi = args.qhi
1
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
38 self.qlo = None
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
39 try:
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
40 f = float(args.qlo)
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
41 self.qlo = f
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
42 except Exception as e:
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
43 s = str(e)
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
44 print(s, ' qlo=', args.qlo)
0
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
45 nbw = len(args.bigwig)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
46 nlab = len(args.bigwiglabels)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
47 if nlab < nbw:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
48 self.bwlabels += ["Nolabel"] * (nbw - nlab)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
49 self.makeBed()
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
50
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
51 def processVals(self, bw, isTop):
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
52 """
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
53 idea from http://gregoryzynda.com/python/numpy/contiguous/interval/2019/11/29/contiguous-regions.html
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
54 Fast segmentation into regions by taking np.diff on the boolean array of over (under) cutpoint indicators in bwex.
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
55 This only gives non-zero values at the segment boundaries where there's a change, so those zeros are all removed in bwexdnz
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
56 leaving an array of segment start/end positions. That's twisted around into an array of start/end coordinates.
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
57 Magical. Fast. Could do the same for means or medians over windows for sparse bigwigs like repeat regions.
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
58 """
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
59 if isTop:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
60 bwex = np.r_[False, bw >= self.bwtop, False] # extend with 0s
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
61 else:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
62 bwex = np.r_[False, bw <= self.bwbot, False]
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
63 bwexd = np.diff(bwex)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
64 bwexdnz = bwexd.nonzero()[0]
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
65 bwregions = np.reshape(bwexdnz, (-1, 2))
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
66 return bwregions
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
67
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
68 def writeBed(self, bed, bedfname):
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
69 """
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
70 potentially multiple
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
71 """
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
72 bed.sort()
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
73 beds = ["%s\t%d\t%d\t%s\t%d" % x for x in bed]
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
74 with open(bedfname, "w") as bedf:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
75 bedf.write("\n".join(beds))
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
76 bedf.write("\n")
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
77
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
78 def makeTableRow(self, bw, bwlabel, chr):
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
79 """
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
80 called for every contig, but messy inline
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
81 """
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
82 bwmean = np.mean(bw)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
83 bwstd = np.std(bw)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
84 bwmax = np.max(bw)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
85 nrow = np.size(bw)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
86 bwmin = np.min(bw)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
87 row = "%s\t%s\t%d\t%f\t%f\t%f\t%f" % (
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
88 bwlabel,
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
89 chr,
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
90 nrow,
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
91 bwmean,
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
92 bwstd,
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
93 bwmin,
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
94 bwmax,
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
95 )
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
96 if self.qhi is not None:
1
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
97 row += "\t%.2f" % self.bwtop
0
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
98 else:
1
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
99 row += "\tnoqhi"
0
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
100 if self.qlo is not None:
1
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
101 row += "\t%.2f" % self.bwbot
0
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
102 else:
1
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
103 row += "\tnoqlo"
0
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
104 return row
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
105
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
106 def makeBed(self):
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
107 bedhi = []
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
108 bedlo = []
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
109 bwlabels = self.bwlabels
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
110 bwnames = self.bwnames
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
111 if self.tableoutfile:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
112 restab = ["bigwig\tcontig\tn\tmean\tstd\tmin\tmax\tqtop\tqbot"]
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
113 for i, bwname in enumerate(bwnames):
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
114 bwlabel = bwlabels[i].replace(" ", "")
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
115 fakepath = "in%d.bw" % i
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
116 if os.path.isfile(fakepath):
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
117 os.remove(fakepath)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
118 p = Path(fakepath)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
119 p.symlink_to(bwname) # required by pybigtools (!)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
120 bwf = pybigtools.open(fakepath)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
121 chrlist = bwf.chroms()
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
122 chrs = list(chrlist.keys())
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
123 chrs.sort()
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
124 for chr in chrs:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
125 bw = bwf.values(chr)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
126 bw = bw[~np.isnan(bw)] # some have NaN if parts of a contig not covered
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
127 if self.qhi is not None:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
128 self.bwtop = np.quantile(bw, self.qhi)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
129 bwhi = self.processVals(bw, isTop=True)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
130 for j, seg in enumerate(bwhi):
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
131 if seg[1] - seg[0] >= self.bedwin:
1
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
132 score = np.sum(bw[seg[0]:seg[1]])
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
133 bedhi.append(
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
134 (
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
135 chr,
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
136 seg[0],
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
137 seg[1],
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
138 "%s_%d" % (bwlabel, score),
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
139 score,
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
140 )
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
141 )
0
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
142 if self.qlo is not None:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
143 self.bwbot = np.quantile(bw, self.qlo)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
144 bwlo = self.processVals(bw, isTop=False)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
145 for j, seg in enumerate(bwlo):
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
146 if seg[1] - seg[0] >= self.bedwin:
1
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
147 score = -1 * np.sum(bw[seg[0]:seg[1]])
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
148 bedlo.append(
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
149 (
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
150 chr,
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
151 seg[0],
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
152 seg[1],
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
153 "%s_%d" % (bwlabel, score),
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
154 score,
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
155 )
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
156 )
0
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
157 if self.tableoutfile:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
158 row = self.makeTableRow(bw, bwlabel, chr)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
159 restab.append(copy.copy(row))
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
160 if self.tableoutfile:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
161 stable = "\n".join(restab)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
162 with open(self.tableoutfile, "w") as t:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
163 t.write(stable)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
164 t.write("\n")
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
165 some = False
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
166 if self.qlo:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
167 if self.outbeds in ["outall", "outlo", "outlohi"]:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
168 self.writeBed(bedlo, self.bedoutlo)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
169 some = True
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
170 if self.qhi:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
171 if self.outbeds in ["outall", "outlohi", "outhi"]:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
172 self.writeBed(bedhi, self.bedouthi)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
173 some = True
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
174 if self.outbeds in ["outall", "outhilo"]:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
175 allbed = bedlo + bedhi
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
176 self.writeBed(allbed, self.bedouthilo)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
177 some = True
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
178 if not some:
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
179 sys.stderr.write(
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
180 "Invalid configuration - no output could be created. Was qlo missing and only low output requested for example?"
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
181 )
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
182 sys.exit(2)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
183
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
184
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
185 if __name__ == "__main__":
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
186 parser = argparse.ArgumentParser()
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
187 a = parser.add_argument
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
188 a("-m", "--minwin", default=10, type=int)
1
8377a6abb4da planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 92ffe42a6ad6e81f3f157bbc9b942c000d450416
iuc
parents: 0
diff changeset
189 a("-l", "--qlo", default=None)
0
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
190 a("-i", "--qhi", default=None, type=float)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
191 a("--bedouthi", default=None)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
192 a("--bedoutlo", default=None)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
193 a("--bedouthilo", default=None)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
194 a("-w", "--bigwig", nargs="+")
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
195 a("-n", "--bigwiglabels", nargs="+")
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
196 a("-o", "--outbeds", default="outhilo", help="optional high and low combined bed")
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
197 a("-t", "--tableoutfile", default=None)
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
198 args = parser.parse_args()
ebcd48f183b3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/bigwig_outlier_bed commit 091caba3c5b066b293745ccee5cd31132fec3b4b
iuc
parents:
diff changeset
199 findOut(args)