Mercurial > repos > iuc > circos
annotate alignments-to-links.py @ 11:0ee66defe58b draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit b9ec351920dbc83fa14bd1f8cfdd0a6a19b89473"
| author | iuc | 
|---|---|
| date | Tue, 16 Nov 2021 09:19:09 +0000 | 
| parents | 890ef899a3d7 | 
| children | 
| rev | line source | 
|---|---|
| 2 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 1 import itertools | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 2 import sys | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 3 | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 4 from Bio import AlignIO | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 5 | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 6 | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 7 format_mapping = { | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 8 "xmfa": "mauve", | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 9 "maf": "maf", | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 10 "nex": "nexus", | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 11 # 'phylip': 'phylip-relaxed', | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 12 "stockholm": "stockholm", | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 13 } | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 14 | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 15 for aln in AlignIO.parse(sys.argv[1], format_mapping.get(sys.argv[2], "maf")): | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 16 | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 17 for (a, b) in itertools.combinations(aln, 2): | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 18 a_s = a.annotations["start"] | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 19 b_s = b.annotations["start"] | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 20 | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 21 if "size" in a.annotations: | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 22 a_l = a.annotations["size"] | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 23 b_l = b.annotations["size"] | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 24 a_e = a_l + a_s | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 25 b_e = b_l + b_s | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 26 else: | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 27 a_e = a.annotations["end"] | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 28 b_e = b.annotations["end"] | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 29 | 
| 
890ef899a3d7
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/circos commit 076837a2e9c2b6ececcea4aa286ea7a412387a96"
 iuc parents: diff
changeset | 30 sys.stdout.write("%s\t%s\t%s\t%s\t%s\t%s\n" % (a.id, a_s, a_e, b.id, b_s, b_e)) | 
