annotate jbrowse.py @ 10:1a6d882d340d draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
author iuc
date Fri, 02 Dec 2016 17:58:54 -0500
parents ad4b9d7eae6a
children 4cbceec1d6b4
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
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
3 import copy
0
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
4 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
5 import json
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
6 import logging
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
7 import os
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
8 import shutil
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
9 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
10 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
11 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
12 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
13 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
14
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
15 from Bio.Data import CodonTable
8
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 logging.basicConfig(level=logging.INFO)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
18 log = logging.getLogger('jbrowse')
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
19
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
20
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
21 class ColorScaling(object):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
22
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
23 COLOR_FUNCTION_TEMPLATE = """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
24 function(feature, variableName, glyphObject, track) {{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
25 var score = {score};
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
26 {opacity}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
27 return 'rgba({red}, {green}, {blue}, ' + opacity + ')';
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
28 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
29 """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
30
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
31 COLOR_FUNCTION_TEMPLATE_QUAL = """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
32 function(feature, variableName, glyphObject, track) {{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
33 var search_up = function self(sf, attr){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
34 if(sf.get(attr) !== undefined){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
35 return sf.get(attr);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
36 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
37 if(sf.parent() === undefined) {{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
38 return;
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
39 }}else{{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
40 return self(sf.parent(), attr);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
41 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
42 }};
0
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
43
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
44 var search_down = function self(sf, attr){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
45 if(sf.get(attr) !== undefined){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
46 return sf.get(attr);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
47 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
48 if(sf.children() === undefined) {{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
49 return;
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
50 }}else{{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
51 var kids = sf.children();
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
52 for(var child_idx in kids){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
53 var x = self(kids[child_idx], attr);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
54 if(x !== undefined){{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
55 return x;
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
56 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
57 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
58 return;
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
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
62 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
63 var score = (search_up(feature, 'score') || search_down(feature, 'score'));
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
64 {opacity}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
65 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
66 var red = parseInt(result[1], 16);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
67 var green = parseInt(result[2], 16);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
68 var blue = parseInt(result[3], 16);
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
69 if(isNaN(opacity) || opacity < 0){{ opacity = 0; }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
70 return 'rgba(' + red + ',' + green + ',' + blue + ',' + opacity + ')';
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
71 }}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
72 """
0
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
73
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
74 OPACITY_MATH = {
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
75 'linear': """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
76 var opacity = (score - ({min})) / (({max}) - ({min}));
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
77 """,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
78 'logarithmic': """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
79 var opacity = (score - ({min})) / (({max}) - ({min}));
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
80 opacity = Math.log10(opacity) + Math.log10({max});
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
81 """,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
82 'blast': """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
83 var opacity = 0;
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
84 if(score == 0.0) {
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
85 opacity = 1;
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
86 } else{
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
87 opacity = (20 - Math.log10(score)) / 180;
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
88 }
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
89 """
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
90 }
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
91
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
92 BREWER_COLOUR_IDX = 0
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
93 BREWER_COLOUR_SCHEMES = [
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
94 (166, 206, 227),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
95 (31, 120, 180),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
96 (178, 223, 138),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
97 (51, 160, 44),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
98 (251, 154, 153),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
99 (227, 26, 28),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
100 (253, 191, 111),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
101 (255, 127, 0),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
102 (202, 178, 214),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
103 (106, 61, 154),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
104 (255, 255, 153),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
105 (177, 89, 40),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
106 (228, 26, 28),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
107 (55, 126, 184),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
108 (77, 175, 74),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
109 (152, 78, 163),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
110 (255, 127, 0),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
111 ]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
112
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
113 BREWER_DIVERGING_PALLETES = {
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
114 'BrBg': ("#543005", "#003c30"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
115 'PiYg': ("#8e0152", "#276419"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
116 'PRGn': ("#40004b", "#00441b"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
117 'PuOr': ("#7f3b08", "#2d004b"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
118 'RdBu': ("#67001f", "#053061"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
119 'RdGy': ("#67001f", "#1a1a1a"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
120 'RdYlBu': ("#a50026", "#313695"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
121 'RdYlGn': ("#a50026", "#006837"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
122 'Spectral': ("#9e0142", "#5e4fa2"),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
123 }
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
124
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
125 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
126 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
127
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
128 def rgb_from_hex(self, hexstr):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
129 # http://stackoverflow.com/questions/4296249/how-do-i-convert-a-hex-triplet-to-an-rgb-tuple-and-back
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
130 return struct.unpack('BBB', hexstr.decode('hex'))
1
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 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
133 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
134 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
135 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
136 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
137 try:
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
138 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
139 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
140 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
141
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
142 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
143 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
144
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
145 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
146 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
147 except Exception:
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
148 pass
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
149 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
150
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
151 def hex_from_rgb(self, r, g, b):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
152 return '#%02x%02x%02x' % (r, g, b)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
153
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
154 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
155 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
156 self.brewer_colour_idx += 1
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
157 return r, g, b
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
158
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
159 def parse_menus(self, track):
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
160 trackConfig = {'menuTemplate': [{}, {}, {}]}
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
161
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
162 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
163 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
164 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
165 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
166
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
167 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
168 tpl = {
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
169 '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
170 '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
171 '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
172 }
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
173 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
174 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
175 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
176 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
177 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
178 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
179
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
180 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
181
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
182 return trackConfig
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
183
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
184 def parse_colours(self, track, trackFormat, gff3=None):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
185 # Wiggle tracks have a bicolor pallete
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
186 trackConfig = {'style': {}}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
187 if trackFormat == 'wiggle':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
188
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
189 trackConfig['style']['pos_color'] = track['wiggle']['color_pos']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
190 trackConfig['style']['neg_color'] = track['wiggle']['color_neg']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
191
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
192 if trackConfig['style']['pos_color'] == '__auto__':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
193 trackConfig['style']['neg_color'] = self.hex_from_rgb(*self._get_colours())
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
194 trackConfig['style']['pos_color'] = self.hex_from_rgb(*self._get_colours())
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
195
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
196 # Wiggle tracks can change colour at a specified place
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
197 bc_pivot = track['wiggle']['bicolor_pivot']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
198 if bc_pivot not in ('mean', 'zero'):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
199 # The values are either one of those two strings
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
200 # or a number
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
201 bc_pivot = float(bc_pivot)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
202 trackConfig['bicolor_pivot'] = bc_pivot
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
203 elif 'scaling' in track:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
204 if track['scaling']['method'] == 'ignore':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
205 if track['scaling']['scheme']['color'] != '__auto__':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
206 trackConfig['style']['color'] = track['scaling']['scheme']['color']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
207 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
208 trackConfig['style']['color'] = self.hex_from_rgb(*self._get_colours())
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
209 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
210 # Scored method
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
211 algo = track['scaling']['algo']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
212 # linear, logarithmic, blast
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
213 scales = track['scaling']['scales']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
214 # type __auto__, manual (min, max)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
215 scheme = track['scaling']['scheme']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
216 # scheme -> (type (opacity), color)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
217 # ==================================
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
218 # GENE CALLS OR BLAST
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
219 # ==================================
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
220 if trackFormat == 'blast':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
221 red, green, blue = self._get_colours()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
222 color_function = self.COLOR_FUNCTION_TEMPLATE.format(**{
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
223 'score': "feature._parent.get('score')",
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
224 'opacity': self.OPACITY_MATH['blast'],
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
225 'red': red,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
226 'green': green,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
227 'blue': blue,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
228 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
229 trackConfig['style']['color'] = color_function.replace('\n', '')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
230 elif trackFormat == 'gene_calls':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
231 # Default values, based on GFF3 spec
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
232 min_val = 0
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
233 max_val = 1000
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
234 # 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
235 if scales['type'] == 'automatic' or scales['type'] == '__auto__':
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
236 min_val, max_val = self.min_max_gff(gff3)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
237 else:
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
238 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
239 max_val = scales.get('max', 1000)
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
240
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
241 if scheme['color'] == '__auto__':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
242 user_color = 'undefined'
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
243 auto_color = "'%s'" % self.hex_from_rgb(*self._get_colours())
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
244 elif scheme['color'].startswith('#'):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
245 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
246 auto_color = 'undefined'
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
247 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
248 user_color = 'undefined'
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
249 auto_color = "'%s'" % self.hex_from_rgb(*self._get_colours())
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
250
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
251 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
252 'opacity': self.OPACITY_MATH[algo].format(**{'max': max_val, 'min': min_val}),
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
253 'user_spec_color': user_color,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
254 'auto_gen_color': auto_color,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
255 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
256
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
257 trackConfig['style']['color'] = color_function.replace('\n', '')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
258 return trackConfig
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 def etree_to_dict(t):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
262 d = {t.tag: {} if t.attrib else None}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
263 children = list(t)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
264 if children:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
265 dd = defaultdict(list)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
266 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
267 for k, v in dc.items():
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
268 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
269 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
270 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
271 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
272 if t.text:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
273 text = t.text.strip()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
274 if children or t.attrib:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
275 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
276 d[t.tag]['#text'] = text
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
277 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
278 d[t.tag] = text
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
279 return d
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
280
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
281
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
282 # score comes from feature._parent.get('score') or feature.get('score')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
283
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
284 INSTALLED_TO = os.path.dirname(os.path.realpath(__file__))
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
285
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
286
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
287 class JbrowseConnector(object):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
288
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
289 def __init__(self, jbrowse, outdir, genomes, standalone=False, gencode=1):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
290 self.TN_TABLE = {
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
291 'gff3': '--gff',
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
292 'gff': '--gff',
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
293 'bed': '--bed',
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
294 '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
295 }
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
296
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
297 self.cs = ColorScaling()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
298 self.jbrowse = jbrowse
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
299 self.outdir = outdir
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
300 self.genome_paths = genomes
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
301 self.standalone = standalone
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
302 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
303 self.tracksToIndex = []
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
304
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
305 if standalone:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
306 self.clone_jbrowse(self.jbrowse, self.outdir)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
307 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
308 try:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
309 os.makedirs(self.outdir)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
310 except OSError:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
311 # Ignore if the folder exists
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
312 pass
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
313
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
314 self.process_genomes()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
315 self.update_gencode()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
316
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
317 def update_gencode(self):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
318 table = CodonTable.unambiguous_dna_by_id[int(self.gencode)]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
319 trackList = os.path.join(self.outdir, 'data', 'trackList.json')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
320 with open(trackList, 'r') as handle:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
321 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
322
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
323 trackListData['tracks'][0].update({
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
324 'codonStarts': table.start_codons,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
325 'codonStops': table.stop_codons,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
326 'codonTable': table.forward_table,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
327 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
328
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
329 with open(trackList, 'w') as handle:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
330 json.dump(trackListData, handle, indent=2)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
331
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
332 def subprocess_check_call(self, command):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
333 log.debug('cd %s && %s', self.outdir, ' '.join(command))
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
334 subprocess.check_call(command, cwd=self.outdir)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
335
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
336 def _jbrowse_bin(self, command):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
337 return os.path.realpath(os.path.join(self.jbrowse, 'bin', command))
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
338
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
339 def process_genomes(self):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
340 for genome_path in self.genome_paths:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
341 self.subprocess_check_call([
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
342 'perl', self._jbrowse_bin('prepare-refseqs.pl'),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
343 '--fasta', genome_path])
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
344
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
345 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
346 # Generate names
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
347
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
348 args = [
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
349 '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
350 '--hashBits', '16'
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
351 ]
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
352
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
353 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
354
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
355 if tracks:
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
356 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
357 else:
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
358 # 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
359 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
360
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
361 self.subprocess_check_call(args)
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
362
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
363 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
364
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
365 cmd = [
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
366 '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
367 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
368 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
369 ]
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
370 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
371
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
372 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
373 if len(json_data) == 0:
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
374 return
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
375
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
376 tmp = tempfile.NamedTemporaryFile(delete=False)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
377 tmp.write(json.dumps(json_data))
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
378 tmp.close()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
379 cmd = ['perl', self._jbrowse_bin('add-track-json.pl'), tmp.name,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
380 os.path.join('data', 'trackList.json')]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
381 self.subprocess_check_call(cmd)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
382 os.unlink(tmp.name)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
383
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
384 def _blastxml_to_gff3(self, xml, min_gap=10):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
385 gff3_unrebased = tempfile.NamedTemporaryFile(delete=False)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
386 cmd = ['python', os.path.join(INSTALLED_TO, 'blastxml_to_gapped_gff3.py'),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
387 '--trim', '--trim_end', '--min_gap', str(min_gap), xml]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
388 log.debug('cd %s && %s > %s', self.outdir, ' '.join(cmd), gff3_unrebased.name)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
389 subprocess.check_call(cmd, cwd=self.outdir, stdout=gff3_unrebased)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
390 gff3_unrebased.close()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
391 return gff3_unrebased.name
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
392
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
393 def add_blastxml(self, data, trackData, blastOpts, **kwargs):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
394 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
395
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
396 if 'parent' in blastOpts and blastOpts['parent'] != 'None':
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
397 gff3_rebased = tempfile.NamedTemporaryFile(delete=False)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
398 cmd = ['python', os.path.join(INSTALLED_TO, 'gff3_rebase.py')]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
399 if blastOpts.get('protein', 'false') == 'true':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
400 cmd.append('--protein2dna')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
401 cmd.extend([os.path.realpath(blastOpts['parent']), gff3])
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
402 log.debug('cd %s && %s > %s', self.outdir, ' '.join(cmd), gff3_rebased.name)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
403 subprocess.check_call(cmd, cwd=self.outdir, stdout=gff3_rebased)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
404 gff3_rebased.close()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
405
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
406 # Replace original gff3 file
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
407 shutil.copy(gff3_rebased.name, gff3)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
408 os.unlink(gff3_rebased.name)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
409
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
410 config = {
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
411 'glyph': 'JBrowse/View/FeatureGlyph/Segments',
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
412 "category": trackData['category'],
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
413 }
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
414
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
415 clientConfig = trackData['style']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
416
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
417 cmd = ['perl', self._jbrowse_bin('flatfile-to-json.pl'),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
418 '--gff', gff3,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
419 '--trackLabel', trackData['label'],
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
420 '--key', trackData['key'],
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
421 '--clientConfig', json.dumps(clientConfig),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
422 '--config', json.dumps(config),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
423 '--trackType', 'JBrowse/View/Track/CanvasFeatures'
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
424 ]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
425
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
426 self.subprocess_check_call(cmd)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
427 os.unlink(gff3)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
428
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
429 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
430 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
431
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
432 def add_bigwig(self, data, trackData, wiggleOpts, **kwargs):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
433 dest = os.path.join('data', 'raw', trackData['label'] + '.bw')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
434 cmd = ['ln', 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
435 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
436
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
437 trackData.update({
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
438 "urlTemplate": os.path.join('..', dest),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
439 "storeClass": "JBrowse/Store/SeqFeature/BigWig",
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
440 "type": "JBrowse/View/Track/Wiggle/Density",
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
441 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
442
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
443 trackData['type'] = wiggleOpts['type']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
444 trackData['variance_band'] = True if wiggleOpts['variance_band'] == 'true' else False
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
445
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
446 if 'min' in wiggleOpts and 'max' in wiggleOpts:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
447 trackData['min_score'] = wiggleOpts['min']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
448 trackData['max_score'] = wiggleOpts['max']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
449 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
450 trackData['autoscale'] = wiggleOpts.get('autoscale', 'local')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
451
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
452 self._add_track_json(trackData)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
453
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
454 def add_bam(self, data, trackData, bamOpts, bam_index=None, **kwargs):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
455 dest = os.path.join('data', 'raw', trackData['label'] + '.bam')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
456 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
457 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
458
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
459 cmd = ['ln', '-s', os.path.realpath(bam_index), dest + '.bai']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
460 self.subprocess_check_call(cmd)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
461
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
462 trackData.update({
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
463 "urlTemplate": os.path.join('..', dest),
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
464 "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
465 "storeClass": "JBrowse/Store/SeqFeature/BAM",
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
466 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
467
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
468 self._add_track_json(trackData)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
469
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
470 if bamOpts.get('auto_snp', 'false') == 'true':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
471 trackData2 = copy.copy(trackData)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
472 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
473 "type": "JBrowse/View/Track/SNPCoverage",
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
474 "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
475 "label": trackData['label'] + "_autosnp",
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
476 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
477 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
478
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
479 def add_vcf(self, data, trackData, vcfOpts={}, **kwargs):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
480 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
481 # ln?
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
482 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
483 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
484 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
485 self.subprocess_check_call(cmd)
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
486 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
487 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
488
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
489 trackData.update({
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
490 "urlTemplate": os.path.join('..', dest + '.gz'),
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
491 "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
492 "storeClass": "JBrowse/Store/SeqFeature/VCFTabix",
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
493 })
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
494 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
495
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
496 def add_features(self, data, format, trackData, gffOpts, **kwargs):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
497 cmd = [
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
498 'perl', self._jbrowse_bin('flatfile-to-json.pl'),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
499 self.TN_TABLE.get(format, 'gff'),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
500 data,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
501 '--trackLabel', trackData['label'],
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
502 '--key', trackData['key']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
503 ]
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
504
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
505 config = copy.copy(trackData)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
506 clientConfig = trackData['style']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
507 del config['style']
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
508
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
509 if 'match' in gffOpts:
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
510 config['glyph'] = 'JBrowse/View/FeatureGlyph/Segments'
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
511 cmd += ['--type', gffOpts['match']]
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
512
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
513 cmd += ['--clientConfig', json.dumps(clientConfig),
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
514 ]
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
515
10
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
516 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
517 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
518 trackType = gffOpts['trackType']
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
519
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
520 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
521 if 'transcriptType' in gffOpts and gffOpts['transcriptType']:
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
522 config['transcriptType'] = gffOpts['transcriptType']
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
523 if 'subParts' in gffOpts and gffOpts['subParts']:
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
524 config['subParts'] = gffOpts['subParts']
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
525 if 'impliedUTRs' in gffOpts and gffOpts['impliedUTRs']:
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
526 config['impliedUTRs'] = gffOpts['impliedUTRs']
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
527
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
528 cmd += [
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
529 '--trackType', gffOpts['trackType']
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
530 ]
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
531
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
532 cmd.extend(['--config', json.dumps(config)])
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
533
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
534 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
535
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
536 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
537 self.tracksToIndex.append("%s" % trackData['label'])
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
538
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
539 def process_annotations(self, track):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
540 outputTrackConfig = {
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
541 'style': {
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
542 '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
543 'className': track['style'].get('className', 'feature'),
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
544 'description': track['style'].get('description', ''),
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
545 },
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
546 'category': track['category'],
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
547 }
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
548
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
549 for i, (dataset_path, dataset_ext, track_human_label) in enumerate(track['trackfiles']):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
550 log.info('Processing %s / %s', track['category'], track_human_label)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
551 outputTrackConfig['key'] = track_human_label
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
552 hashData = [dataset_path, track_human_label, track['category']]
10
1a6d882d340d planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
iuc
parents: 8
diff changeset
553 outputTrackConfig['label'] = hashlib.md5('|'.join(hashData).encode('utf-8')).hexdigest() + '_%s' % i
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
554
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
555 # Colour parsing is complex due to different track types having
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
556 # different colour options.
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
557 colourOptions = self.cs.parse_colours(track['conf']['options'], track['format'], gff3=dataset_path)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
558 # 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
559 for key in colourOptions:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
560 if key == 'style':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
561 for subkey in colourOptions['style']:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
562 outputTrackConfig['style'][subkey] = colourOptions['style'][subkey]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
563 else:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
564 outputTrackConfig[key] = colourOptions[key]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
565
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
566 menus = self.cs.parse_menus(track['conf']['options'])
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
567 outputTrackConfig.update(menus)
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
568
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
569 # 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
570 # import sys; sys.exit()
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
571 if dataset_ext in ('gff', 'gff3', 'bed'):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
572 self.add_features(dataset_path, dataset_ext, outputTrackConfig,
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
573 track['conf']['options']['gff'])
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
574 elif dataset_ext == 'bigwig':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
575 self.add_bigwig(dataset_path, outputTrackConfig,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
576 track['conf']['options']['wiggle'])
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
577 elif dataset_ext == 'bam':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
578 real_indexes = track['conf']['options']['pileup']['bam_indices']['bam_index']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
579 if not isinstance(real_indexes, list):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
580 # <bam_indices>
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
581 # <bam_index>/path/to/a.bam.bai</bam_index>
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
582 # </bam_indices>
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
583 #
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
584 # The above will result in the 'bam_index' key containing a
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
585 # string. If there are two or more indices, the container
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
586 # becomes a list. Fun!
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
587 real_indexes = [real_indexes]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
588
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
589 self.add_bam(dataset_path, outputTrackConfig,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
590 track['conf']['options']['pileup'],
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
591 bam_index=real_indexes[i])
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
592 elif dataset_ext == 'blastxml':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
593 self.add_blastxml(dataset_path, outputTrackConfig, track['conf']['options']['blast'])
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
594 elif dataset_ext == 'vcf':
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
595 self.add_vcf(dataset_path, outputTrackConfig)
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
596
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
597 # 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
598 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
599
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
600 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
601 viz_data = {}
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
602 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
603 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
604
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
605 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
606 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
607
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
608 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
609 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
610
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
611 generalData = {}
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
612 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
613 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
614
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
615 generalData['view'] = {
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
616 '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
617 }
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
618 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
619 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
620 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
621 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
622 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
623 generalData['hideGenomeOptions'] = (data['general']['hideGenomeOptions'] == 'true')
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
624
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
625 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
626 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
627
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
628 def clone_jbrowse(self, jbrowse_dir, destination):
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
629 """Clone a JBrowse directory into a destination directory.
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
630 """
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
631 # 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
632 # unlike copytree
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
633 cmd = ['cp', '-r', os.path.join(jbrowse_dir, '.'), destination]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
634 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
635 subprocess.check_call(cmd)
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
636 cmd = ['mkdir', '-p', os.path.join(destination, 'data', 'raw')]
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
637 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
638 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
639
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
640 # 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
641 # JBrowse releases come with some broken symlinks
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
642 cmd = ['find', destination, '-type', 'l', '-xtype', 'l', '-exec', 'rm', "'{}'", '+']
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
643 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
644 subprocess.check_call(cmd)
0
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
645
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
646
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
647 if __name__ == '__main__':
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
648 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
649 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
650
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
651 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
652 parser.add_argument('--outdir', help='Output directory', default='out')
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
653 parser.add_argument('--standalone', help='Standalone mode includes a copy of JBrowse', action='store_true')
0
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
654 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
655
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
656 tree = ET.parse(args.xml.name)
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
657 root = tree.getroot()
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
658
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
659 jc = JbrowseConnector(
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
660 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
661 outdir=args.outdir,
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
662 genomes=[os.path.realpath(x.text) for x in root.findall('metadata/genomes/genome')],
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
663 standalone=args.standalone,
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
664 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
665 )
0
2c9e5136b416 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 685773d3da40afdc4d14846d4935b3b0a100f56e
iuc
parents:
diff changeset
666
5
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
667 extra_data = {
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
668 'visibility': {
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
669 'default_on': [],
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
670 'default_off': [],
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
671 'force': [],
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
672 'always': [],
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
673 },
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
674 'general': {
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
675 '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
676 '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
677 '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
678 '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
679 '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
680 '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
681 '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
682 '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
683 'hideGenomeOptions': root.find('metadata/general/hideGenomeOptions').text,
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
684 }
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
685 }
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
686 for track in root.findall('tracks/track'):
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
687 track_conf = {}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
688 track_conf['trackfiles'] = [
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
689 (os.path.realpath(x.attrib['path']), x.attrib['ext'], x.attrib['label'])
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
690 for x in track.findall('files/trackFile')
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
691 ]
1
497c6bb3b717 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 0887009a23d176b21536c9fd8a18c4fecc417d4f
iuc
parents: 0
diff changeset
692
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
693 track_conf['category'] = track.attrib['cat']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
694 track_conf['format'] = track.attrib['format']
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
695 try:
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
696 # Only pertains to gff3 + blastxml. TODO?
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
697 track_conf['style'] = {t.tag: t.text for t in track.find('options/style')}
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
698 except TypeError:
3
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
699 track_conf['style'] = {}
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
700 pass
7342f467507b Uploaded v0.4 of JBrowse
iuc
parents: 1
diff changeset
701 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
702 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
703
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
704 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
705 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
706
ae9382cfb6ac planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 3bbca939ca8a3298a3a2d6450abb04a96851e1ed
iuc
parents: 3
diff changeset
707 jc.add_final_data(extra_data)
8
ad4b9d7eae6a planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 9a243c616a4a3156347e38fdb5f35863ae5133f9
iuc
parents: 5
diff changeset
708 jc.generate_names()