annotate abjbrowse2.py @ 13:1d86925dbb4c draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
author fubar
date Mon, 22 Jan 2024 11:52:19 +0000
parents
children 7c2e28e144f3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1 #!/usr/bin/env python
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
2 import argparse
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
3 import binascii
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
4 import datetime
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
5 import hashlib
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
6 import json
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
7 import logging
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
8 import os
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
9 import re
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
10 import shutil
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
11 import struct
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
12 import subprocess
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
13 import tempfile
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
14 import xml.etree.ElementTree as ET
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
15 from collections import defaultdict
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
16
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
17 logging.basicConfig(level=logging.INFO)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
18 log = logging.getLogger('jbrowse')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
19 TODAY = datetime.datetime.now().strftime("%Y-%m-%d")
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
20 GALAXY_INFRASTRUCTURE_URL = None
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
21
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
22
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
23 class ColorScaling(object):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
24
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
25 COLOR_FUNCTION_TEMPLATE = """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
26 function(feature, variableName, glyphObject, track) {{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
27 var score = {score};
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
28 {opacity}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
29 return 'rgba({red}, {green}, {blue}, ' + opacity + ')';
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
30 }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
31 """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
32
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
33 COLOR_FUNCTION_TEMPLATE_QUAL = r"""
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
34 function(feature, variableName, glyphObject, track) {{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
35 var search_up = function self(sf, attr){{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
36 if(sf.get(attr) !== undefined){{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
37 return sf.get(attr);
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
38 }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
39 if(sf.parent() === undefined) {{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
40 return;
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
41 }}else{{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
42 return self(sf.parent(), attr);
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
43 }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
44 }};
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
45
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
46 var search_down = function self(sf, attr){{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
47 if(sf.get(attr) !== undefined){{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
48 return sf.get(attr);
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
49 }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
50 if(sf.children() === undefined) {{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
51 return;
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
52 }}else{{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
53 var kids = sf.children();
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
54 for(var child_idx in kids){{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
55 var x = self(kids[child_idx], attr);
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
56 if(x !== undefined){{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
57 return x;
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
58 }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
59 }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
60 return;
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
61 }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
62 }};
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
63
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
64 var color = ({user_spec_color} || search_up(feature, 'color') || search_down(feature, 'color') || {auto_gen_color});
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
65 var score = (search_up(feature, 'score') || search_down(feature, 'score'));
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
66 {opacity}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
67 if(score === undefined){{ opacity = 1; }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
68 var result = /^#?([a-f\d]{{2}})([a-f\d]{{2}})([a-f\d]{{2}})$/i.exec(color);
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
69 var red = parseInt(result[1], 16);
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
70 var green = parseInt(result[2], 16);
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
71 var blue = parseInt(result[3], 16);
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
72 if(isNaN(opacity) || opacity < 0){{ opacity = 0; }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
73 return 'rgba(' + red + ',' + green + ',' + blue + ',' + opacity + ')';
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
74 }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
75 """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
76
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
77 OPACITY_MATH = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
78 'linear': """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
79 var opacity = (score - ({min})) / (({max}) - ({min}));
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
80 """,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
81 'logarithmic': """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
82 var opacity = Math.log10(score - ({min})) / Math.log10(({max}) - ({min}));
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
83 """,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
84 'blast': """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
85 var opacity = 0;
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
86 if(score == 0.0) {{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
87 opacity = 1;
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
88 }} else {{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
89 opacity = (20 - Math.log10(score)) / 180;
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
90 }}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
91 """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
92 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
93
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
94 BREWER_COLOUR_IDX = 0
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
95 BREWER_COLOUR_SCHEMES = [
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
96 (166, 206, 227),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
97 (31, 120, 180),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
98 (178, 223, 138),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
99 (51, 160, 44),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
100 (251, 154, 153),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
101 (227, 26, 28),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
102 (253, 191, 111),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
103 (255, 127, 0),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
104 (202, 178, 214),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
105 (106, 61, 154),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
106 (255, 255, 153),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
107 (177, 89, 40),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
108 (228, 26, 28),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
109 (55, 126, 184),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
110 (77, 175, 74),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
111 (152, 78, 163),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
112 (255, 127, 0),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
113 ]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
114
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
115 BREWER_DIVERGING_PALLETES = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
116 'BrBg': ("#543005", "#003c30"),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
117 'PiYg': ("#8e0152", "#276419"),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
118 'PRGn': ("#40004b", "#00441b"),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
119 'PuOr': ("#7f3b08", "#2d004b"),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
120 'RdBu': ("#67001f", "#053061"),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
121 'RdGy': ("#67001f", "#1a1a1a"),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
122 'RdYlBu': ("#a50026", "#313695"),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
123 'RdYlGn': ("#a50026", "#006837"),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
124 'Spectral': ("#9e0142", "#5e4fa2"),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
125 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
126
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
127 def __init__(self):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
128 self.brewer_colour_idx = 0
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
129
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
130 def rgb_from_hex(self, hexstr):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
131 # http://stackoverflow.com/questions/4296249/how-do-i-convert-a-hex-triplet-to-an-rgb-tuple-and-back
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
132 return struct.unpack('BBB', binascii.unhexlify(hexstr))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
133
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
134 def min_max_gff(self, gff_file):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
135 min_val = None
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
136 max_val = None
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
137 with open(gff_file, 'r') as handle:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
138 for line in handle:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
139 try:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
140 value = float(line.split('\t')[5])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
141 min_val = min(value, (min_val or value))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
142 max_val = max(value, (max_val or value))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
143
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
144 if value < min_val:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
145 min_val = value
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
146
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
147 if value > max_val:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
148 max_val = value
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
149 except Exception:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
150 pass
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
151 return min_val, max_val
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
152
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
153 def hex_from_rgb(self, r, g, b):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
154 return '#%02x%02x%02x' % (r, g, b)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
155
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
156 def _get_colours(self):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
157 r, g, b = self.BREWER_COLOUR_SCHEMES[self.brewer_colour_idx % len(self.BREWER_COLOUR_SCHEMES)]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
158 self.brewer_colour_idx += 1
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
159 return r, g, b
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
160
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
161 def parse_menus(self, track):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
162 trackConfig = {'menuTemplate': [{}, {}, {}, {}]}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
163
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
164 if 'menu' in track['menus']:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
165 menu_list = [track['menus']['menu']]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
166 if isinstance(track['menus']['menu'], list):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
167 menu_list = track['menus']['menu']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
168
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
169 for m in menu_list:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
170 tpl = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
171 'action': m['action'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
172 'label': m.get('label', '{name}'),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
173 'iconClass': m.get('iconClass', 'dijitIconBookmark'),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
174 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
175 if 'url' in m:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
176 tpl['url'] = m['url']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
177 if 'content' in m:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
178 tpl['content'] = m['content']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
179 if 'title' in m:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
180 tpl['title'] = m['title']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
181
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
182 trackConfig['menuTemplate'].append(tpl)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
183
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
184 return trackConfig
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
185
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
186 def parse_colours(self, track, trackFormat, gff3=None):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
187 # Wiggle tracks have a bicolor pallete
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
188 trackConfig = {'style': {}}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
189 if trackFormat == 'wiggle':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
190
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
191 trackConfig['style']['pos_color'] = track['wiggle']['color_pos']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
192 trackConfig['style']['neg_color'] = track['wiggle']['color_neg']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
193
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
194 if trackConfig['style']['pos_color'] == '__auto__':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
195 trackConfig['style']['neg_color'] = self.hex_from_rgb(*self._get_colours())
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
196 trackConfig['style']['pos_color'] = self.hex_from_rgb(*self._get_colours())
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
197
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
198 # Wiggle tracks can change colour at a specified place
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
199 bc_pivot = track['wiggle']['bicolor_pivot']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
200 if bc_pivot not in ('mean', 'zero'):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
201 # The values are either one of those two strings
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
202 # or a number
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
203 bc_pivot = float(bc_pivot)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
204 trackConfig['bicolor_pivot'] = bc_pivot
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
205 elif 'scaling' in track:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
206 if track['scaling']['method'] == 'ignore':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
207 if track['scaling']['scheme']['color'] != '__auto__':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
208 trackConfig['style']['color'] = track['scaling']['scheme']['color']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
209 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
210 trackConfig['style']['color'] = self.hex_from_rgb(*self._get_colours())
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
211 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
212 # Scored method
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
213 algo = track['scaling']['algo']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
214 # linear, logarithmic, blast
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
215 scales = track['scaling']['scales']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
216 # type __auto__, manual (min, max)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
217 scheme = track['scaling']['scheme']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
218 # scheme -> (type (opacity), color)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
219 # ==================================
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
220 # GENE CALLS OR BLAST
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
221 # ==================================
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
222 if trackFormat == 'blast':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
223 red, green, blue = self._get_colours()
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
224 color_function = self.COLOR_FUNCTION_TEMPLATE.format(**{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
225 'score': "feature._parent.get('score')",
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
226 'opacity': self.OPACITY_MATH['blast'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
227 'red': red,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
228 'green': green,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
229 'blue': blue,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
230 })
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
231 trackConfig['style']['color'] = color_function.replace('\n', '')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
232 elif trackFormat == 'gene_calls':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
233 # Default values, based on GFF3 spec
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
234 min_val = 0
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
235 max_val = 1000
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
236 # Get min/max and build a scoring function since JBrowse doesn't
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
237 if scales['type'] == 'automatic' or scales['type'] == '__auto__':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
238 min_val, max_val = self.min_max_gff(gff3)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
239 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
240 min_val = scales.get('min', 0)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
241 max_val = scales.get('max', 1000)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
242
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
243 if scheme['color'] == '__auto__':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
244 user_color = 'undefined'
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
245 auto_color = "'%s'" % self.hex_from_rgb(*self._get_colours())
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
246 elif scheme['color'].startswith('#'):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
247 user_color = "'%s'" % self.hex_from_rgb(*self.rgb_from_hex(scheme['color'][1:]))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
248 auto_color = 'undefined'
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
249 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
250 user_color = 'undefined'
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
251 auto_color = "'%s'" % self.hex_from_rgb(*self._get_colours())
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
252
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
253 color_function = self.COLOR_FUNCTION_TEMPLATE_QUAL.format(**{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
254 'opacity': self.OPACITY_MATH[algo].format(**{'max': max_val, 'min': min_val}),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
255 'user_spec_color': user_color,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
256 'auto_gen_color': auto_color,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
257 })
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
258
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
259 trackConfig['style']['color'] = color_function.replace('\n', '')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
260 return trackConfig
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
261
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
262
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
263 def etree_to_dict(t):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
264 if t is None:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
265 return {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
266
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
267 d = {t.tag: {} if t.attrib else None}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
268 children = list(t)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
269 if children:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
270 dd = defaultdict(list)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
271 for dc in map(etree_to_dict, children):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
272 for k, v in dc.items():
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
273 dd[k].append(v)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
274 d = {t.tag: {k: v[0] if len(v) == 1 else v for k, v in dd.items()}}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
275 if t.attrib:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
276 d[t.tag].update(('@' + k, v) for k, v in t.attrib.items())
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
277 if t.text:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
278 text = t.text.strip()
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
279 if children or t.attrib:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
280 if text:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
281 d[t.tag]['#text'] = text
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
282 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
283 d[t.tag] = text
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
284 return d
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
285
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
286
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
287 # score comes from feature._parent.get('score') or feature.get('score')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
288
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
289 INSTALLED_TO = os.path.dirname(os.path.realpath(__file__))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
290
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
291
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
292 def metadata_from_node(node):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
293 metadata = {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
294 try:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
295 if len(node.findall('dataset')) != 1:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
296 # exit early
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
297 return metadata
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
298 except Exception:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
299 return {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
300
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
301 for (key, value) in node.findall('dataset')[0].attrib.items():
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
302 metadata['dataset_%s' % key] = value
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
303
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
304 for (key, value) in node.findall('history')[0].attrib.items():
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
305 metadata['history_%s' % key] = value
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
306
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
307 for (key, value) in node.findall('metadata')[0].attrib.items():
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
308 metadata['metadata_%s' % key] = value
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
309
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
310 for (key, value) in node.findall('tool')[0].attrib.items():
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
311 metadata['tool_%s' % key] = value
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
312
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
313 # Additional Mappings applied:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
314 metadata['dataset_edam_format'] = '<a target="_blank" href="http://edamontology.org/{0}">{1}</a>'.format(metadata['dataset_edam_format'], metadata['dataset_file_ext'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
315 metadata['history_user_email'] = '<a href="mailto:{0}">{0}</a>'.format(metadata['history_user_email'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
316 metadata['history_display_name'] = '<a target="_blank" href="{galaxy}/history/view/{encoded_hist_id}">{hist_name}</a>'.format(
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
317 galaxy=GALAXY_INFRASTRUCTURE_URL,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
318 encoded_hist_id=metadata['history_id'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
319 hist_name=metadata['history_display_name']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
320 )
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
321 metadata['tool_tool'] = '<a target="_blank" href="{galaxy}/datasets/{encoded_id}/show_params">{tool_id}</a>'.format(
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
322 galaxy=GALAXY_INFRASTRUCTURE_URL,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
323 encoded_id=metadata['dataset_id'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
324 tool_id=metadata['tool_tool_id'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
325 # tool_version=metadata['tool_tool_version'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
326 )
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
327 return metadata
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
328
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
329
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
330 class JbrowseConnector(object):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
331
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
332 def __init__(self, jbrowse, outdir, genomes):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
333 self.cs = ColorScaling()
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
334 self.jbrowse = jbrowse
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
335 self.outdir = outdir
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
336 self.genome_paths = genomes
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
337 self.tracksToIndex = []
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
338
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
339 # This is the id of the current assembly
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
340 self.assembly_ids = {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
341 self.current_assembly_id = []
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
342
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
343 # If upgrading, look at the existing data
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
344 self.check_existing(self.outdir)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
345
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
346 self.clone_jbrowse(self.jbrowse, self.outdir)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
347
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
348 self.process_genomes()
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
349
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
350 def subprocess_check_call(self, command, output=None):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
351 if output:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
352 log.debug('cd %s && %s > %s', self.outdir, ' '.join(command), output)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
353 subprocess.check_call(command, cwd=self.outdir, stdout=output)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
354 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
355 log.debug('cd %s && %s', self.outdir, ' '.join(command))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
356 subprocess.check_call(command, cwd=self.outdir)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
357
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
358 def subprocess_popen(self, command):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
359 log.debug('cd %s && %s', self.outdir, command)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
360 p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
361 output, err = p.communicate()
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
362 retcode = p.returncode
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
363 if retcode != 0:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
364 log.error('cd %s && %s', self.outdir, command)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
365 log.error(output)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
366 log.error(err)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
367 raise RuntimeError("Command failed with exit code %s" % (retcode))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
368
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
369 def subprocess_check_output(self, command):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
370 log.debug('cd %s && %s', self.outdir, ' '.join(command))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
371 return subprocess.check_output(command, cwd=self.outdir)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
372
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
373 def symlink_or_copy(self, src, dest):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
374 if 'GALAXY_JBROWSE_SYMLINKS' in os.environ and bool(os.environ['GALAXY_JBROWSE_SYMLINKS']):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
375 cmd = ['ln', '-s', src, dest]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
376 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
377 cmd = ['cp', src, dest]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
378
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
379 return self.subprocess_check_call(cmd)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
380
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
381 def symlink_or_copy_load_action(self):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
382 if 'GALAXY_JBROWSE_SYMLINKS' in os.environ and bool(os.environ['GALAXY_JBROWSE_SYMLINKS']):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
383 return 'symlink'
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
384 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
385 return 'copy'
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
386
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
387 def check_existing(self, destination):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
388 existing = os.path.join(destination, 'data', "config.json")
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
389 if os.path.exists(existing):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
390 with open(existing, 'r') as existing_conf:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
391 conf = json.load(existing_conf)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
392 if 'assemblies' in conf:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
393 for assembly in conf['assemblies']:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
394 if 'name' in assembly:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
395 self.assembly_ids[assembly['name']] = None
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
396
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
397 def process_genomes(self):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
398 for genome_node in self.genome_paths:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
399 # We only expect one input genome per run. This for loop is just
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
400 # easier to write than the alternative / catches any possible
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
401 # issues.
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
402 self.add_assembly(genome_node['path'], genome_node['label'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
403
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
404 def add_assembly(self, path, label, default=True):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
405 # Find a non-existing filename for the new genome
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
406 # (to avoid colision when upgrading an existing instance)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
407 rel_seq_path = os.path.join('data', 'assembly')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
408 seq_path = os.path.join(self.outdir, rel_seq_path)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
409 fn_try = 1
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
410 while (os.path.exists(seq_path + '.fasta') or os.path.exists(seq_path + '.fasta.gz')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
411 or os.path.exists(seq_path + '.fasta.gz.fai') or os.path.exists(seq_path + '.fasta.gz.gzi')):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
412 rel_seq_path = os.path.join('data', 'assembly%s' % fn_try)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
413 seq_path = os.path.join(self.outdir, rel_seq_path)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
414 fn_try += 1
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
415
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
416 # Find a non-existing label for the new genome
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
417 # (to avoid colision when upgrading an existing instance)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
418 lab_try = 1
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
419 uniq_label = label
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
420 while uniq_label in self.assembly_ids:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
421 uniq_label = label + str(lab_try)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
422 lab_try += 1
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
423
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
424 # Find a default scaffold to display
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
425 # TODO this may not be necessary in the future, see https://github.com/GMOD/jbrowse-components/issues/2708
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
426 with open(path, 'r') as fa_handle:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
427 fa_header = fa_handle.readline()[1:].strip().split(' ')[0]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
428
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
429 self.assembly_ids[uniq_label] = fa_header
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
430 if default:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
431 self.current_assembly_id = uniq_label
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
432
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
433 copied_genome = seq_path + '.fasta'
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
434 shutil.copy(path, copied_genome)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
435
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
436 # Compress with bgzip
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
437 cmd = ['bgzip', copied_genome]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
438 self.subprocess_check_call(cmd)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
439
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
440 # FAI Index
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
441 cmd = ['samtools', 'faidx', copied_genome + '.gz']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
442 self.subprocess_check_call(cmd)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
443
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
444 self.subprocess_check_call([
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
445 'jbrowse', 'add-assembly',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
446 '--load', 'inPlace',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
447 '--name', uniq_label,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
448 '--type', 'bgzipFasta',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
449 '--target', os.path.join(self.outdir, 'data'),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
450 '--skipCheck',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
451 rel_seq_path + '.fasta.gz'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
452
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
453 return uniq_label
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
454
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
455 def text_index(self):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
456 # Index tracks
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
457 args = [
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
458 'jbrowse', 'text-index',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
459 '--target', os.path.join(self.outdir, 'data'),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
460 '--assemblies', self.current_assembly_id,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
461 ]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
462
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
463 tracks = ','.join(self.tracksToIndex)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
464 if tracks:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
465 args += ['--tracks', tracks]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
466
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
467 self.subprocess_check_call(args)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
468
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
469 def _blastxml_to_gff3(self, xml, min_gap=10):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
470 gff3_unrebased = tempfile.NamedTemporaryFile(delete=False)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
471 cmd = ['python', os.path.join(INSTALLED_TO, 'blastxml_to_gapped_gff3.py'),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
472 '--trim', '--trim_end', '--include_seq', '--min_gap', str(min_gap), xml]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
473 log.debug('cd %s && %s > %s', self.outdir, ' '.join(cmd), gff3_unrebased.name)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
474 subprocess.check_call(cmd, cwd=self.outdir, stdout=gff3_unrebased)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
475 gff3_unrebased.close()
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
476 return gff3_unrebased.name
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
477
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
478 def _prepare_track_style(self, xml_conf):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
479
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
480 style_data = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
481 "type": "LinearBasicDisplay"
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
482 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
483
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
484 if 'display' in xml_conf['style']:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
485 style_data['type'] = xml_conf['style']['display']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
486 del xml_conf['style']['display']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
487
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
488 style_data['displayId'] = "%s_%s" % (xml_conf['label'], style_data['type'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
489
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
490 style_data.update(xml_conf['style'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
491
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
492 return {'displays': [style_data]}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
493
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
494 def add_blastxml(self, data, trackData, blastOpts, **kwargs):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
495 gff3 = self._blastxml_to_gff3(data, min_gap=blastOpts['min_gap'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
496
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
497 if 'parent' in blastOpts and blastOpts['parent'] != 'None':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
498 gff3_rebased = tempfile.NamedTemporaryFile(delete=False)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
499 cmd = ['python', os.path.join(INSTALLED_TO, 'gff3_rebase.py')]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
500 if blastOpts.get('protein', 'false') == 'true':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
501 cmd.append('--protein2dna')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
502 cmd.extend([os.path.realpath(blastOpts['parent']), gff3])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
503 log.debug('cd %s && %s > %s', self.outdir, ' '.join(cmd), gff3_rebased.name)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
504 subprocess.check_call(cmd, cwd=self.outdir, stdout=gff3_rebased)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
505 gff3_rebased.close()
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
506
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
507 # Replace original gff3 file
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
508 shutil.copy(gff3_rebased.name, gff3)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
509 os.unlink(gff3_rebased.name)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
510
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
511 rel_dest = os.path.join('data', trackData['label'] + '.gff')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
512 dest = os.path.join(self.outdir, rel_dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
513
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
514 self._sort_gff(gff3, dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
515 os.unlink(gff3)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
516
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
517 style_json = self._prepare_track_style(trackData)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
518
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
519 self._add_track(trackData['label'], trackData['key'], trackData['category'], rel_dest + '.gz', config=style_json)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
520
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
521 def add_bigwig(self, data, trackData, wiggleOpts, **kwargs):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
522
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
523 rel_dest = os.path.join('data', trackData['label'] + '.bw')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
524 dest = os.path.join(self.outdir, rel_dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
525 self.symlink_or_copy(os.path.realpath(data), dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
526
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
527 style_json = self._prepare_track_style(trackData)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
528
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
529 self._add_track(trackData['label'], trackData['key'], trackData['category'], rel_dest, config=style_json)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
530
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
531 # Anything ending in "am" (Bam or Cram)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
532 def add_xam(self, data, trackData, xamOpts, index=None, ext="bam", **kwargs):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
533
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
534 index_ext = "bai"
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
535 if ext == "cram":
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
536 index_ext = "crai"
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
537
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
538 rel_dest = os.path.join('data', trackData['label'] + '.%s' % ext)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
539 dest = os.path.join(self.outdir, rel_dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
540
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
541 self.symlink_or_copy(os.path.realpath(data), dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
542
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
543 if index is not None and os.path.exists(os.path.realpath(index)):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
544 # xai most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
545 self.subprocess_check_call(['cp', os.path.realpath(index), dest + '.%s' % index_ext])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
546 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
547 # Can happen in exotic condition
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
548 # e.g. if bam imported as symlink with datatype=unsorted.bam, then datatype changed to bam
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
549 # => no index generated by galaxy, but there might be one next to the symlink target
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
550 # this trick allows to skip the bam sorting made by galaxy if already done outside
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
551 if os.path.exists(os.path.realpath(data) + '.%s' % index_ext):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
552 self.symlink_or_copy(os.path.realpath(data) + '.%s' % index_ext, dest + '.%s' % index_ext)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
553 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
554 log.warn('Could not find a bam index (.%s file) for %s', (index_ext, data))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
555
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
556 style_json = self._prepare_track_style(trackData)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
557
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
558 self._add_track(trackData['label'], trackData['key'], trackData['category'], rel_dest, config=style_json)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
559
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
560 def add_vcf(self, data, trackData, vcfOpts={}, zipped=False, **kwargs):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
561
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
562 if zipped:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
563 rel_dest = os.path.join('data', trackData['label'] + '.vcf.gz')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
564 dest = os.path.join(self.outdir, rel_dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
565 shutil.copy(os.path.realpath(data), dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
566 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
567 rel_dest = os.path.join('data', trackData['label'] + '.vcf')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
568 dest = os.path.join(self.outdir, rel_dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
569 shutil.copy(os.path.realpath(data), dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
570
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
571 cmd = ['bgzip', dest]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
572 self.subprocess_check_call(cmd)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
573 cmd = ['tabix', dest + '.gz']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
574 self.subprocess_check_call(cmd)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
575
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
576 rel_dest = os.path.join('data', trackData['label'] + '.vcf.gz')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
577
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
578 style_json = self._prepare_track_style(trackData)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
579
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
580 self._add_track(trackData['label'], trackData['key'], trackData['category'], rel_dest, config=style_json)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
581
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
582 def add_gff(self, data, format, trackData, gffOpts, **kwargs):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
583 rel_dest = os.path.join('data', trackData['label'] + '.gff')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
584 dest = os.path.join(self.outdir, rel_dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
585
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
586 self._sort_gff(data, dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
587
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
588 style_json = self._prepare_track_style(trackData)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
589
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
590 self._add_track(trackData['label'], trackData['key'], trackData['category'], rel_dest + '.gz', config=style_json)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
591
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
592 def add_bed(self, data, format, trackData, gffOpts, **kwargs):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
593 rel_dest = os.path.join('data', trackData['label'] + '.bed')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
594 dest = os.path.join(self.outdir, rel_dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
595
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
596 self._sort_bed(data, dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
597
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
598 style_json = self._prepare_track_style(trackData)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
599
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
600 self._add_track(trackData['label'], trackData['key'], trackData['category'], rel_dest + '.gz', config=style_json)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
601
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
602 def add_paf(self, data, trackData, pafOpts, **kwargs):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
603 rel_dest = os.path.join('data', trackData['label'] + '.paf')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
604 dest = os.path.join(self.outdir, rel_dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
605
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
606 self.symlink_or_copy(os.path.realpath(data), dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
607
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
608 added_assembly = self.add_assembly(pafOpts['genome'], pafOpts['genome_label'], default=False)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
609
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
610 style_json = self._prepare_track_style(trackData)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
611
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
612 self._add_track(trackData['label'], trackData['key'], trackData['category'], rel_dest, assemblies=[self.current_assembly_id, added_assembly], config=style_json)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
613
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
614 def add_hic(self, data, trackData, hicOpts, **kwargs):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
615 rel_dest = os.path.join('data', trackData['label'] + '.hic')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
616 dest = os.path.join(self.outdir, rel_dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
617
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
618 self.symlink_or_copy(os.path.realpath(data), dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
619
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
620 style_json = self._prepare_track_style(trackData)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
621
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
622 self._add_track(trackData['label'], trackData['key'], trackData['category'], rel_dest, config=style_json)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
623
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
624 def add_sparql(self, url, query, query_refnames, trackData):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
625
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
626 json_track_data = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
627 "type": "FeatureTrack",
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
628 "trackId": id,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
629 "name": trackData['label'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
630 "adapter": {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
631 "type": "SPARQLAdapter",
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
632 "endpoint": {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
633 "uri": url,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
634 "locationType": "UriLocation"
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
635 },
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
636 "queryTemplate": query
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
637 },
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
638 "category": [
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
639 trackData['category']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
640 ],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
641 "assemblyNames": [
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
642 self.current_assembly_id
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
643 ]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
644 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
645
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
646 if query_refnames:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
647 json_track_data['adapter']['refNamesQueryTemplate']: query_refnames
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
648
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
649 self.subprocess_check_call([
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
650 'jbrowse', 'add-track-json',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
651 '--target', os.path.join(self.outdir, 'data'),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
652 json_track_data])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
653
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
654 # Doesn't work as of 1.6.4, might work in the future
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
655 # self.subprocess_check_call([
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
656 # 'jbrowse', 'add-track',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
657 # '--trackType', 'sparql',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
658 # '--name', trackData['label'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
659 # '--category', trackData['category'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
660 # '--target', os.path.join(self.outdir, 'data'),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
661 # '--trackId', id,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
662 # '--config', '{"queryTemplate": "%s"}' % query,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
663 # url])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
664
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
665 def _add_track(self, id, label, category, path, assemblies=[], config=None):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
666
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
667 assemblies_opt = self.current_assembly_id
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
668 if assemblies:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
669 assemblies_opt = ','.join(assemblies)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
670
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
671 cmd = [
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
672 'jbrowse', 'add-track',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
673 '--load', 'inPlace',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
674 '--name', label,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
675 '--category', category,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
676 '--target', os.path.join(self.outdir, 'data'),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
677 '--trackId', id,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
678 '--assemblyNames', assemblies_opt
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
679 ]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
680
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
681 if config:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
682 cmd.append('--config')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
683 cmd.append(json.dumps(config))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
684
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
685 cmd.append(path)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
686
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
687 self.subprocess_check_call(cmd)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
688
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
689 def _sort_gff(self, data, dest):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
690 # Only index if not already done
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
691 if not os.path.exists(dest):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
692 cmd = "gff3sort.pl --precise '%s' | grep -v \"^$\" > '%s'" % (data, dest)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
693 self.subprocess_popen(cmd)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
694
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
695 self.subprocess_check_call(['bgzip', '-f', dest])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
696 self.subprocess_check_call(['tabix', '-f', '-p', 'gff', dest + '.gz'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
697
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
698 def _sort_bed(self, data, dest):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
699 # Only index if not already done
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
700 if not os.path.exists(dest):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
701 cmd = ['sort', '-k1,1', '-k2,2n', data]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
702 with open(dest, 'w') as handle:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
703 self.subprocess_check_call(cmd, output=handle)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
704
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
705 self.subprocess_check_call(['bgzip', '-f', dest])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
706 self.subprocess_check_call(['tabix', '-f', '-p', 'bed', dest + '.gz'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
707
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
708 def process_annotations(self, track):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
709
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
710 category = track['category'].replace('__pd__date__pd__', TODAY)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
711 outputTrackConfig = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
712 'category': category,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
713 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
714
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
715 mapped_chars = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
716 '>': '__gt__',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
717 '<': '__lt__',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
718 "'": '__sq__',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
719 '"': '__dq__',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
720 '[': '__ob__',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
721 ']': '__cb__',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
722 '{': '__oc__',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
723 '}': '__cc__',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
724 '@': '__at__',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
725 '#': '__pd__',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
726 "": '__cn__'
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
727 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
728
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
729 for i, (dataset_path, dataset_ext, track_human_label, extra_metadata) in enumerate(track['trackfiles']):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
730 # Unsanitize labels (element_identifiers are always sanitized by Galaxy)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
731 for key, value in mapped_chars.items():
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
732 track_human_label = track_human_label.replace(value, key)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
733
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
734 log.info('Processing track %s / %s (%s)', category, track_human_label, dataset_ext)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
735 outputTrackConfig['key'] = track_human_label
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
736 # We add extra data to hash for the case of REST + SPARQL.
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
737 if 'conf' in track and 'options' in track['conf'] and 'url' in track['conf']['options']:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
738 rest_url = track['conf']['options']['url']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
739 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
740 rest_url = ''
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
741
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
742 # I chose to use track['category'] instead of 'category' here. This
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
743 # is intentional. This way re-running the tool on a different date
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
744 # will not generate different hashes and make comparison of outputs
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
745 # much simpler.
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
746 hashData = [str(dataset_path), track_human_label, track['category'], rest_url, self.current_assembly_id]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
747 hashData = '|'.join(hashData).encode('utf-8')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
748 outputTrackConfig['label'] = hashlib.md5(hashData).hexdigest() + '_%s' % i
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
749 outputTrackConfig['metadata'] = extra_metadata
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
750
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
751 outputTrackConfig['style'] = track['style']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
752
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
753 if 'menus' in track['conf']['options']:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
754 menus = self.cs.parse_menus(track['conf']['options'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
755 outputTrackConfig.update(menus)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
756
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
757 if dataset_ext in ('gff', 'gff3'):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
758 self.add_gff(dataset_path, dataset_ext, outputTrackConfig,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
759 track['conf']['options']['gff'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
760 elif dataset_ext == 'bed':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
761 self.add_bed(dataset_path, dataset_ext, outputTrackConfig,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
762 track['conf']['options']['gff'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
763 elif dataset_ext == 'bigwig':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
764 self.add_bigwig(dataset_path, outputTrackConfig,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
765 track['conf']['options']['wiggle'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
766 elif dataset_ext == 'bam':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
767 real_indexes = track['conf']['options']['pileup']['bam_indices']['bam_index']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
768 if not isinstance(real_indexes, list):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
769 # <bam_indices>
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
770 # <bam_index>/path/to/a.bam.bai</bam_index>
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
771 # </bam_indices>
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
772 #
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
773 # The above will result in the 'bam_index' key containing a
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
774 # string. If there are two or more indices, the container
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
775 # becomes a list. Fun!
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
776 real_indexes = [real_indexes]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
777
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
778 self.add_xam(dataset_path, outputTrackConfig,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
779 track['conf']['options']['pileup'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
780 index=real_indexes[i], ext="bam")
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
781 elif dataset_ext == 'cram':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
782 real_indexes = track['conf']['options']['cram']['cram_indices']['cram_index']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
783 if not isinstance(real_indexes, list):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
784 # <bam_indices>
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
785 # <bam_index>/path/to/a.bam.bai</bam_index>
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
786 # </bam_indices>
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
787 #
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
788 # The above will result in the 'bam_index' key containing a
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
789 # string. If there are two or more indices, the container
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
790 # becomes a list. Fun!
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
791 real_indexes = [real_indexes]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
792
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
793 self.add_xam(dataset_path, outputTrackConfig,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
794 track['conf']['options']['cram'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
795 index=real_indexes[i], ext="cram")
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
796 elif dataset_ext == 'blastxml':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
797 self.add_blastxml(dataset_path, outputTrackConfig, track['conf']['options']['blast'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
798 elif dataset_ext == 'vcf':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
799 self.add_vcf(dataset_path, outputTrackConfig)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
800 elif dataset_ext == 'vcf_bgzip':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
801 self.add_vcf(dataset_path, outputTrackConfig, zipped=True)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
802 elif dataset_ext == 'rest':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
803 self.add_rest(track['conf']['options']['rest']['url'], outputTrackConfig)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
804 elif dataset_ext == 'synteny':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
805 self.add_paf(dataset_path, outputTrackConfig,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
806 track['conf']['options']['synteny'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
807 elif dataset_ext == 'hic':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
808 self.add_hic(dataset_path, outputTrackConfig,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
809 track['conf']['options']['hic'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
810 elif dataset_ext == 'sparql':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
811 sparql_query = track['conf']['options']['sparql']['query']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
812 for key, value in mapped_chars.items():
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
813 sparql_query = sparql_query.replace(value, key)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
814 sparql_query_refnames = track['conf']['options']['sparql']['query_refnames']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
815 for key, value in mapped_chars.items():
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
816 sparql_query_refnames = sparql_query_refnames.replace(value, key)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
817 self.add_sparql(track['conf']['options']['sparql']['url'], sparql_query, sparql_query_refnames, outputTrackConfig)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
818 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
819 log.warn('Do not know how to handle %s', dataset_ext)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
820
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
821 # Return non-human label for use in other fields
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
822 yield outputTrackConfig['label']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
823
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
824 def add_default_session(self, data):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
825 """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
826 Add some default session settings: set some assemblies/tracks on/off
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
827 """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
828 tracks_data = []
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
829
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
830 # TODO using the default session for now, but check out session specs in the future https://github.com/GMOD/jbrowse-components/issues/2708
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
831
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
832 # We need to know the track type from the config.json generated just before
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
833 config_path = os.path.join(self.outdir, 'data', 'config.json')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
834 track_types = {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
835 with open(config_path, 'r') as config_file:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
836 config_json = json.load(config_file)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
837
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
838 for track_conf in config_json['tracks']:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
839 track_types[track_conf['trackId']] = track_conf['type']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
840
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
841 for on_track in data['visibility']['default_on']:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
842 # TODO several problems with this currently
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
843 # - we are forced to copy the same kind of style config as the per track config from _prepare_track_style (not exactly the same though)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
844 # - we get an error when refreshing the page
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
845 # - this could be solved by session specs, see https://github.com/GMOD/jbrowse-components/issues/2708
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
846 style_data = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
847 "type": "LinearBasicDisplay",
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
848 "height": 100
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
849 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
850
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
851 if on_track in data['style']:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
852 if 'display' in data['style'][on_track]:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
853 style_data['type'] = data['style'][on_track]['display']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
854 del data['style'][on_track]['display']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
855
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
856 style_data.update(data['style'][on_track])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
857
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
858 if on_track in data['style_labels']:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
859 # TODO fix this: it should probably go in a renderer block (SvgFeatureRenderer) but still does not work
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
860 # TODO move this to per track displays?
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
861 style_data['labels'] = data['style_labels'][on_track]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
862
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
863 tracks_data.append({
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
864 "type": track_types[on_track],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
865 "configuration": on_track,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
866 "displays": [
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
867 style_data
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
868 ]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
869 })
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
870
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
871 # The view for the assembly we're adding
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
872 view_json = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
873 "type": "LinearGenomeView",
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
874 "tracks": tracks_data
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
875 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
876
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
877 refName = None
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
878 if data.get('defaultLocation', ''):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
879 loc_match = re.search(r'^(\w+):(\d+)\.+(\d+)$', data['defaultLocation'])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
880 if loc_match:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
881 refName = loc_match.group(1)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
882 start = int(loc_match.group(2))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
883 end = int(loc_match.group(3))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
884 elif self.assembly_ids[self.current_assembly_id] is not None:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
885 refName = self.assembly_ids[self.current_assembly_id]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
886 start = 0
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
887 end = 1000000 # Booh, hard coded! waiting for https://github.com/GMOD/jbrowse-components/issues/2708
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
888
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
889 if refName is not None:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
890 # TODO displayedRegions is not just zooming to the region, it hides the rest of the chromosome
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
891 view_json['displayedRegions'] = [{
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
892 "refName": refName,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
893 "start": start,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
894 "end": end,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
895 "reversed": False,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
896 "assemblyName": self.current_assembly_id
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
897 }]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
898
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
899 session_name = data.get('session_name', "New session")
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
900 if not session_name:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
901 session_name = "New session"
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
902
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
903 # Merge with possibly existing defaultSession (if upgrading a jbrowse instance)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
904 session_json = {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
905 if 'defaultSession' in config_json:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
906 session_json = config_json['defaultSession']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
907
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
908 session_json["name"] = session_name
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
909
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
910 if 'views' not in session_json:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
911 session_json['views'] = []
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
912
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
913 session_json['views'].append(view_json)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
914
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
915 config_json['defaultSession'] = session_json
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
916
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
917 with open(config_path, 'w') as config_file:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
918 json.dump(config_json, config_file, indent=2)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
919
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
920 def add_general_configuration(self, data):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
921 """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
922 Add some general configuration to the config.json file
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
923 """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
924
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
925 config_path = os.path.join(self.outdir, 'data', 'config.json')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
926 with open(config_path, 'r') as config_file:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
927 config_json = json.load(config_file)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
928
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
929 config_data = {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
930
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
931 config_data['disableAnalytics'] = data.get('analytics', 'false') == 'true'
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
932
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
933 config_data['theme'] = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
934 "palette": {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
935 "primary": {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
936 "main": data.get('primary_color', '#0D233F')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
937 },
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
938 "secondary": {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
939 "main": data.get('secondary_color', '#721E63')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
940 },
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
941 "tertiary": {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
942 "main": data.get('tertiary_color', '#135560')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
943 },
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
944 "quaternary": {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
945 "main": data.get('quaternary_color', '#FFB11D')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
946 },
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
947 },
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
948 "typography": {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
949 "fontSize": int(data.get('font_size', 10))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
950 },
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
951 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
952
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
953 config_json['configuration'].update(config_data)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
954
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
955 with open(config_path, 'w') as config_file:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
956 json.dump(config_json, config_file, indent=2)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
957
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
958 def clone_jbrowse(self, jbrowse_dir, destination):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
959 """Clone a JBrowse directory into a destination directory.
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
960 """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
961
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
962 copytree(jbrowse_dir, destination)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
963
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
964 try:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
965 shutil.rmtree(os.path.join(destination, 'test_data'))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
966 except OSError as e:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
967 log.error("Error: %s - %s." % (e.filename, e.strerror))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
968
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
969 if not os.path.exists(os.path.join(destination, 'data')):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
970 # It can already exist if upgrading an instance
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
971 os.makedirs(os.path.join(destination, 'data'))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
972 log.info("makedir %s" % (os.path.join(destination, 'data')))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
973
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
974 os.symlink('./data/config.json', os.path.join(destination, 'config.json'))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
975
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
976
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
977 def copytree(src, dst, symlinks=False, ignore=None):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
978 for item in os.listdir(src):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
979 s = os.path.join(src, item)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
980 d = os.path.join(dst, item)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
981 if os.path.isdir(s):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
982 shutil.copytree(s, d, symlinks, ignore)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
983 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
984 shutil.copy2(s, d)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
985
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
986
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
987 def parse_style_conf(item):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
988 if 'type' in item.attrib and item.attrib['type'] in ['boolean', 'integer']:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
989 if item.attrib['type'] == 'boolean':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
990 return item.text in ("yes", "true", "True")
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
991 elif item.attrib['type'] == 'integer':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
992 return int(item.text)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
993 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
994 return item.text
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
995
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
996
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
997 if __name__ == '__main__':
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
998 parser = argparse.ArgumentParser(description="", epilog="")
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
999 parser.add_argument('xml', type=argparse.FileType('r'), help='Track Configuration')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1000
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1001 parser.add_argument('--jbrowse', help='Folder containing a jbrowse release')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1002 parser.add_argument('--outdir', help='Output directory', default='out')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1003 parser.add_argument('--version', '-V', action='version', version="%(prog)s 0.8.0")
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1004 args = parser.parse_args()
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1005
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1006 tree = ET.parse(args.xml.name)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1007 root = tree.getroot()
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1008
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1009 # This should be done ASAP
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1010 GALAXY_INFRASTRUCTURE_URL = root.find('metadata/galaxyUrl').text
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1011 # Sometimes this comes as `localhost` without a protocol
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1012 if not GALAXY_INFRASTRUCTURE_URL.startswith('http'):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1013 # so we'll prepend `http://` and hope for the best. Requests *should*
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1014 # be GET and not POST so it should redirect OK
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1015 GALAXY_INFRASTRUCTURE_URL = 'http://' + GALAXY_INFRASTRUCTURE_URL
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1016
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1017 jc = JbrowseConnector(
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1018 jbrowse=args.jbrowse,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1019 outdir=args.outdir,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1020 genomes=[
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1021 {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1022 'path': os.path.realpath(x.attrib['path']),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1023 'meta': metadata_from_node(x.find('metadata')),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1024 'label': x.attrib['label']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1025 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1026 for x in root.findall('metadata/genomes/genome')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1027 ]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1028 )
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1029
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1030 default_session_data = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1031 'visibility': {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1032 'default_on': [],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1033 'default_off': [],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1034 },
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1035 'style': {},
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1036 'style_labels': {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1037 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1038
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1039 # TODO add metadata to tracks
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1040 for track in root.findall('tracks/track'):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1041 track_conf = {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1042 track_conf['trackfiles'] = []
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1043
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1044 trackfiles = track.findall('files/trackFile')
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1045 if trackfiles:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1046 for x in track.findall('files/trackFile'):
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1047 if trackfiles:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1048 metadata = metadata_from_node(x.find('metadata'))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1049
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1050 track_conf['trackfiles'].append((
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1051 os.path.realpath(x.attrib['path']),
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1052 x.attrib['ext'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1053 x.attrib['label'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1054 metadata
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1055 ))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1056 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1057 # For tracks without files (rest, sparql)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1058 track_conf['trackfiles'].append((
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1059 '', # N/A, no path for rest or sparql
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1060 track.attrib['format'],
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1061 track.find('options/label').text,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1062 {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1063 ))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1064
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1065 track_conf['category'] = track.attrib['cat']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1066 track_conf['format'] = track.attrib['format']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1067 track_conf['style'] = {item.tag: parse_style_conf(item) for item in track.find('options/style')}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1068
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1069 track_conf['style'] = {item.tag: parse_style_conf(item) for item in track.find('options/style')}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1070
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1071 track_conf['style_labels'] = {item.tag: parse_style_conf(item) for item in track.find('options/style_labels')}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1072
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1073 track_conf['conf'] = etree_to_dict(track.find('options'))
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1074 keys = jc.process_annotations(track_conf)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1075
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1076 for key in keys:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1077 default_session_data['visibility'][track.attrib.get('visibility', 'default_off')].append(key)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1078
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1079 default_session_data['style'][key] = track_conf['style'] # TODO do we need this anymore?
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1080 default_session_data['style_labels'][key] = track_conf['style_labels']
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1081
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1082 default_session_data['defaultLocation'] = root.find('metadata/general/defaultLocation').text
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1083 default_session_data['session_name'] = root.find('metadata/general/session_name').text
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1084
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1085 general_data = {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1086 'analytics': root.find('metadata/general/analytics').text,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1087 'primary_color': root.find('metadata/general/primary_color').text,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1088 'secondary_color': root.find('metadata/general/secondary_color').text,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1089 'tertiary_color': root.find('metadata/general/tertiary_color').text,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1090 'quaternary_color': root.find('metadata/general/quaternary_color').text,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1091 'font_size': root.find('metadata/general/font_size').text,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1092 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1093
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1094 jc.add_default_session(default_session_data)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1095 jc.add_general_configuration(general_data)
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1096 jc.text_index()
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1097