annotate stack-histogram.py @ 13:8b1cf140bbd4 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 0cfd88d16b0b20a66d4b21b037ddee6a8c440d88
author iuc
date Wed, 12 Apr 2023 15:08:23 +0000
parents ecaa0210e62b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
b84d385679e2 "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
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
2 import logging
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
3 import sys
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
4
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
5 import pyBigWig
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
6
b84d385679e2 "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)
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
8 log = logging.getLogger()
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
9
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
10 if __name__ == "__main__":
b84d385679e2 "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:]
b84d385679e2 "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]
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
13
b84d385679e2 "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!
13
8b1cf140bbd4 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 0cfd88d16b0b20a66d4b21b037ddee6a8c440d88
iuc
parents: 7
diff changeset
15 k = list(bws[0].chroms().keys())
6
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
16
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
17 # do magic?
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
18 # nah.
b84d385679e2 "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.
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
20 # and crash otherwise.
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
21 # sorry not sorry.
b84d385679e2 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 1584882716a1d2c598e8485da9d73bcf80d9b29a"
iuc
parents:
diff changeset
22
b84d385679e2 "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:
b84d385679e2 "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]):
b84d385679e2 "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]
7
ecaa0210e62b "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit ef20b4968a6d00c49209de6b723f8b96d8bd128a"
iuc
parents: 6
diff changeset
26 values = ",".join(map(str, [x[2] for x in interval_set]))
6
b84d385679e2 "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))