Mercurial > repos > eric-rasche > circos
annotate fasta-to-karyotype.py @ 9:e6440d0201f7 draft default tip
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 7e335df423e3e06da3d33a5378a336a149e6cc6c
author | eric-rasche |
---|---|
date | Fri, 30 Jun 2017 06:48:38 -0400 |
parents | b56f47c58779 |
children |
rev | line source |
---|---|
0
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
1 #!/usr/bin/env python |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
2 from Bio import SeqIO |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
3 import sys |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
4 |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
5 for idx, seq in enumerate(SeqIO.parse(sys.argv[1], 'fasta')): |
3
b56f47c58779
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 4503a4ca99e65aa821e2c953f2f18eaadeed170a
eric-rasche
parents:
0
diff
changeset
|
6 sys.stdout.write("chr - {seq_id} {idx} 0 {length} set3-12-qual-{color}\n".format( |
0
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
7 seq_id=seq.id, idx=idx, length=len(seq), color=((idx + 1) % 12) |
3
b56f47c58779
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 4503a4ca99e65aa821e2c953f2f18eaadeed170a
eric-rasche
parents:
0
diff
changeset
|
8 )) |
0
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
9 |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
10 if len(sys.argv) > 2: |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
11 # band hs1 p36.32 p36.32 2200000 5100000 gpos25 |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
12 # band hs1 p36.31 p36.31 5100000 6900000 gneg |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
13 # band hs1 p36.23 p36.23 6900000 8800000 gpos25 |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
14 COLS = ('chrom', 'chromStart', 'chromEnd', 'name', 'score', 'strand', |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
15 'thickStart', 'thickEnd', 'itemRgb') |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
16 with open(sys.argv[2], 'r') as handle: |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
17 for line in handle: |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
18 lineData = dict(zip(COLS, line.split())) |
3
b56f47c58779
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 4503a4ca99e65aa821e2c953f2f18eaadeed170a
eric-rasche
parents:
0
diff
changeset
|
19 sys.stdout.write("band {chrom} {name} {name} {chromStart} {chromEnd} {color}\n".format( |
0
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
20 # Can access name because requiring >bed3 |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
21 name=lineData['name'], |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
22 chrom=lineData['chrom'], |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
23 chromStart=lineData['chromStart'], |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
24 chromEnd=lineData['chromEnd'], |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
25 # ???? |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
26 color=lineData.get('itemRgb', 'gpos50'), |
3
b56f47c58779
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 4503a4ca99e65aa821e2c953f2f18eaadeed170a
eric-rasche
parents:
0
diff
changeset
|
27 )) |
0
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
28 # band |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
29 # ID |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
30 # parentChr |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
31 # parentChr |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
32 # START |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
33 # END COLOR |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
34 |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
35 # chrom - The name of the chromosome (e.g. chr3, chrY, chr2_random) or scaffold (e.g. scaffold10671). |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
36 # chromStart - The starting position of the feature in the chromosome or scaffold. The first base in a chromosome is numbered 0. |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
37 # chromEnd - The ending position of the feature in the chromosome or scaffold. The chromEnd base is not included in the display of the feature. For example, the first 100 bases of a chromosome are defined as chromStart=0, chromEnd=100, and span the bases numbered 0-99. |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
38 # name - Defines the name of the BED line. This label is displayed to the left of the BED line in the Genome Browser window when the track is open to full display mode or directly to the left of the item in pack mode. |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
39 # score - A score between 0 and 1000. If the track line useScore attribute is set to 1 for this annotation data set, the score value will determine the level of gray in which this feature is displayed (higher numbers = darker gray). This table shows the Genome Browser's translation of BED score values into shades of gray: |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
40 # strand - Defines the strand - either '+' or '-'. |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
41 # thickStart - The starting position at which the feature is drawn thickly (for example, the start codon in gene displays). When there is no thick part, thickStart and thickEnd are usually set to the chromStart position. |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
42 # thickEnd - The ending position at which the feature is drawn thickly (for example, the stop codon in gene displays). |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
43 # itemRgb - An RGB value of the form R,G,B (e.g. 255,0,0). If the track line itemRgb attribute is set to "On", this RBG value will determine the display color of the data contained in this BED line. NOTE: It is recommended that a simple color scheme (eight colors or less) be used with this attribute to avoid overwhelming the color resources of the Genome Browser and your Internet browser. |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
44 # blockCount - The number of blocks (exons) in the BED line. |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
45 # blockSizes - A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount. |
e8475d0195fe
planemo upload for repository https://github.com/TAMU-CPT/galaxy-circos-tool commit 358dd35a2150af4183d9303af1df4f63be0737cd
eric-rasche
parents:
diff
changeset
|
46 # blockStarts - A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount. |