annotate jbrowse.py @ 25:1cfc579079a6 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
author iuc
date Tue, 29 Jan 2019 05:34:16 -0500
parents fa30df9b79c2
children 61ce21e36cb5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
17 from Bio.Data import CodonTable
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
18 logging.basicConfig(level=logging.INFO)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
24 class ColorScaling(object):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
25
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
26 COLOR_FUNCTION_TEMPLATE = """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
27 function(feature, variableName, glyphObject, track) {{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
28 var score = {score};
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
29 {opacity}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
30 return 'rgba({red}, {green}, {blue}, ' + opacity + ')';
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
31 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
32 """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
33
22
5f70e7fe6077 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit a4b0969b33a68a0ea9ba12291f6694aec24f13ed
iuc
parents: 21
diff changeset
34 COLOR_FUNCTION_TEMPLATE_QUAL = r"""
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
35 function(feature, variableName, glyphObject, track) {{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
36 var search_up = function self(sf, attr){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
37 if(sf.get(attr) !== undefined){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
38 return sf.get(attr);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
39 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
40 if(sf.parent() === undefined) {{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
41 return;
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
42 }}else{{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
43 return self(sf.parent(), attr);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
44 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
47 var search_down = function self(sf, attr){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
48 if(sf.get(attr) !== undefined){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
49 return sf.get(attr);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
50 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
51 if(sf.children() === undefined) {{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
52 return;
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
53 }}else{{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
54 var kids = sf.children();
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
55 for(var child_idx in kids){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
56 var x = self(kids[child_idx], attr);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
57 if(x !== undefined){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
58 return x;
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
59 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
60 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
61 return;
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
62 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
63 }};
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
64
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
65 var color = ({user_spec_color} || search_up(feature, 'color') || search_down(feature, 'color') || {auto_gen_color});
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
66 var score = (search_up(feature, 'score') || search_down(feature, 'score'));
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
69 var result = /^#?([a-f\d]{{2}})([a-f\d]{{2}})([a-f\d]{{2}})$/i.exec(color);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
70 var red = parseInt(result[1], 16);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
71 var green = parseInt(result[2], 16);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
72 var blue = parseInt(result[3], 16);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
73 if(isNaN(opacity) || opacity < 0){{ opacity = 0; }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
74 return 'rgba(' + red + ',' + green + ',' + blue + ',' + opacity + ')';
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
75 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
78 OPACITY_MATH = {
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
79 'linear': """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
80 var opacity = (score - ({min})) / (({max}) - ({min}));
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
81 """,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
82 'logarithmic': """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
83 var opacity = (score - ({min})) / (({max}) - ({min}));
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
84 opacity = Math.log10(opacity) + Math.log10({max});
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
85 """,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
86 'blast': """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
93 """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
96 BREWER_COLOUR_IDX = 0
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
97 BREWER_COLOUR_SCHEMES = [
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
98 (166, 206, 227),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
99 (31, 120, 180),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
100 (178, 223, 138),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
101 (51, 160, 44),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
102 (251, 154, 153),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
103 (227, 26, 28),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
104 (253, 191, 111),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
105 (255, 127, 0),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
106 (202, 178, 214),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
107 (106, 61, 154),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
108 (255, 255, 153),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
109 (177, 89, 40),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
110 (228, 26, 28),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
111 (55, 126, 184),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
112 (77, 175, 74),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
113 (152, 78, 163),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
114 (255, 127, 0),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
115 ]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
116
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
117 BREWER_DIVERGING_PALLETES = {
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
118 'BrBg': ("#543005", "#003c30"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
119 'PiYg': ("#8e0152", "#276419"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
120 'PRGn': ("#40004b", "#00441b"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
121 'PuOr': ("#7f3b08", "#2d004b"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
122 'RdBu': ("#67001f", "#053061"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
123 'RdGy': ("#67001f", "#1a1a1a"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
124 'RdYlBu': ("#a50026", "#313695"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
125 'RdYlGn': ("#a50026", "#006837"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
126 'Spectral': ("#9e0142", "#5e4fa2"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
127 }
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
128
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
132 def rgb_from_hex(self, hexstr):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
155 def hex_from_rgb(self, r, g, b):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
156 return '#%02x%02x%02x' % (r, g, b)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
157
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
160 self.brewer_colour_idx += 1
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
161 return r, g, b
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
188 def parse_colours(self, track, trackFormat, gff3=None):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
189 # Wiggle tracks have a bicolor pallete
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
190 trackConfig = {'style': {}}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
191 if trackFormat == 'wiggle':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
192
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
193 trackConfig['style']['pos_color'] = track['wiggle']['color_pos']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
194 trackConfig['style']['neg_color'] = track['wiggle']['color_neg']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
195
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
196 if trackConfig['style']['pos_color'] == '__auto__':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
197 trackConfig['style']['neg_color'] = self.hex_from_rgb(*self._get_colours())
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
198 trackConfig['style']['pos_color'] = self.hex_from_rgb(*self._get_colours())
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
199
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
200 # Wiggle tracks can change colour at a specified place
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
201 bc_pivot = track['wiggle']['bicolor_pivot']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
202 if bc_pivot not in ('mean', 'zero'):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
203 # The values are either one of those two strings
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
204 # or a number
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
205 bc_pivot = float(bc_pivot)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
206 trackConfig['bicolor_pivot'] = bc_pivot
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
207 elif 'scaling' in track:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
208 if track['scaling']['method'] == 'ignore':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
209 if track['scaling']['scheme']['color'] != '__auto__':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
210 trackConfig['style']['color'] = track['scaling']['scheme']['color']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
211 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
212 trackConfig['style']['color'] = self.hex_from_rgb(*self._get_colours())
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
213 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
214 # Scored method
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
215 algo = track['scaling']['algo']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
216 # linear, logarithmic, blast
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
217 scales = track['scaling']['scales']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
218 # type __auto__, manual (min, max)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
219 scheme = track['scaling']['scheme']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
220 # scheme -> (type (opacity), color)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
221 # ==================================
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
222 # GENE CALLS OR BLAST
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
223 # ==================================
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
224 if trackFormat == 'blast':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
225 red, green, blue = self._get_colours()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
226 color_function = self.COLOR_FUNCTION_TEMPLATE.format(**{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
227 'score': "feature._parent.get('score')",
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
228 'opacity': self.OPACITY_MATH['blast'],
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
229 'red': red,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
230 'green': green,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
231 'blue': blue,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
232 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
233 trackConfig['style']['color'] = color_function.replace('\n', '')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
234 elif trackFormat == 'gene_calls':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
235 # Default values, based on GFF3 spec
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
236 min_val = 0
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
237 max_val = 1000
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
240 min_val, max_val = self.min_max_gff(gff3)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
244
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
245 if scheme['color'] == '__auto__':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
246 user_color = 'undefined'
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
247 auto_color = "'%s'" % self.hex_from_rgb(*self._get_colours())
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
248 elif scheme['color'].startswith('#'):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
249 user_color = "'%s'" % self.hex_from_rgb(*self.rgb_from_hex(scheme['color'][1:]))
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
250 auto_color = 'undefined'
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
251 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
252 user_color = 'undefined'
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
253 auto_color = "'%s'" % self.hex_from_rgb(*self._get_colours())
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
254
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
257 'user_spec_color': user_color,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
258 'auto_gen_color': auto_color,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
259 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
260
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
261 trackConfig['style']['color'] = color_function.replace('\n', '')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
262 return trackConfig
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
263
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
264
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
265 def etree_to_dict(t):
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
266 if t is None:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
267 return {}
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
268
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
269 d = {t.tag: {} if t.attrib else None}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
270 children = list(t)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
271 if children:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
272 dd = defaultdict(list)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
273 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
274 for k, v in dc.items():
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
275 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
276 d = {t.tag: {k: v[0] if len(v) == 1 else v for k, v in dd.items()}}
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
277 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
278 d[t.tag].update(('@' + k, v) for k, v in t.attrib.items())
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
279 if t.text:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
280 text = t.text.strip()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
281 if children or t.attrib:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
282 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
283 d[t.tag]['#text'] = text
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
284 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
285 d[t.tag] = text
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
286 return d
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
287
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
288
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
289 # score comes from feature._parent.get('score') or feature.get('score')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
290
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
291 INSTALLED_TO = os.path.dirname(os.path.realpath(__file__))
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
292
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
293
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
294 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
295 metadata = {}
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
296 try:
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
297 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
298 # exit early
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
299 return metadata
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
300 except Exception:
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
301 return {}
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('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
304 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
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('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
307 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
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('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
310 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
311
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
312 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
313 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
314
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
315 # 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
316 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
317 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
318 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
319 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
320 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
321 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
322 )
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
323 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
324 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
325 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
326 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
327 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
328 )
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
329 return metadata
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
330
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
331
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
332 class JbrowseConnector(object):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
333
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
334 def __init__(self, jbrowse, outdir, genomes, standalone=False, gencode=1):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
335 self.TN_TABLE = {
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
336 'gff3': '--gff',
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
337 'gff': '--gff',
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
338 'bed': '--bed',
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
339 '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
340 }
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
341
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
342 self.cs = ColorScaling()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
343 self.jbrowse = jbrowse
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
344 self.outdir = outdir
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
345 self.genome_paths = genomes
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
346 self.standalone = standalone
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
347 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
348 self.tracksToIndex = []
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
349
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
350 if standalone:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
351 self.clone_jbrowse(self.jbrowse, self.outdir)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
352 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
353 try:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
354 os.makedirs(self.outdir)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
355 except OSError:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
356 # Ignore if the folder exists
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
357 pass
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
358
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
359 try:
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
360 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
361 except OSError:
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
362 # 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
363 pass
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
364
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
365 self.process_genomes()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
366 self.update_gencode()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
367
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
368 def update_gencode(self):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
369 table = CodonTable.unambiguous_dna_by_id[int(self.gencode)]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
370 trackList = os.path.join(self.outdir, 'data', 'trackList.json')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
371 with open(trackList, 'r') as handle:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
372 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
373
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
374 trackListData['tracks'][0].update({
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
375 'codonStarts': table.start_codons,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
376 'codonStops': table.stop_codons,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
377 'codonTable': table.forward_table,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
378 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
379
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
380 with open(trackList, 'w') as handle:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
381 json.dump(trackListData, handle, indent=2)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
382
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
383 def subprocess_check_call(self, command):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
384 log.debug('cd %s && %s', self.outdir, ' '.join(command))
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
385 subprocess.check_call(command, cwd=self.outdir)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
386
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
387 def subprocess_popen(self, command):
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
388 log.debug('cd %s && %s', self.outdir, command)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
389 p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
390 output, err = p.communicate()
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
391 retcode = p.returncode
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
392 if retcode != 0:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
393 log.error('cd %s && %s', self.outdir, command)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
394 log.error(output)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
395 log.error(err)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
396 raise RuntimeError("Command failed with exit code %s" % (retcode))
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
397
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
398 def _jbrowse_bin(self, command):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
399 return os.path.realpath(os.path.join(self.jbrowse, 'bin', command))
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
400
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
401 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
402 for genome_node in self.genome_paths:
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
403 # We only expect one input genome per run. This for loop is just
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
404 # easier to write than the alternative / catches any possible
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
405 # issues.
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
406
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
407 # Copy the file in workdir, prepare-refseqs.pl will copy it to jbrowse's data dir
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
408 local_genome = os.path.realpath('./genome.fasta')
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
409 shutil.copy(genome_node['path'], local_genome)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
410
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
411 cmd = ['samtools', 'faidx', local_genome]
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
412 self.subprocess_check_call(cmd)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
413
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
414 self.subprocess_check_call([
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
415 'perl', self._jbrowse_bin('prepare-refseqs.pl'),
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
416 '--trackConfig', json.dumps({'metadata': genome_node['meta']}),
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
417 '--indexed_fasta', os.path.realpath(local_genome)])
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
418
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
419 os.unlink(local_genome)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
420 os.unlink(local_genome + '.fai')
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
421
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
422 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
423 # Generate names
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
424 args = [
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
425 '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
426 '--hashBits', '16'
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
427 ]
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
428
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
429 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
430 if tracks:
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
431 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
432 else:
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
433 # 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
434 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
435
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
436 self.subprocess_check_call(args)
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
437
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
438 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
439 cmd = [
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
440 '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
441 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
442 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
443 ]
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
444 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
445
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
446 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
447 if len(json_data) == 0:
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
448 return
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
449
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
450 tmp = tempfile.NamedTemporaryFile(delete=False)
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
451 json.dump(json_data, tmp)
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
452 tmp.close()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
453 cmd = ['perl', self._jbrowse_bin('add-track-json.pl'), tmp.name,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
454 os.path.join('data', 'trackList.json')]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
455 self.subprocess_check_call(cmd)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
456 os.unlink(tmp.name)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
457
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
458 def _blastxml_to_gff3(self, xml, min_gap=10):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
459 gff3_unrebased = tempfile.NamedTemporaryFile(delete=False)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
460 cmd = ['python', os.path.join(INSTALLED_TO, 'blastxml_to_gapped_gff3.py'),
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
461 '--trim', '--trim_end', '--include_seq', '--min_gap', str(min_gap), xml]
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
462 log.debug('cd %s && %s > %s', self.outdir, ' '.join(cmd), gff3_unrebased.name)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
463 subprocess.check_call(cmd, cwd=self.outdir, stdout=gff3_unrebased)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
464 gff3_unrebased.close()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
465 return gff3_unrebased.name
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
466
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
467 def add_blastxml(self, data, trackData, blastOpts, **kwargs):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
468 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
469
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
470 if 'parent' in blastOpts and blastOpts['parent'] != 'None':
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
471 gff3_rebased = tempfile.NamedTemporaryFile(delete=False)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
472 cmd = ['python', os.path.join(INSTALLED_TO, 'gff3_rebase.py')]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
473 if blastOpts.get('protein', 'false') == 'true':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
474 cmd.append('--protein2dna')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
475 cmd.extend([os.path.realpath(blastOpts['parent']), gff3])
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
476 log.debug('cd %s && %s > %s', self.outdir, ' '.join(cmd), gff3_rebased.name)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
477 subprocess.check_call(cmd, cwd=self.outdir, stdout=gff3_rebased)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
478 gff3_rebased.close()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
479
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
480 # Replace original gff3 file
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
481 shutil.copy(gff3_rebased.name, gff3)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
482 os.unlink(gff3_rebased.name)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
483
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
484 dest = os.path.join(self.outdir, 'data', 'raw', trackData['label'] + '.gff')
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
485
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
486 self._sort_gff(gff3, dest)
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
487
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
488 url = os.path.join('raw', trackData['label'] + '.gff.gz')
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
489 trackData.update({
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
490 "urlTemplate": url,
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
491 "storeClass": "JBrowse/Store/SeqFeature/GFF3Tabix",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
492 })
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
493
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
494 trackData['glyph'] = 'JBrowse/View/FeatureGlyph/Segments'
13
69c5e9c0add0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents: 12
diff changeset
495
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
496 trackData['trackType'] = 'BlastView/View/Track/CanvasFeatures'
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
497 trackData['type'] = 'BlastView/View/Track/CanvasFeatures'
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
498
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
499 self._add_track_json(trackData)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
500
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
501 os.unlink(gff3)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
502
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
503 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
504 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
505
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
506 def add_bigwig(self, data, trackData, wiggleOpts, **kwargs):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
507 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
508 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
509 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
510
12
db5fe5a3176a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents: 11
diff changeset
511 url = os.path.join('raw', trackData['label'] + '.bw')
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
512 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
513 "urlTemplate": url,
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
514 "storeClass": "JBrowse/Store/SeqFeature/BigWig",
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
515 "type": "JBrowse/View/Track/Wiggle/Density",
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
516 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
517
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
518 trackData['type'] = wiggleOpts['type']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
519 trackData['variance_band'] = True if wiggleOpts['variance_band'] == 'true' else False
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
520
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
521 if 'min' in wiggleOpts and 'max' in wiggleOpts:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
522 trackData['min_score'] = wiggleOpts['min']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
523 trackData['max_score'] = wiggleOpts['max']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
524 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
525 trackData['autoscale'] = wiggleOpts.get('autoscale', 'local')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
526
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
527 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
528
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
529 self._add_track_json(trackData)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
530
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
531 def add_bigwig_multiple(self, data, trackData, wiggleOpts, **kwargs):
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
532
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
533 urls = []
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
534 for idx, bw in enumerate(data):
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
535 dest = os.path.join('data', 'raw', trackData['label'] + '_' + str(idx) + '.bw')
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
536 cmd = ['ln', '-s', bw[1], dest]
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
537 self.subprocess_check_call(cmd)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
538
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
539 urls.append({"url": os.path.join('raw', trackData['label'] + '_' + str(idx) + '.bw'), "name": str(idx + 1) + ' - ' + bw[0]})
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
540
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
541 trackData.update({
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
542 "urlTemplates": urls,
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
543 "showTooltips": "true",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
544 "storeClass": "MultiBigWig/Store/SeqFeature/MultiBigWig",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
545 "type": "MultiBigWig/View/Track/MultiWiggle/MultiDensity",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
546 })
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
547 if 'XYPlot' in wiggleOpts['type']:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
548 trackData['type'] = "MultiBigWig/View/Track/MultiWiggle/MultiXYPlot"
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
549
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
550 trackData['variance_band'] = True if wiggleOpts['variance_band'] == 'true' else False
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
551
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
552 if 'min' in wiggleOpts and 'max' in wiggleOpts:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
553 trackData['min_score'] = wiggleOpts['min']
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
554 trackData['max_score'] = wiggleOpts['max']
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
555 else:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
556 trackData['autoscale'] = wiggleOpts.get('autoscale', 'local')
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
557
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
558 trackData['scale'] = wiggleOpts['scale']
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
559
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
560 self._add_track_json(trackData)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
561
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
562 def add_bam(self, data, trackData, bamOpts, bam_index=None, **kwargs):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
563 dest = os.path.join('data', 'raw', trackData['label'] + '.bam')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
564 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
565 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
566
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
567 cmd = ['ln', '-s', os.path.realpath(bam_index), dest + '.bai']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
568 self.subprocess_check_call(cmd)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
569
12
db5fe5a3176a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents: 11
diff changeset
570 url = os.path.join('raw', trackData['label'] + '.bam')
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
571 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
572 "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
573 "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
574 "storeClass": "JBrowse/Store/SeqFeature/BAM",
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
575 "chunkSizeLimit": bamOpts.get('chunkSizeLimit', '5000000')
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
576 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
577
14
18be2d72fdee planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0bfb0de98c918860c21808e8832caad9f0535975
iuc
parents: 13
diff changeset
578 # 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
579 # 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
580 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
581 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
582
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
583 self._add_track_json(trackData)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
584
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
585 if bamOpts.get('auto_snp', 'false') == 'true':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
586 trackData2 = copy.copy(trackData)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
587 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
588 "type": "JBrowse/View/Track/SNPCoverage",
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
589 "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
590 "label": trackData['label'] + "_autosnp",
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
591 "chunkSizeLimit": bamOpts.get('chunkSizeLimit', '5000000')
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
592 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
593 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
594
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
595 def add_vcf(self, data, trackData, vcfOpts={}, **kwargs):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
596 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
597 # ln?
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
598 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
599 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
600 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
601 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
602 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
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
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
605 url = os.path.join('raw', trackData['label'] + '.vcf.gz')
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
606 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
607 "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
608 "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
609 "storeClass": "JBrowse/Store/SeqFeature/VCFTabix",
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
610 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
611 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
612
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
613 def _sort_gff(self, data, dest):
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
614
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
615 if not os.path.exists(dest):
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
616 # Only index if not already done
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
617 cmd = "grep ^\"#\" '%s' > '%s'" % (data, dest)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
618 self.subprocess_popen(cmd)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
619
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
620 cmd = "grep -v ^\"#\" '%s' | grep -v \"^$\" | grep \"\t\" | sort -k1,1 -k4,4n >> '%s'" % (data, dest)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
621 self.subprocess_popen(cmd)
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
622
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
623 cmd = ['bgzip', '-f', dest]
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
624 self.subprocess_popen(' '.join(cmd))
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
625 cmd = ['tabix', '-f', '-p', 'gff', dest + '.gz']
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
626 self.subprocess_popen(' '.join(cmd))
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
627
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
628 def add_features(self, data, format, trackData, gffOpts, **kwargs):
13
69c5e9c0add0 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit bb4fe9cc4bc03918afa525569ed36144a819ce79
iuc
parents: 12
diff changeset
629
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
630 dest = os.path.join(self.outdir, 'data', 'raw', trackData['label'] + '.gff')
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
631
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
632 self._sort_gff(data, dest)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
633
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
634 url = os.path.join('raw', trackData['label'] + '.gff.gz')
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
635 trackData.update({
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
636 "urlTemplate": url,
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
637 "storeClass": "JBrowse/Store/SeqFeature/GFF3Tabix",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
638 })
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
639
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
640 if 'match' in gffOpts:
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
641 trackData['glyph'] = 'JBrowse/View/FeatureGlyph/Segments'
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
642
10
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
643 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
644 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
645 trackType = gffOpts['trackType']
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
646 trackData['trackType'] = trackType
10
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
647
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
648 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
649 if 'transcriptType' in gffOpts and gffOpts['transcriptType']:
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
650 trackData['transcriptType'] = 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
651 if 'subParts' in gffOpts and gffOpts['subParts']:
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
652 trackData['subParts'] = gffOpts['subParts']
10
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
653 if 'impliedUTRs' in gffOpts and gffOpts['impliedUTRs']:
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
654 trackData['impliedUTRs'] = gffOpts['impliedUTRs']
10
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
655
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
656 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
657
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
658 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
659 self.tracksToIndex.append("%s" % trackData['label'])
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
660
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
661 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
662 data = {
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
663 "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
664 "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
665 "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
666 "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
667 "storeClass": "JBrowse/Store/SeqFeature/REST",
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
668 "baseUrl": url
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
669 }
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
670 self._add_track_json(data)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
671
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
672 def add_sparql(self, url, query, trackData):
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
673 data = {
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
674 "label": trackData['label'],
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
675 "key": trackData['key'],
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
676 "category": trackData['category'],
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
677 "type": "JBrowse/View/Track/CanvasFeatures",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
678 "storeClass": "JBrowse/Store/SeqFeature/SPARQL",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
679 "urlTemplate": url,
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
680 "queryTemplate": query
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
681 }
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
682 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
683
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
684 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
685 category = track['category'].replace('__pd__date__pd__', TODAY)
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
686 outputTrackConfig = {
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
687 'style': {
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
688 '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
689 'className': track['style'].get('className', 'feature'),
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
690 'description': track['style'].get('description', ''),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
691 },
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
692 '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
693 '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
694 '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
695 'category': category,
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
696 }
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
697
16
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
698 mapped_chars = {
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
699 '>': '__gt__',
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
700 '<': '__lt__',
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
701 "'": '__sq__',
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
702 '"': '__dq__',
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
703 '[': '__ob__',
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
704 ']': '__cb__',
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
705 '{': '__oc__',
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
706 '}': '__cc__',
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
707 '@': '__at__',
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
708 '#': '__pd__',
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
709 "": '__cn__'
16
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
710 }
b5c5470d7c09 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit c306d242caf7e0447517c9749ca7656823f315e5
iuc
parents: 14
diff changeset
711
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
712 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
713 # 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
714 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
715 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
716
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
717 log.info('Processing %s / %s', category, track_human_label)
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
718 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
719 # We add extra data to hash for the case of REST + SPARQL.
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
720 if 'conf' in track and 'options' in track['conf'] and 'url' in track['conf']['options']:
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
721 rest_url = track['conf']['options']['url']
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
722 else:
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
723 rest_url = ''
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
724
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
725 # 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
726 # 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
727 # 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
728 # much simpler.
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
729 hashData = [str(dataset_path), track_human_label, track['category'], rest_url]
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
730 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
731 outputTrackConfig['label'] = hashlib.md5(hashData).hexdigest() + '_%s' % i
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
732 outputTrackConfig['metadata'] = extra_metadata
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
733
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
734 # Colour parsing is complex due to different track types having
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
735 # different colour options.
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
736 colourOptions = self.cs.parse_colours(track['conf']['options'], track['format'], gff3=dataset_path)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
737 # This used to be done with a dict.update() call, however that wiped out any previous style settings...
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
738 for key in colourOptions:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
739 if key == 'style':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
740 for subkey in colourOptions['style']:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
741 outputTrackConfig['style'][subkey] = colourOptions['style'][subkey]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
742 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
743 outputTrackConfig[key] = colourOptions[key]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
744
12
db5fe5a3176a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 2bfbb5ae6b801e43355fdc3f964a5111fe3fe3a1
iuc
parents: 11
diff changeset
745 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
746 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
747 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
748
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
749 # 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
750 # import sys; sys.exit()
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
751 if dataset_ext in ('gff', 'gff3', 'bed'):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
752 self.add_features(dataset_path, dataset_ext, outputTrackConfig,
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
753 track['conf']['options']['gff'])
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
754 elif dataset_ext == 'bigwig':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
755 self.add_bigwig(dataset_path, outputTrackConfig,
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
756 track['conf']['options']['wiggle'])
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
757 elif dataset_ext == 'bigwig_multiple':
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
758 self.add_bigwig_multiple(dataset_path, outputTrackConfig,
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
759 track['conf']['options']['wiggle'])
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
760 elif dataset_ext == 'bam':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
761 real_indexes = track['conf']['options']['pileup']['bam_indices']['bam_index']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
762 if not isinstance(real_indexes, list):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
763 # <bam_indices>
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
764 # <bam_index>/path/to/a.bam.bai</bam_index>
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
765 # </bam_indices>
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
766 #
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
767 # The above will result in the 'bam_index' key containing a
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
768 # string. If there are two or more indices, the container
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
769 # becomes a list. Fun!
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
770 real_indexes = [real_indexes]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
771
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
772 self.add_bam(dataset_path, outputTrackConfig,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
773 track['conf']['options']['pileup'],
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
774 bam_index=real_indexes[i])
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
775 elif dataset_ext == 'blastxml':
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
776 self.add_blastxml(dataset_path, outputTrackConfig, track['conf']['options']['blast'])
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
777 elif dataset_ext == 'vcf':
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
778 self.add_vcf(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
779 elif dataset_ext == 'rest':
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
780 self.add_rest(track['conf']['options']['rest']['url'], outputTrackConfig)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
781 elif dataset_ext == 'sparql':
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
782 sparql_query = track['conf']['options']['sparql']['query']
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
783 for key, value in mapped_chars.items():
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
784 sparql_query = sparql_query.replace(value, key)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
785 self.add_sparql(track['conf']['options']['sparql']['url'], sparql_query, outputTrackConfig)
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
786 else:
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
787 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
788
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
789 # 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
790 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
791
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
792 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
793 viz_data = {}
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
794 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
795 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
796
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
797 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
798 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
799
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
800 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
801 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
802
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
803 generalData = {}
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
804 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
805 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
806
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
807 generalData['view'] = {
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
808 '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
809 }
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
810 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
811 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
812 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
813 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
814 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
815 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
816 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
817
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
818 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
819 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
820
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
821 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
822 self._add_track_json({
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
823 "storeClass": "JBrowse/Store/SeqFeature/IndexedFasta",
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
824 "type": "GCContent/View/Track/GCContentXY",
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
825 "label": "GC Content",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
826 "key": "GCContentXY",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
827 "urlTemplate": "seq/genome.fasta",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
828 "bicolor_pivot": 0.5,
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
829 "category": "GC Content",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
830 "metadata": {
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
831 "tool_tool": '<a target="_blank" href="https://github.com/elsiklab/gccontent/commit/030180e75a19fad79478d43a67c566ec6">elsiklab/gccontent</a>',
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
832 "tool_tool_version": "5c8b0582ecebf9edf684c76af8075fb3d30ec3fa",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
833 "dataset_edam_format": "",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
834 "dataset_size": "",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
835 "history_display_name": "",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
836 "history_user_email": "",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
837 "metadata_dbkey": "",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
838 }
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
839 # TODO: Expose params for everyone.
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
840 })
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
841 self._add_track_json({
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
842 "storeClass": "JBrowse/Store/SeqFeature/IndexedFasta",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
843 "type": "GCContent/View/Track/GCContentXY",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
844 "label": "GC skew",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
845 "key": "GCSkew",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
846 "urlTemplate": "seq/genome.fasta",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
847 "gcMode": "skew",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
848 "min_score": -1,
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
849 "bicolor_pivot": 0,
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
850 "category": "GC Content",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
851 "metadata": {
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
852 "tool_tool": '<a target="_blank" href="https://github.com/elsiklab/gccontent/commit/030180e75a19fad79478d43a67c566ec6">elsiklab/gccontent</a>',
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
853 "tool_tool_version": "5c8b0582ecebf9edf684c76af8075fb3d30ec3fa",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
854 "dataset_edam_format": "",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
855 "dataset_size": "",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
856 "history_display_name": "",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
857 "history_user_email": "",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
858 "metadata_dbkey": "",
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
859 }
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
860 # 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
861 })
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
862
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
863 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
864 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
865 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
866 trackListJson.update({
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
867 "trackSelector": {
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
868 "renameFacets": {
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
869 "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
870 "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
871 "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
872 "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
873 "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
874 "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
875 "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
876 "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
877 },
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
878 "displayColumns": [
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
879 "key",
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
880 "tool_tool",
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
881 "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
882 "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
883 "dataset_size",
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
884 "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
885 "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
886 "metadata_dbkey",
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
887 ],
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
888 "type": "Faceted",
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
889 "title": ["Galaxy Metadata"],
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
890 "icon": "https://galaxyproject.org/images/logos/galaxy-icon-square.png",
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
891 "escapeHTMLInData": False
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 "trackMetadata": {
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
894 "indexFacets": [
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
895 "category",
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
896 "key",
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
897 "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
898 "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
899 "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
900 "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
901 "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
902 ]
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
903 }
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
904 })
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
905 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
906 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
907
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
908 def clone_jbrowse(self, jbrowse_dir, destination):
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
909 """Clone a JBrowse directory into a destination directory.
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
910 """
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
911 # 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
912 # unlike copytree
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
913 cmd = ['cp', '-r', os.path.join(jbrowse_dir, '.'), destination]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
914 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
915 subprocess.check_call(cmd)
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
916 cmd = ['mkdir', '-p', os.path.join(destination, 'data', 'raw')]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
917 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
918 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
919
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
920 # 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
921 # 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
922 cmd = ['find', destination, '-type', 'l', '-xtype', 'l']
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
923 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
924 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
925 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
926 try:
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
927 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
928 except OSError:
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
929 pass
0
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
930
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
931
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
932 if __name__ == '__main__':
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
933 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
934 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
935
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
936 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
937 parser.add_argument('--outdir', help='Output directory', default='out')
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
938 parser.add_argument('--standalone', help='Standalone mode includes a copy of JBrowse', action='store_true')
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
939 parser.add_argument('--version', '-V', action='version', version="%(prog)s 0.8.0")
0
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
940 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
941
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
942 tree = ET.parse(args.xml.name)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
943 root = tree.getroot()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
944
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
945 # This should be done ASAP
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
946 GALAXY_INFRASTRUCTURE_URL = root.find('metadata/galaxyUrl').text
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
947 # Sometimes this comes as `localhost` without a protocol
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
948 if not GALAXY_INFRASTRUCTURE_URL.startswith('http'):
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
949 # so we'll prepend `http://` and hope for the best. Requests *should*
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
950 # be GET and not POST so it should redirect OK
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
951 GALAXY_INFRASTRUCTURE_URL = 'http://' + GALAXY_INFRASTRUCTURE_URL
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
952
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
953 jc = JbrowseConnector(
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
954 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
955 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
956 genomes=[
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
957 {
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
958 '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
959 '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
960 }
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
961 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
962 ],
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
963 standalone=args.standalone,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
964 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
965 )
0
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
966
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
967 extra_data = {
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
968 'visibility': {
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
969 'default_on': [],
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
970 'default_off': [],
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
971 'force': [],
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
972 'always': [],
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
973 },
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
974 'general': {
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
975 '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
976 '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
977 '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
978 '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
979 '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
980 '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
981 '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
982 '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
983 '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
984 },
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
985 'plugins': [],
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
986 'plugins_python': [],
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
987 }
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
988
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
989 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
990 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
991 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
992 extra_data['plugins'].append({
24
fa30df9b79c2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 309588eae8df8baffaf49fc00fb0d28106109ddf
iuc
parents: 22
diff changeset
993 'location': 'https://cdn.jsdelivr.net/gh/elsiklab/gccontent@5c8b0582ecebf9edf684c76af8075fb3d30ec3fa/',
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
994 'name': 'GCContent'
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
995 })
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
996
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
997 # Not needed in 1.16.1: it's built in the conda package now, and this plugin doesn't need to be enabled anywhere
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
998 # if plugins['Bookmarks'] == 'True':
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
999 # extra_data['plugins'].append({
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1000 # 'location': 'https://cdn.jsdelivr.net/gh/TAMU-CPT/bookmarks-jbrowse@5242694120274c86e1ccd5cb0e5e943e78f82393/',
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1001 # 'name': 'Bookmarks'
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1002 # })
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1003
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1004 # Not needed in 1.16.1: it's built in the conda package now, and this plugin doesn't need to be enabled anywhere
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1005 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
1006 extra_data['plugins_python'].append('ComboTrackSelector')
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1007 # Not needed in 1.16.1: it's built in the conda package now, and this plugin doesn't need to be enabled anywhere
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1008 # extra_data['plugins'].append({
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1009 # 'location': 'https://cdn.jsdelivr.net/gh/Arabidopsis-Information-Portal/ComboTrackSelector@52403928d5ccbe2e3a86b0fa5eb8e61c0f2e2f57/',
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1010 # 'icon': 'https://galaxyproject.org/images/logos/galaxy-icon-square.png',
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1011 # 'name': 'ComboTrackSelector'
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1012 # })
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1013
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1014 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
1015 extra_data['plugins'].append({
24
fa30df9b79c2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 309588eae8df8baffaf49fc00fb0d28106109ddf
iuc
parents: 22
diff changeset
1016 'location': 'https://cdn.jsdelivr.net/gh/erasche/jbrowse-minimalist-theme@d698718442da306cf87f033c72ddb745f3077775/',
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1017 'name': 'MinimalistTheme'
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1018 })
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1019 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
1020 extra_data['plugins'].append({
24
fa30df9b79c2 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 309588eae8df8baffaf49fc00fb0d28106109ddf
iuc
parents: 22
diff changeset
1021 'location': 'https://cdn.jsdelivr.net/gh/erasche/jbrowse-dark-theme@689eceb7e33bbc1b9b15518d45a5a79b2e5d0a26/',
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1022 'name': 'DarkTheme'
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1023 })
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1024
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1025 if plugins['BlastView'] == 'True':
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1026 extra_data['plugins_python'].append('BlastView')
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1027 extra_data['plugins'].append({
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1028 'location': 'https://cdn.jsdelivr.net/gh/TAMU-CPT/blastview@97572a21b7f011c2b4d9a0b5af40e292d694cbef/',
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1029 'name': 'BlastView'
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1030 })
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1031
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
1032 for track in root.findall('tracks/track'):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
1033 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
1034 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
1035
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1036 is_multi_bigwig = False
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1037 try:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1038 if track.find('options/wiggle/multibigwig') and (track.find('options/wiggle/multibigwig').text == 'True'):
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1039 is_multi_bigwig = True
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1040 multi_bigwig_paths = []
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1041 except KeyError:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1042 pass
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1043
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1044 trackfiles = track.findall('files/trackFile')
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1045 if trackfiles:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1046 for x in track.findall('files/trackFile'):
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1047 if is_multi_bigwig:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1048 multi_bigwig_paths.append((x.attrib['label'], os.path.realpath(x.attrib['path'])))
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1049 else:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1050 if trackfiles:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1051 metadata = metadata_from_node(x.find('metadata'))
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1052
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1053 track_conf['trackfiles'].append((
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1054 os.path.realpath(x.attrib['path']),
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1055 x.attrib['ext'],
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1056 x.attrib['label'],
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1057 metadata
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1058 ))
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1059 else:
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1060 # For tracks without files (rest, sparql)
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1061 track_conf['trackfiles'].append((
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1062 '', # N/A, no path for rest or sparql
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1063 track.attrib['format'],
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1064 track.find('options/label').text,
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1065 {}
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1066 ))
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1067
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1068 if is_multi_bigwig:
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1069 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
1070
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1071 track_conf['trackfiles'].append((
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1072 multi_bigwig_paths, # Passing an array of paths to represent as one track
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1073 'bigwig_multiple',
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1074 'MultiBigWig', # Giving an hardcoded name for now
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1075 {} # No metadata for multiple bigwig
17
ff11d442feed planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 16
diff changeset
1076 ))
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
1077
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
1078 track_conf['category'] = track.attrib['cat']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
1079 track_conf['format'] = track.attrib['format']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
1080 try:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
1081 # Only pertains to gff3 + blastxml. TODO?
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
1082 track_conf['style'] = {t.tag: t.text for t in track.find('options/style')}
25
1cfc579079a6 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit b6f9a87b6091cc881a49e0b6acfadc5e7786967f
iuc
parents: 24
diff changeset
1083 except TypeError:
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
1084 track_conf['style'] = {}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
1085 pass
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
1086 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
1087 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
1088
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
1089 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
1090 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
1091
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
1092 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
1093 jc.generate_names()