Mercurial > repos > iuc > circos
diff stack-histogram.py @ 6:740057a5126d draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
author | iuc |
---|---|
date | Fri, 01 May 2020 07:28:50 -0400 |
parents | |
children | 4b519282a05b |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stack-histogram.py Fri May 01 07:28:50 2020 -0400 @@ -0,0 +1,27 @@ +#!/usr/bin/env python +import logging +import sys + +import pyBigWig + +logging.basicConfig(level=logging.INFO) +log = logging.getLogger() + +if __name__ == "__main__": + files = sys.argv[1:] + bws = [pyBigWig.open(x) for x in files] + + # obtain some chroms. Hope all sets are identical! + k = bws[0].chroms().keys() + + # do magic? + # nah. + # just assert that intervals are identical. + # and crash otherwise. + # sorry not sorry. + + for chrom in k: + for interval_set in zip(*[bw.intervals(chrom) for bw in bws]): + (start, end) = interval_set[0][0:2] + values = ','.join(map(str, [x[2] for x in interval_set])) + sys.stdout.write("%s\t%s\t%s\t%s\n" % (chrom, start, end, values))