Mercurial > repos > iuc > circos
annotate 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 |
rev | line source |
---|---|
6
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
2 import logging |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
3 import sys |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
4 |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
5 import pyBigWig |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
6 |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
7 logging.basicConfig(level=logging.INFO) |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
8 log = logging.getLogger() |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
9 |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
10 if __name__ == "__main__": |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
11 files = sys.argv[1:] |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
12 bws = [pyBigWig.open(x) for x in files] |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
13 |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
14 # obtain some chroms. Hope all sets are identical! |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
15 k = bws[0].chroms().keys() |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
16 |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
17 # do magic? |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
18 # nah. |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
19 # just assert that intervals are identical. |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
20 # and crash otherwise. |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
21 # sorry not sorry. |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
22 |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
23 for chrom in k: |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
24 for interval_set in zip(*[bw.intervals(chrom) for bw in bws]): |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
25 (start, end) = interval_set[0][0:2] |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
26 values = ','.join(map(str, [x[2] for x in interval_set])) |
740057a5126d
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff
changeset
|
27 sys.stdout.write("%s\t%s\t%s\t%s\n" % (chrom, start, end, values)) |