Mercurial > repos > iuc > jbrowse
annotate jbrowse.py @ 20:558d652cd681 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 75a0a1c7b26cac156f76e8266a0e2e3d81be7f02
author | iuc |
---|---|
date | Thu, 30 Aug 2018 11:43:59 -0400 |
parents | ff11d442feed |
children | 1c718d8b3532 |
rev | line source |
---|---|
0
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env python |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
2 import argparse |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
3 import binascii |
3 | 4 import copy |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
5 import datetime |
0
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
6 import hashlib |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
7 import json |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
8 import logging |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
9 import os |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
10 import shutil |
3 | 11 import struct |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
12 import subprocess |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
13 import tempfile |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
14 import xml.etree.ElementTree as ET |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
15 from collections import defaultdict |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
16 |
3 | 17 from Bio.Data import CodonTable |
18 logging.basicConfig(level=logging.INFO) | |
19 log = logging.getLogger('jbrowse') | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
20 TODAY = datetime.datetime.now().strftime("%Y-%m-%d") |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
21 GALAXY_INFRASTRUCTURE_URL = None |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
22 |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
23 |
3 | 24 class ColorScaling(object): |
25 | |
26 COLOR_FUNCTION_TEMPLATE = """ | |
27 function(feature, variableName, glyphObject, track) {{ | |
28 var score = {score}; | |
29 {opacity} | |
30 return 'rgba({red}, {green}, {blue}, ' + opacity + ')'; | |
31 }} | |
32 """ | |
33 | |
34 COLOR_FUNCTION_TEMPLATE_QUAL = """ | |
35 function(feature, variableName, glyphObject, track) {{ | |
36 var search_up = function self(sf, attr){{ | |
37 if(sf.get(attr) !== undefined){{ | |
38 return sf.get(attr); | |
39 }} | |
40 if(sf.parent() === undefined) {{ | |
41 return; | |
42 }}else{{ | |
43 return self(sf.parent(), attr); | |
44 }} | |
45 }}; | |
0
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
46 |
3 | 47 var search_down = function self(sf, attr){{ |
48 if(sf.get(attr) !== undefined){{ | |
49 return sf.get(attr); | |
50 }} | |
51 if(sf.children() === undefined) {{ | |
52 return; | |
53 }}else{{ | |
54 var kids = sf.children(); | |
55 for(var child_idx in kids){{ | |
56 var x = self(kids[child_idx], attr); | |
57 if(x !== undefined){{ | |
58 return x; | |
59 }} | |
60 }} | |
61 return; | |
62 }} | |
63 }}; | |
64 | |
65 var color = ({user_spec_color} || search_up(feature, 'color') || search_down(feature, 'color') || {auto_gen_color}); | |
66 var score = (search_up(feature, 'score') || search_down(feature, 'score')); | |
67 {opacity} | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
68 if(score === undefined){{ opacity = 1; }} |
3 | 69 var result = /^#?([a-f\d]{{2}})([a-f\d]{{2}})([a-f\d]{{2}})$/i.exec(color); |
70 var red = parseInt(result[1], 16); | |
71 var green = parseInt(result[2], 16); | |
72 var blue = parseInt(result[3], 16); | |
73 if(isNaN(opacity) || opacity < 0){{ opacity = 0; }} | |
74 return 'rgba(' + red + ',' + green + ',' + blue + ',' + opacity + ')'; | |
75 }} | |
76 """ | |
0
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
77 |
3 | 78 OPACITY_MATH = { |
79 'linear': """ | |
80 var opacity = (score - ({min})) / (({max}) - ({min})); | |
81 """, | |
82 'logarithmic': """ | |
83 var opacity = (score - ({min})) / (({max}) - ({min})); | |
84 opacity = Math.log10(opacity) + Math.log10({max}); | |
85 """, | |
86 'blast': """ | |
87 var opacity = 0; | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
88 if(score == 0.0) {{ |
3 | 89 opacity = 1; |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
90 }} else {{ |
3 | 91 opacity = (20 - Math.log10(score)) / 180; |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
92 }} |
3 | 93 """ |
94 } | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
95 |
3 | 96 BREWER_COLOUR_IDX = 0 |
97 BREWER_COLOUR_SCHEMES = [ | |
98 (166, 206, 227), | |
99 (31, 120, 180), | |
100 (178, 223, 138), | |
101 (51, 160, 44), | |
102 (251, 154, 153), | |
103 (227, 26, 28), | |
104 (253, 191, 111), | |
105 (255, 127, 0), | |
106 (202, 178, 214), | |
107 (106, 61, 154), | |
108 (255, 255, 153), | |
109 (177, 89, 40), | |
110 (228, 26, 28), | |
111 (55, 126, 184), | |
112 (77, 175, 74), | |
113 (152, 78, 163), | |
114 (255, 127, 0), | |
115 ] | |
116 | |
117 BREWER_DIVERGING_PALLETES = { | |
118 'BrBg': ("#543005", "#003c30"), | |
119 'PiYg': ("#8e0152", "#276419"), | |
120 'PRGn': ("#40004b", "#00441b"), | |
121 'PuOr': ("#7f3b08", "#2d004b"), | |
122 'RdBu': ("#67001f", "#053061"), | |
123 'RdGy': ("#67001f", "#1a1a1a"), | |
124 'RdYlBu': ("#a50026", "#313695"), | |
125 'RdYlGn': ("#a50026", "#006837"), | |
126 'Spectral': ("#9e0142", "#5e4fa2"), | |
127 } | |
128 | |
129 def __init__(self): | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
130 self.brewer_colour_idx = 0 |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
131 |
3 | 132 def rgb_from_hex(self, hexstr): |
133 # http://stackoverflow.com/questions/4296249/how-do-i-convert-a-hex-triplet-to-an-rgb-tuple-and-back | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
134 return struct.unpack('BBB', binascii.unhexlify(hexstr)) |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
135 |
3 | 136 def min_max_gff(self, gff_file): |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
137 min_val = None |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
138 max_val = None |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
139 with open(gff_file, 'r') as handle: |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
140 for line in handle: |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
141 try: |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
142 value = float(line.split('\t')[5]) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
143 min_val = min(value, (min_val or value)) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
144 max_val = max(value, (max_val or value)) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
145 |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
146 if value < min_val: |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
147 min_val = value |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
148 |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
149 if value > max_val: |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
150 max_val = value |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
151 except Exception: |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
152 pass |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
153 return min_val, max_val |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
154 |
3 | 155 def hex_from_rgb(self, r, g, b): |
156 return '#%02x%02x%02x' % (r, g, b) | |
157 | |
158 def _get_colours(self): | |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
159 r, g, b = self.BREWER_COLOUR_SCHEMES[self.brewer_colour_idx % len(self.BREWER_COLOUR_SCHEMES)] |
3 | 160 self.brewer_colour_idx += 1 |
161 return r, g, b | |
162 | |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
163 def parse_menus(self, track): |
12
db5fe5a3176a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents:
11
diff
changeset
|
164 trackConfig = {'menuTemplate': [{}, {}, {}, {}]} |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
165 |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
166 if 'menu' in track['menus']: |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
167 menu_list = [track['menus']['menu']] |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
168 if isinstance(track['menus']['menu'], list): |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
169 menu_list = track['menus']['menu'] |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
170 |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
171 for m in menu_list: |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
172 tpl = { |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
173 'action': m['action'], |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
174 'label': m.get('label', '{name}'), |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
175 'iconClass': m.get('iconClass', 'dijitIconBookmark'), |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
176 } |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
177 if 'url' in m: |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
178 tpl['url'] = m['url'] |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
179 if 'content' in m: |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
180 tpl['content'] = m['content'] |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
181 if 'title' in m: |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
182 tpl['title'] = m['title'] |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
183 |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
184 trackConfig['menuTemplate'].append(tpl) |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
185 |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
186 return trackConfig |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
187 |
3 | 188 def parse_colours(self, track, trackFormat, gff3=None): |
189 # Wiggle tracks have a bicolor pallete | |
190 trackConfig = {'style': {}} | |
191 if trackFormat == 'wiggle': | |
192 | |
193 trackConfig['style']['pos_color'] = track['wiggle']['color_pos'] | |
194 trackConfig['style']['neg_color'] = track['wiggle']['color_neg'] | |
195 | |
196 if trackConfig['style']['pos_color'] == '__auto__': | |
197 trackConfig['style']['neg_color'] = self.hex_from_rgb(*self._get_colours()) | |
198 trackConfig['style']['pos_color'] = self.hex_from_rgb(*self._get_colours()) | |
199 | |
200 # Wiggle tracks can change colour at a specified place | |
201 bc_pivot = track['wiggle']['bicolor_pivot'] | |
202 if bc_pivot not in ('mean', 'zero'): | |
203 # The values are either one of those two strings | |
204 # or a number | |
205 bc_pivot = float(bc_pivot) | |
206 trackConfig['bicolor_pivot'] = bc_pivot | |
207 elif 'scaling' in track: | |
208 if track['scaling']['method'] == 'ignore': | |
209 if track['scaling']['scheme']['color'] != '__auto__': | |
210 trackConfig['style']['color'] = track['scaling']['scheme']['color'] | |
211 else: | |
212 trackConfig['style']['color'] = self.hex_from_rgb(*self._get_colours()) | |
213 else: | |
214 # Scored method | |
215 algo = track['scaling']['algo'] | |
216 # linear, logarithmic, blast | |
217 scales = track['scaling']['scales'] | |
218 # type __auto__, manual (min, max) | |
219 scheme = track['scaling']['scheme'] | |
220 # scheme -> (type (opacity), color) | |
221 # ================================== | |
222 # GENE CALLS OR BLAST | |
223 # ================================== | |
224 if trackFormat == 'blast': | |
225 red, green, blue = self._get_colours() | |
226 color_function = self.COLOR_FUNCTION_TEMPLATE.format(**{ | |
227 'score': "feature._parent.get('score')", | |
228 'opacity': self.OPACITY_MATH['blast'], | |
229 'red': red, | |
230 'green': green, | |
231 'blue': blue, | |
232 }) | |
233 trackConfig['style']['color'] = color_function.replace('\n', '') | |
234 elif trackFormat == 'gene_calls': | |
235 # Default values, based on GFF3 spec | |
236 min_val = 0 | |
237 max_val = 1000 | |
238 # Get min/max and build a scoring function since JBrowse doesn't | |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
239 if scales['type'] == 'automatic' or scales['type'] == '__auto__': |
3 | 240 min_val, max_val = self.min_max_gff(gff3) |
241 else: | |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
242 min_val = scales.get('min', 0) |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
243 max_val = scales.get('max', 1000) |
3 | 244 |
245 if scheme['color'] == '__auto__': | |
246 user_color = 'undefined' | |
247 auto_color = "'%s'" % self.hex_from_rgb(*self._get_colours()) | |
248 elif scheme['color'].startswith('#'): | |
249 user_color = "'%s'" % self.hex_from_rgb(*self.rgb_from_hex(scheme['color'][1:])) | |
250 auto_color = 'undefined' | |
251 else: | |
252 user_color = 'undefined' | |
253 auto_color = "'%s'" % self.hex_from_rgb(*self._get_colours()) | |
254 | |
255 color_function = self.COLOR_FUNCTION_TEMPLATE_QUAL.format(**{ | |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
256 'opacity': self.OPACITY_MATH[algo].format(**{'max': max_val, 'min': min_val}), |
3 | 257 'user_spec_color': user_color, |
258 'auto_gen_color': auto_color, | |
259 }) | |
260 | |
261 trackConfig['style']['color'] = color_function.replace('\n', '') | |
262 return trackConfig | |
263 | |
264 | |
265 def etree_to_dict(t): | |
266 d = {t.tag: {} if t.attrib else None} | |
267 children = list(t) | |
268 if children: | |
269 dd = defaultdict(list) | |
270 for dc in map(etree_to_dict, children): | |
10
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
271 for k, v in dc.items(): |
3 | 272 dd[k].append(v) |
10
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
273 d = {t.tag: {k: v[0] if len(v) == 1 else v for k, v in dd.items()}} |
3 | 274 if t.attrib: |
10
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
275 d[t.tag].update(('@' + k, v) for k, v in t.attrib.items()) |
3 | 276 if t.text: |
277 text = t.text.strip() | |
278 if children or t.attrib: | |
279 if text: | |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
280 d[t.tag]['#text'] = text |
3 | 281 else: |
282 d[t.tag] = text | |
283 return d | |
284 | |
285 | |
286 # score comes from feature._parent.get('score') or feature.get('score') | |
287 | |
288 INSTALLED_TO = os.path.dirname(os.path.realpath(__file__)) | |
289 | |
290 | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
291 def metadata_from_node(node): |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
292 metadata = {} |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
293 try: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
294 if len(node.findall('dataset')) != 1: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
295 # exit early |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
296 return metadata |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
297 except Exception: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
298 return {} |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
299 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
300 for (key, value) in node.findall('dataset')[0].attrib.items(): |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
301 metadata['dataset_%s' % key] = value |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
302 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
303 for (key, value) in node.findall('history')[0].attrib.items(): |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
304 metadata['history_%s' % key] = value |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
305 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
306 for (key, value) in node.findall('metadata')[0].attrib.items(): |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
307 metadata['metadata_%s' % key] = value |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
308 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
309 for (key, value) in node.findall('tool')[0].attrib.items(): |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
310 metadata['tool_%s' % key] = value |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
311 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
312 # Additional Mappings applied: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
313 metadata['dataset_edam_format'] = '<a target="_blank" href="http://edamontology.org/{0}">{1}</a>'.format(metadata['dataset_edam_format'], metadata['dataset_file_ext']) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
314 metadata['history_user_email'] = '<a href="mailto:{0}">{0}</a>'.format(metadata['history_user_email']) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
315 metadata['history_display_name'] = '<a target="_blank" href="{galaxy}/history/view/{encoded_hist_id}">{hist_name}</a>'.format( |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
316 galaxy=GALAXY_INFRASTRUCTURE_URL, |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
317 encoded_hist_id=metadata['history_id'], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
318 hist_name=metadata['history_display_name'] |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
319 ) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
320 metadata['tool_tool'] = '<a target="_blank" href="{galaxy}/datasets/{encoded_id}/show_params">{tool_id}</a>'.format( |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
321 galaxy=GALAXY_INFRASTRUCTURE_URL, |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
322 encoded_id=metadata['dataset_id'], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
323 tool_id=metadata['tool_tool_id'], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
324 tool_version=metadata['tool_tool_version'], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
325 ) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
326 return metadata |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
327 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
328 |
3 | 329 class JbrowseConnector(object): |
330 | |
331 def __init__(self, jbrowse, outdir, genomes, standalone=False, gencode=1): | |
332 self.TN_TABLE = { | |
333 'gff3': '--gff', | |
334 'gff': '--gff', | |
335 'bed': '--bed', | |
336 'genbank': '--gbk', | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
337 } |
3 | 338 |
339 self.cs = ColorScaling() | |
340 self.jbrowse = jbrowse | |
341 self.outdir = outdir | |
342 self.genome_paths = genomes | |
343 self.standalone = standalone | |
344 self.gencode = gencode | |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
345 self.tracksToIndex = [] |
3 | 346 |
347 if standalone: | |
348 self.clone_jbrowse(self.jbrowse, self.outdir) | |
349 else: | |
350 try: | |
351 os.makedirs(self.outdir) | |
352 except OSError: | |
353 # Ignore if the folder exists | |
354 pass | |
355 | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
356 try: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
357 os.makedirs(os.path.join(self.outdir, 'data', 'raw')) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
358 except OSError: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
359 # Ignore if the folder exists |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
360 pass |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
361 |
3 | 362 self.process_genomes() |
363 self.update_gencode() | |
364 | |
365 def update_gencode(self): | |
366 table = CodonTable.unambiguous_dna_by_id[int(self.gencode)] | |
367 trackList = os.path.join(self.outdir, 'data', 'trackList.json') | |
368 with open(trackList, 'r') as handle: | |
369 trackListData = json.load(handle) | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
370 |
3 | 371 trackListData['tracks'][0].update({ |
372 'codonStarts': table.start_codons, | |
373 'codonStops': table.stop_codons, | |
374 'codonTable': table.forward_table, | |
375 }) | |
376 | |
377 with open(trackList, 'w') as handle: | |
378 json.dump(trackListData, handle, indent=2) | |
379 | |
380 def subprocess_check_call(self, command): | |
381 log.debug('cd %s && %s', self.outdir, ' '.join(command)) | |
382 subprocess.check_call(command, cwd=self.outdir) | |
383 | |
384 def _jbrowse_bin(self, command): | |
385 return os.path.realpath(os.path.join(self.jbrowse, 'bin', command)) | |
386 | |
387 def process_genomes(self): | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
388 for genome_node in self.genome_paths: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
389 # TODO: Waiting on https://github.com/GMOD/jbrowse/pull/884 |
3 | 390 self.subprocess_check_call([ |
391 'perl', self._jbrowse_bin('prepare-refseqs.pl'), | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
392 '--fasta', genome_node['path']]) |
3 | 393 |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
394 def generate_names(self): |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
395 # Generate names |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
396 args = [ |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
397 'perl', self._jbrowse_bin('generate-names.pl'), |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
398 '--hashBits', '16' |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
399 ] |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
400 |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
401 tracks = ','.join(self.tracksToIndex) |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
402 if tracks: |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
403 args += ['--tracks', tracks] |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
404 else: |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
405 # No tracks to index, index only the refseq |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
406 args += ['--tracks', 'DNA'] |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
407 |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
408 self.subprocess_check_call(args) |
3 | 409 |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
410 def _add_json(self, json_data): |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
411 cmd = [ |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
412 'perl', self._jbrowse_bin('add-json.pl'), |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
413 json.dumps(json_data), |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
414 os.path.join('data', 'trackList.json') |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
415 ] |
3 | 416 self.subprocess_check_call(cmd) |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
417 |
3 | 418 def _add_track_json(self, json_data): |
10
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
419 if len(json_data) == 0: |
3 | 420 return |
421 | |
422 tmp = tempfile.NamedTemporaryFile(delete=False) | |
423 tmp.write(json.dumps(json_data)) | |
424 tmp.close() | |
425 cmd = ['perl', self._jbrowse_bin('add-track-json.pl'), tmp.name, | |
426 os.path.join('data', 'trackList.json')] | |
427 self.subprocess_check_call(cmd) | |
428 os.unlink(tmp.name) | |
429 | |
430 def _blastxml_to_gff3(self, xml, min_gap=10): | |
431 gff3_unrebased = tempfile.NamedTemporaryFile(delete=False) | |
432 cmd = ['python', os.path.join(INSTALLED_TO, 'blastxml_to_gapped_gff3.py'), | |
433 '--trim', '--trim_end', '--min_gap', str(min_gap), xml] | |
434 log.debug('cd %s && %s > %s', self.outdir, ' '.join(cmd), gff3_unrebased.name) | |
435 subprocess.check_call(cmd, cwd=self.outdir, stdout=gff3_unrebased) | |
436 gff3_unrebased.close() | |
437 return gff3_unrebased.name | |
438 | |
439 def add_blastxml(self, data, trackData, blastOpts, **kwargs): | |
440 gff3 = self._blastxml_to_gff3(data, min_gap=blastOpts['min_gap']) | |
0
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
441 |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
442 if 'parent' in blastOpts and blastOpts['parent'] != 'None': |
3 | 443 gff3_rebased = tempfile.NamedTemporaryFile(delete=False) |
444 cmd = ['python', os.path.join(INSTALLED_TO, 'gff3_rebase.py')] | |
445 if blastOpts.get('protein', 'false') == 'true': | |
446 cmd.append('--protein2dna') | |
447 cmd.extend([os.path.realpath(blastOpts['parent']), gff3]) | |
448 log.debug('cd %s && %s > %s', self.outdir, ' '.join(cmd), gff3_rebased.name) | |
449 subprocess.check_call(cmd, cwd=self.outdir, stdout=gff3_rebased) | |
450 gff3_rebased.close() | |
451 | |
452 # Replace original gff3 file | |
453 shutil.copy(gff3_rebased.name, gff3) | |
454 os.unlink(gff3_rebased.name) | |
455 | |
456 config = { | |
457 'glyph': 'JBrowse/View/FeatureGlyph/Segments', | |
458 "category": trackData['category'], | |
459 } | |
460 | |
461 clientConfig = trackData['style'] | |
462 | |
463 cmd = ['perl', self._jbrowse_bin('flatfile-to-json.pl'), | |
464 '--gff', gff3, | |
465 '--trackLabel', trackData['label'], | |
466 '--key', trackData['key'], | |
467 '--clientConfig', json.dumps(clientConfig), | |
468 '--config', json.dumps(config), | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
469 '--trackType', 'BlastView/View/Track/CanvasFeatures' |
3 | 470 ] |
471 | |
13
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
472 # className in --clientConfig is ignored, it needs to be set with --className |
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
473 if 'className' in trackData['style']: |
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
474 cmd += ['--className', trackData['style']['className']] |
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
475 |
3 | 476 self.subprocess_check_call(cmd) |
477 os.unlink(gff3) | |
478 | |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
479 if blastOpts.get('index', 'false') == 'true': |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
480 self.tracksToIndex.append("%s" % trackData['label']) |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
481 |
3 | 482 def add_bigwig(self, data, trackData, wiggleOpts, **kwargs): |
483 dest = os.path.join('data', 'raw', trackData['label'] + '.bw') | |
16
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
484 cmd = ['ln', '-s', data, dest] |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
485 self.subprocess_check_call(cmd) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
486 |
12
db5fe5a3176a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents:
11
diff
changeset
|
487 url = os.path.join('raw', trackData['label'] + '.bw') |
3 | 488 trackData.update({ |
12
db5fe5a3176a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents:
11
diff
changeset
|
489 "urlTemplate": url, |
3 | 490 "storeClass": "JBrowse/Store/SeqFeature/BigWig", |
491 "type": "JBrowse/View/Track/Wiggle/Density", | |
492 }) | |
493 | |
494 trackData['type'] = wiggleOpts['type'] | |
495 trackData['variance_band'] = True if wiggleOpts['variance_band'] == 'true' else False | |
496 | |
497 if 'min' in wiggleOpts and 'max' in wiggleOpts: | |
498 trackData['min_score'] = wiggleOpts['min'] | |
499 trackData['max_score'] = wiggleOpts['max'] | |
500 else: | |
501 trackData['autoscale'] = wiggleOpts.get('autoscale', 'local') | |
502 | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
503 trackData['scale'] = wiggleOpts['scale'] |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
504 |
3 | 505 self._add_track_json(trackData) |
506 | |
507 def add_bam(self, data, trackData, bamOpts, bam_index=None, **kwargs): | |
508 dest = os.path.join('data', 'raw', trackData['label'] + '.bam') | |
509 cmd = ['ln', '-s', os.path.realpath(data), dest] | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
510 self.subprocess_check_call(cmd) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
511 |
3 | 512 cmd = ['ln', '-s', os.path.realpath(bam_index), dest + '.bai'] |
513 self.subprocess_check_call(cmd) | |
514 | |
12
db5fe5a3176a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents:
11
diff
changeset
|
515 url = os.path.join('raw', trackData['label'] + '.bam') |
3 | 516 trackData.update({ |
12
db5fe5a3176a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents:
11
diff
changeset
|
517 "urlTemplate": url, |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
518 "type": "JBrowse/View/Track/Alignments2", |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
519 "storeClass": "JBrowse/Store/SeqFeature/BAM", |
3 | 520 }) |
521 | |
14
18be2d72fdee
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0bfb0de98c918860c21808e8832caad9f0535975
iuc
parents:
13
diff
changeset
|
522 # Apollo will only switch to the (prettier) 'bam-read' className if it's not set explicitly in the track config |
18be2d72fdee
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0bfb0de98c918860c21808e8832caad9f0535975
iuc
parents:
13
diff
changeset
|
523 # So remove the default 'feature' value for these bam tracks |
18be2d72fdee
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0bfb0de98c918860c21808e8832caad9f0535975
iuc
parents:
13
diff
changeset
|
524 if 'className' in trackData['style'] and trackData['style']['className'] == 'feature': |
18be2d72fdee
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0bfb0de98c918860c21808e8832caad9f0535975
iuc
parents:
13
diff
changeset
|
525 del trackData['style']['className'] |
18be2d72fdee
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0bfb0de98c918860c21808e8832caad9f0535975
iuc
parents:
13
diff
changeset
|
526 |
3 | 527 self._add_track_json(trackData) |
528 | |
529 if bamOpts.get('auto_snp', 'false') == 'true': | |
530 trackData2 = copy.copy(trackData) | |
531 trackData2.update({ | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
532 "type": "JBrowse/View/Track/SNPCoverage", |
3 | 533 "key": trackData['key'] + " - SNPs/Coverage", |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
534 "label": trackData['label'] + "_autosnp", |
3 | 535 }) |
536 self._add_track_json(trackData2) | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
537 |
3 | 538 def add_vcf(self, data, trackData, vcfOpts={}, **kwargs): |
539 dest = os.path.join('data', 'raw', trackData['label'] + '.vcf') | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
540 # ln? |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
541 cmd = ['ln', '-s', data, dest] |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
542 self.subprocess_check_call(cmd) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
543 cmd = ['bgzip', dest] |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
544 self.subprocess_check_call(cmd) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
545 cmd = ['tabix', '-p', 'vcf', dest + '.gz'] |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
546 self.subprocess_check_call(cmd) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
547 |
12
db5fe5a3176a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents:
11
diff
changeset
|
548 url = os.path.join('raw', trackData['label'] + '.vcf') |
3 | 549 trackData.update({ |
12
db5fe5a3176a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents:
11
diff
changeset
|
550 "urlTemplate": url, |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
551 "type": "JBrowse/View/Track/HTMLVariants", |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
552 "storeClass": "JBrowse/Store/SeqFeature/VCFTabix", |
3 | 553 }) |
554 self._add_track_json(trackData) | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
555 |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
556 def add_features(self, data, format, trackData, gffOpts, metadata=None, **kwargs): |
3 | 557 cmd = [ |
558 'perl', self._jbrowse_bin('flatfile-to-json.pl'), | |
559 self.TN_TABLE.get(format, 'gff'), | |
560 data, | |
561 '--trackLabel', trackData['label'], | |
562 '--key', trackData['key'] | |
563 ] | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
564 |
13
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
565 # className in --clientConfig is ignored, it needs to be set with --className |
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
566 if 'className' in trackData['style']: |
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
567 cmd += ['--className', trackData['style']['className']] |
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
568 |
3 | 569 config = copy.copy(trackData) |
570 clientConfig = trackData['style'] | |
571 del config['style'] | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
572 |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
573 if 'match' in gffOpts: |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
574 config['glyph'] = 'JBrowse/View/FeatureGlyph/Segments' |
3 | 575 cmd += ['--type', gffOpts['match']] |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
576 |
3 | 577 cmd += ['--clientConfig', json.dumps(clientConfig), |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
578 ] |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
579 |
10
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
580 trackType = 'JBrowse/View/Track/CanvasFeatures' |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
581 if 'trackType' in gffOpts: |
10
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
582 trackType = gffOpts['trackType'] |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
583 |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
584 if trackType == 'JBrowse/View/Track/CanvasFeatures': |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
585 if 'transcriptType' in gffOpts and gffOpts['transcriptType']: |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
586 config['transcriptType'] = gffOpts['transcriptType'] |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
587 if 'subParts' in gffOpts and gffOpts['subParts']: |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
588 config['subParts'] = gffOpts['subParts'] |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
589 if 'impliedUTRs' in gffOpts and gffOpts['impliedUTRs']: |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
590 config['impliedUTRs'] = gffOpts['impliedUTRs'] |
13
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
591 elif trackType == 'JBrowse/View/Track/HTMLFeatures': |
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
592 if 'transcriptType' in gffOpts and gffOpts['transcriptType']: |
69c5e9c0add0
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents:
12
diff
changeset
|
593 cmd += ['--type', gffOpts['transcriptType']] |
10
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
594 |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
595 cmd += [ |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
596 '--trackType', gffOpts['trackType'] |
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
597 ] |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
598 |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
599 if metadata: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
600 config.update({'metadata': metadata}) |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
601 cmd.extend(['--config', json.dumps(config)]) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
602 |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
603 self.subprocess_check_call(cmd) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
604 |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
605 if gffOpts.get('index', 'false') == 'true': |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
606 self.tracksToIndex.append("%s" % trackData['label']) |
3 | 607 |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
608 def add_rest(self, url, trackData): |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
609 data = { |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
610 "label": trackData['label'], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
611 "key": trackData['key'], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
612 "category": trackData['category'], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
613 "type": "JBrowse/View/Track/HTMLFeatures", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
614 "storeClass": "JBrowse/Store/SeqFeature/REST", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
615 "baseUrl": url, |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
616 "query": { |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
617 "organism": "tyrannosaurus" |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
618 } |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
619 } |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
620 self._add_track_json(data) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
621 |
3 | 622 def process_annotations(self, track): |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
623 category = track['category'].replace('__pd__date__pd__', TODAY) |
3 | 624 outputTrackConfig = { |
625 'style': { | |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
626 'label': track['style'].get('label', 'description'), |
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
627 'className': track['style'].get('className', 'feature'), |
3 | 628 'description': track['style'].get('description', ''), |
629 }, | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
630 'overridePlugins': track['style'].get('overridePlugins', False) == 'True', |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
631 'overrideDraggable': track['style'].get('overrideDraggable', False) == 'True', |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
632 'maxHeight': track['style'].get('maxHeight', '600'), |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
633 'category': category, |
3 | 634 } |
635 | |
16
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
636 mapped_chars = { |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
637 '>': '__gt__', |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
638 '<': '__lt__', |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
639 "'": '__sq__', |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
640 '"': '__dq__', |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
641 '[': '__ob__', |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
642 ']': '__cb__', |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
643 '{': '__oc__', |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
644 '}': '__cc__', |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
645 '@': '__at__', |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
646 '#': '__pd__' |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
647 } |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
648 |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
649 for i, (dataset_path, dataset_ext, track_human_label, extra_metadata) in enumerate(track['trackfiles']): |
16
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
650 # Unsanitize labels (element_identifiers are always sanitized by Galaxy) |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
651 for key, value in mapped_chars.items(): |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
652 track_human_label = track_human_label.replace(value, key) |
b5c5470d7c09
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents:
14
diff
changeset
|
653 |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
654 log.info('Processing %s / %s', category, track_human_label) |
3 | 655 outputTrackConfig['key'] = track_human_label |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
656 # We add extra data to hash for the case of REST + SPARQL. |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
657 try: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
658 rest_url = track['conf']['options']['url'] |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
659 except KeyError: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
660 rest_url = '' |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
661 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
662 # I chose to use track['category'] instead of 'category' here. This |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
663 # is intentional. This way re-running the tool on a different date |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
664 # will not generate different hashes and make comparison of outputs |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
665 # much simpler. |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
666 hashData = [dataset_path, track_human_label, track['category'], rest_url] |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
667 hashData = '|'.join(hashData).encode('utf-8') |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
668 outputTrackConfig['label'] = hashlib.md5(hashData).hexdigest() + '_%s' % i |
3 | 669 |
670 # Colour parsing is complex due to different track types having | |
671 # different colour options. | |
672 colourOptions = self.cs.parse_colours(track['conf']['options'], track['format'], gff3=dataset_path) | |
673 # This used to be done with a dict.update() call, however that wiped out any previous style settings... | |
674 for key in colourOptions: | |
675 if key == 'style': | |
676 for subkey in colourOptions['style']: | |
677 outputTrackConfig['style'][subkey] = colourOptions['style'][subkey] | |
678 else: | |
679 outputTrackConfig[key] = colourOptions[key] | |
680 | |
12
db5fe5a3176a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents:
11
diff
changeset
|
681 if 'menus' in track['conf']['options']: |
db5fe5a3176a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents:
11
diff
changeset
|
682 menus = self.cs.parse_menus(track['conf']['options']) |
db5fe5a3176a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents:
11
diff
changeset
|
683 outputTrackConfig.update(menus) |
8
ad4b9d7eae6a
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents:
5
diff
changeset
|
684 |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
685 # import pprint; pprint.pprint(track) |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
686 # import sys; sys.exit() |
3 | 687 if dataset_ext in ('gff', 'gff3', 'bed'): |
688 self.add_features(dataset_path, dataset_ext, outputTrackConfig, | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
689 track['conf']['options']['gff'], metadata=extra_metadata) |
3 | 690 elif dataset_ext == 'bigwig': |
691 self.add_bigwig(dataset_path, outputTrackConfig, | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
692 track['conf']['options']['wiggle'], metadata=extra_metadata) |
3 | 693 elif dataset_ext == 'bam': |
694 real_indexes = track['conf']['options']['pileup']['bam_indices']['bam_index'] | |
695 if not isinstance(real_indexes, list): | |
696 # <bam_indices> | |
697 # <bam_index>/path/to/a.bam.bai</bam_index> | |
698 # </bam_indices> | |
699 # | |
700 # The above will result in the 'bam_index' key containing a | |
701 # string. If there are two or more indices, the container | |
702 # becomes a list. Fun! | |
703 real_indexes = [real_indexes] | |
704 | |
705 self.add_bam(dataset_path, outputTrackConfig, | |
706 track['conf']['options']['pileup'], | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
707 bam_index=real_indexes[i], metadata=extra_metadata) |
3 | 708 elif dataset_ext == 'blastxml': |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
709 self.add_blastxml(dataset_path, outputTrackConfig, track['conf']['options']['blast'], metadata=extra_metadata) |
3 | 710 elif dataset_ext == 'vcf': |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
711 self.add_vcf(dataset_path, outputTrackConfig, metadata=extra_metadata) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
712 elif dataset_ext == 'rest': |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
713 self.add_rest(track['conf']['options']['url'], outputTrackConfig, metadata=extra_metadata) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
714 else: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
715 log.warn('Do not know how to handle %s', dataset_ext) |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
716 |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
717 # Return non-human label for use in other fields |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
718 yield outputTrackConfig['label'] |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
719 |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
720 def add_final_data(self, data): |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
721 viz_data = {} |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
722 if len(data['visibility']['default_on']) > 0: |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
723 viz_data['defaultTracks'] = ','.join(data['visibility']['default_on']) |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
724 |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
725 if len(data['visibility']['always']) > 0: |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
726 viz_data['alwaysOnTracks'] = ','.join(data['visibility']['always']) |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
727 |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
728 if len(data['visibility']['force']) > 0: |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
729 viz_data['forceTracks'] = ','.join(data['visibility']['force']) |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
730 |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
731 generalData = {} |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
732 if data['general']['aboutDescription'] is not None: |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
733 generalData['aboutThisBrowser'] = {'description': data['general']['aboutDescription'].strip()} |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
734 |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
735 generalData['view'] = { |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
736 'trackPadding': data['general']['trackPadding'] |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
737 } |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
738 generalData['shareLink'] = (data['general']['shareLink'] == 'true') |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
739 generalData['show_tracklist'] = (data['general']['show_tracklist'] == 'true') |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
740 generalData['show_nav'] = (data['general']['show_nav'] == 'true') |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
741 generalData['show_overview'] = (data['general']['show_overview'] == 'true') |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
742 generalData['show_menu'] = (data['general']['show_menu'] == 'true') |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
743 generalData['hideGenomeOptions'] = (data['general']['hideGenomeOptions'] == 'true') |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
744 generalData['plugins'] = data['plugins'] |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
745 |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
746 viz_data.update(generalData) |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
747 self._add_json(viz_data) |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
748 |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
749 if 'GCContent' in data['plugins_python']: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
750 self._add_track_json({ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
751 "storeClass": "JBrowse/Store/SeqFeature/SequenceChunks", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
752 "type": "GCContent/View/Track/GCContentXY", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
753 "label": "GCContentXY", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
754 "urlTemplate": "seq/{refseq_dirpath}/{refseq}-", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
755 "bicolor_pivot": 0.5 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
756 # TODO: Expose params for everyone. |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
757 }) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
758 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
759 if 'ComboTrackSelector' in data['plugins_python']: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
760 with open(os.path.join(self.outdir, 'data', 'trackList.json'), 'r') as handle: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
761 trackListJson = json.load(handle) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
762 trackListJson.update({ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
763 "trackSelector": { |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
764 "renameFacets": { |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
765 "tool_tool": "Tool ID", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
766 "tool_tool_id": "Tool ID", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
767 "tool_tool_version": "Tool Version", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
768 "dataset_edam_format": "EDAM", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
769 "dataset_size": "Size", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
770 "history_display_name": "History Name", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
771 "history_user_email": "Owner", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
772 "metadata_dbkey": "Dbkey", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
773 }, |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
774 "displayColumns": [ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
775 "key", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
776 "tool_tool", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
777 "tool_tool_version", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
778 "dataset_edam_format", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
779 "dataset_size", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
780 "history_display_name", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
781 "history_user_email", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
782 "metadata_dbkey", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
783 ], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
784 "type": "Faceted", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
785 "title": ["Galaxy Metadata"], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
786 "escapeHTMLInData": False |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
787 }, |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
788 "trackMetadata": { |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
789 "indexFacets": [ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
790 "category", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
791 "key", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
792 "tool_tool_id", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
793 "tool_tool_version", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
794 "dataset_edam_format", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
795 "history_user_email", |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
796 "history_display_name" |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
797 ] |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
798 } |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
799 }) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
800 with open(os.path.join(self.outdir, 'data', 'trackList2.json'), 'w') as handle: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
801 json.dump(trackListJson, handle) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
802 |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
803 def clone_jbrowse(self, jbrowse_dir, destination): |
3 | 804 """Clone a JBrowse directory into a destination directory. |
805 """ | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
806 # JBrowse seems to have included some bad symlinks, cp ignores bad symlinks |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
807 # unlike copytree |
3 | 808 cmd = ['cp', '-r', os.path.join(jbrowse_dir, '.'), destination] |
809 log.debug(' '.join(cmd)) | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
810 subprocess.check_call(cmd) |
3 | 811 cmd = ['mkdir', '-p', os.path.join(destination, 'data', 'raw')] |
812 log.debug(' '.join(cmd)) | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
813 subprocess.check_call(cmd) |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
814 |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
815 # http://unix.stackexchange.com/a/38691/22785 |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
816 # JBrowse releases come with some broken symlinks |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
817 cmd = ['find', destination, '-type', 'l', '-xtype', 'l'] |
3 | 818 log.debug(' '.join(cmd)) |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
819 symlinks = subprocess.check_output(cmd) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
820 for i in symlinks: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
821 try: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
822 os.unlink(i) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
823 except OSError: |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
824 pass |
0
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
825 |
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
826 |
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
827 if __name__ == '__main__': |
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
828 parser = argparse.ArgumentParser(description="", epilog="") |
10
1a6d882d340d
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents:
8
diff
changeset
|
829 parser.add_argument('xml', type=argparse.FileType('r'), help='Track Configuration') |
0
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
830 |
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
831 parser.add_argument('--jbrowse', help='Folder containing a jbrowse release') |
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
832 parser.add_argument('--outdir', help='Output directory', default='out') |
3 | 833 parser.add_argument('--standalone', help='Standalone mode includes a copy of JBrowse', action='store_true') |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
834 parser.add_argument('--version', '-V', action='version', version="%(prog)s 0.7.0") |
0
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
835 args = parser.parse_args() |
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
836 |
3 | 837 tree = ET.parse(args.xml.name) |
838 root = tree.getroot() | |
839 | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
840 jc = JbrowseConnector( |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
841 jbrowse=args.jbrowse, |
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
842 outdir=args.outdir, |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
843 genomes=[ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
844 { |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
845 'path': os.path.realpath(x.attrib['path']), |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
846 'meta': metadata_from_node(x.find('metadata')) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
847 } |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
848 for x in root.findall('metadata/genomes/genome') |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
849 ], |
3 | 850 standalone=args.standalone, |
851 gencode=root.find('metadata/gencode').text | |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
852 ) |
0
2c9e5136b416
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff
changeset
|
853 |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
854 extra_data = { |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
855 'visibility': { |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
856 'default_on': [], |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
857 'default_off': [], |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
858 'force': [], |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
859 'always': [], |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
860 }, |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
861 'general': { |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
862 'defaultLocation': root.find('metadata/general/defaultLocation').text, |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
863 'trackPadding': int(root.find('metadata/general/trackPadding').text), |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
864 'shareLink': root.find('metadata/general/shareLink').text, |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
865 'aboutDescription': root.find('metadata/general/aboutDescription').text, |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
866 'show_tracklist': root.find('metadata/general/show_tracklist').text, |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
867 'show_nav': root.find('metadata/general/show_nav').text, |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
868 'show_overview': root.find('metadata/general/show_overview').text, |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
869 'show_menu': root.find('metadata/general/show_menu').text, |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
870 'hideGenomeOptions': root.find('metadata/general/hideGenomeOptions').text, |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
871 }, |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
872 'plugins': [{ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
873 'location': 'https://cdn.rawgit.com/TAMU-CPT/blastview/97572a21b7f011c2b4d9a0b5af40e292d694cbef/', |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
874 'name': 'BlastView' |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
875 }], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
876 'plugins_python': ['BlastView'], |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
877 } |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
878 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
879 plugins = root.find('plugins').attrib |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
880 if plugins['GCContent'] == 'True': |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
881 extra_data['plugins_python'].append('GCContent') |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
882 extra_data['plugins'].append({ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
883 'location': 'https://cdn.rawgit.com/elsiklab/gccontent/5c8b0582ecebf9edf684c76af8075fb3d30ec3fa/', |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
884 'name': 'GCContent' |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
885 }) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
886 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
887 if plugins['Bookmarks'] == 'True': |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
888 extra_data['plugins'].append({ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
889 'location': 'https://cdn.rawgit.com/TAMU-CPT/bookmarks-jbrowse/5242694120274c86e1ccd5cb0e5e943e78f82393/', |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
890 'name': 'Bookmarks' |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
891 }) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
892 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
893 if plugins['ComboTrackSelector'] == 'True': |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
894 extra_data['plugins_python'].append('ComboTrackSelector') |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
895 extra_data['plugins'].append({ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
896 'location': 'https://cdn.rawgit.com/Arabidopsis-Information-Portal/ComboTrackSelector/52403928d5ccbe2e3a86b0fa5eb8e61c0f2e2f57', |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
897 'icon': 'https://galaxyproject.org/images/logos/galaxy-icon-square.png', |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
898 'name': 'ComboTrackSelector' |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
899 }) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
900 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
901 if plugins['theme'] == 'Minimalist': |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
902 extra_data['plugins'].append({ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
903 'location': 'https://cdn.rawgit.com/erasche/jbrowse-minimalist-theme/d698718442da306cf87f033c72ddb745f3077775/', |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
904 'name': 'MinimalistTheme' |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
905 }) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
906 elif plugins['theme'] == 'Dark': |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
907 extra_data['plugins'].append({ |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
908 'location': 'https://cdn.rawgit.com/erasche/jbrowse-dark-theme/689eceb7e33bbc1b9b15518d45a5a79b2e5d0a26/', |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
909 'name': 'DarkTheme' |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
910 }) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
911 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
912 GALAXY_INFRASTRUCTURE_URL = root.find('metadata/galaxyUrl').text |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
913 # Sometimes this comes as `localhost` without a protocol |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
914 if not GALAXY_INFRASTRUCTURE_URL.startswith('http'): |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
915 # so we'll prepend `http://` and hope for the best. Requests *should* |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
916 # be GET and not POST so it should redirect OK |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
917 GALAXY_INFRASTRUCTURE_URL = 'http://' + GALAXY_INFRASTRUCTURE_URL |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
918 |
3 | 919 for track in root.findall('tracks/track'): |
920 track_conf = {} | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
921 track_conf['trackfiles'] = [] |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
922 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
923 for x in track.findall('files/trackFile'): |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
924 metadata = metadata_from_node(x.find('metadata')) |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
925 |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
926 track_conf['trackfiles'].append(( |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
927 os.path.realpath(x.attrib['path']), |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
928 x.attrib['ext'], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
929 x.attrib['label'], |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
930 metadata |
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
931 )) |
1
497c6bb3b717
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents:
0
diff
changeset
|
932 |
3 | 933 track_conf['category'] = track.attrib['cat'] |
934 track_conf['format'] = track.attrib['format'] | |
935 try: | |
936 # Only pertains to gff3 + blastxml. TODO? | |
937 track_conf['style'] = {t.tag: t.text for t in track.find('options/style')} | |
17
ff11d442feed
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents:
16
diff
changeset
|
938 except TypeError as te: |
3 | 939 track_conf['style'] = {} |
940 pass | |
941 track_conf['conf'] = etree_to_dict(track.find('options')) | |
5
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
942 keys = jc.process_annotations(track_conf) |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
943 |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
944 for key in keys: |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
945 extra_data['visibility'][track.attrib.get('visibility', 'default_off')].append(key) |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
946 |
ae9382cfb6ac
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents:
3
diff
changeset
|
947 jc.add_final_data(extra_data) |
20
558d652cd681
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 75a0a1c7b26cac156f76e8266a0e2e3d81be7f02
iuc
parents:
17
diff
changeset
|
948 jc.generate_names() |