Mercurial > repos > iuc > circos
comparison tiles-from-gff3.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 | 740057a5126d |
comparison
equal
deleted
inserted
replaced
1:ae9994cf526f | 2:014a21767ac4 |
---|---|
1 #!/usr/bin/env python | |
2 import logging | |
3 import sys | |
4 | |
5 from BCBio import GFF | |
6 | |
7 logging.basicConfig(level=logging.INFO) | |
8 log = logging.getLogger() | |
9 | |
10 | |
11 if __name__ == "__main__": | |
12 attr = sys.argv[2] | |
13 | |
14 for record in GFF.parse(sys.argv[1]): | |
15 if len(record.features) == 0: | |
16 continue | |
17 | |
18 for feature in sorted(record.features, key=lambda x: x.location.start): | |
19 # chrom chromStart chromEnd | |
20 # name score strand | |
21 # thickStart thickEnd itemRgb | |
22 | |
23 kv = { | |
24 "strand": 0 if not feature.location.strand else feature.location.strand, | |
25 "name": feature.qualifiers.get(attr, ["None"])[0] or feature.id, | |
26 "value": feature.qualifiers.get("score", [0])[0], | |
27 } | |
28 | |
29 line = [ | |
30 record.id, | |
31 str(int(feature.location.start)), | |
32 str(int(feature.location.end)), | |
33 ",".join(["%s=%s" % x for x in sorted(kv.items())]), | |
34 ] | |
35 | |
36 sys.stdout.write("\t".join(line)) | |
37 sys.stdout.write("\n") |