Mercurial > repos > iuc > circos
comparison text-from-bed.py @ 2:014a21767ac4 draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
| author | iuc |
|---|---|
| date | Tue, 17 Sep 2019 16:54:57 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:ae9994cf526f | 2:014a21767ac4 |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 import logging | |
| 3 import sys | |
| 4 | |
| 5 logging.basicConfig(level=logging.INFO) | |
| 6 log = logging.getLogger() | |
| 7 | |
| 8 | |
| 9 if __name__ == "__main__": | |
| 10 with open(sys.argv[1], "r") as handle: | |
| 11 for line in handle: | |
| 12 lineData = line.strip().split() | |
| 13 # BED3+ chrom chromStart chromEnd | |
| 14 # BED6+ name score strand | |
| 15 # BED9+ thickStart thickEnd itemRgb | |
| 16 kv = {} | |
| 17 if len(lineData) >= 6: | |
| 18 kv["strand"] = lineData[5].replace("+", "1").replace("-", "-1") | |
| 19 kv["value"] = lineData[4] | |
| 20 else: | |
| 21 sys.exit("Must be BED6+") | |
| 22 | |
| 23 line = [ | |
| 24 lineData[0], # chrom | |
| 25 lineData[1], # chromStart | |
| 26 lineData[2], # chromEnd | |
| 27 lineData[3], | |
| 28 ",".join(["%s=%s" % x for x in sorted(kv.items())]), | |
| 29 ] | |
| 30 | |
| 31 sys.stdout.write("\t".join(line)) | |
| 32 sys.stdout.write("\n") |
