annotate abjbrowse2.py @ 14:7c2e28e144f3 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
author fubar
date Mon, 22 Jan 2024 12:05:09 +0000
parents 1d86925dbb4c
children
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)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
18 log = logging.getLogger("jbrowse")
13
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 = {
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
78 "linear": """
13
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 """,
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
81 "logarithmic": """
13
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 """,
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
84 "blast": """
13
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 }}
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
91 """,
13
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 = {
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
116 "BrBg": ("#543005", "#003c30"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
117 "PiYg": ("#8e0152", "#276419"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
118 "PRGn": ("#40004b", "#00441b"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
119 "PuOr": ("#7f3b08", "#2d004b"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
120 "RdBu": ("#67001f", "#053061"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
121 "RdGy": ("#67001f", "#1a1a1a"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
122 "RdYlBu": ("#a50026", "#313695"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
123 "RdYlGn": ("#a50026", "#006837"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
124 "Spectral": ("#9e0142", "#5e4fa2"),
13
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
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
132 return struct.unpack("BBB", binascii.unhexlify(hexstr))
13
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
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
137 with open(gff_file, "r") as handle:
13
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:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
140 value = float(line.split("\t")[5])
13
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):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
154 return "#%02x%02x%02x" % (r, g, b)
13
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):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
157 r, g, b = self.BREWER_COLOUR_SCHEMES[
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
158 self.brewer_colour_idx % len(self.BREWER_COLOUR_SCHEMES)
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
159 ]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
160 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
161 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
162
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
163 def parse_menus(self, track):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
164 trackConfig = {"menuTemplate": [{}, {}, {}, {}]}
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
165
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
166 if "menu" in track["menus"]:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
167 menu_list = [track["menus"]["menu"]]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
168 if isinstance(track["menus"]["menu"], list):
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
169 menu_list = track["menus"]["menu"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
170
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
171 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
172 tpl = {
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
173 "action": m["action"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
174 "label": m.get("label", "{name}"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
175 "iconClass": m.get("iconClass", "dijitIconBookmark"),
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
176 }
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
177 if "url" in m:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
178 tpl["url"] = m["url"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
179 if "content" in m:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
180 tpl["content"] = m["content"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
181 if "title" in m:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
182 tpl["title"] = m["title"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
183
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
184 trackConfig["menuTemplate"].append(tpl)
13
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 return trackConfig
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
187
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
188 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
189 # Wiggle tracks have a bicolor pallete
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
190 trackConfig = {"style": {}}
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
191 if trackFormat == "wiggle":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
192
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
193 trackConfig["style"]["pos_color"] = track["wiggle"]["color_pos"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
194 trackConfig["style"]["neg_color"] = track["wiggle"]["color_neg"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
195
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
196 if trackConfig["style"]["pos_color"] == "__auto__":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
197 trackConfig["style"]["neg_color"] = self.hex_from_rgb(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
198 *self._get_colours()
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
199 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
200 trackConfig["style"]["pos_color"] = self.hex_from_rgb(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
201 *self._get_colours()
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
202 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
203
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
204 # Wiggle tracks can change colour at a specified place
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
205 bc_pivot = track["wiggle"]["bicolor_pivot"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
206 if bc_pivot not in ("mean", "zero"):
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
207 # 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
208 # 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
209 bc_pivot = float(bc_pivot)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
210 trackConfig["bicolor_pivot"] = bc_pivot
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
211 elif "scaling" in track:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
212 if track["scaling"]["method"] == "ignore":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
213 if track["scaling"]["scheme"]["color"] != "__auto__":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
214 trackConfig["style"]["color"] = track["scaling"]["scheme"]["color"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
215 else:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
216 trackConfig["style"]["color"] = self.hex_from_rgb(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
217 *self._get_colours()
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
218 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
219 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
220 # Scored method
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
221 algo = track["scaling"]["algo"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
222 # linear, logarithmic, blast
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
223 scales = track["scaling"]["scales"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
224 # type __auto__, manual (min, max)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
225 scheme = track["scaling"]["scheme"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
226 # 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
227 # ==================================
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
228 # 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
229 # ==================================
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
230 if trackFormat == "blast":
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
231 red, green, blue = self._get_colours()
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
232 color_function = self.COLOR_FUNCTION_TEMPLATE.format(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
233 **{
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
234 "score": "feature._parent.get('score')",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
235 "opacity": self.OPACITY_MATH["blast"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
236 "red": red,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
237 "green": green,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
238 "blue": blue,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
239 }
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
240 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
241 trackConfig["style"]["color"] = color_function.replace("\n", "")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
242 elif trackFormat == "gene_calls":
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
243 # 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
244 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
245 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
246 # Get min/max and build a scoring function since JBrowse doesn't
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
247 if scales["type"] == "automatic" or scales["type"] == "__auto__":
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
248 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
249 else:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
250 min_val = scales.get("min", 0)
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
251 max_val = scales.get("max", 1000)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
252
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
253 if scheme["color"] == "__auto__":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
254 user_color = "undefined"
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
255 auto_color = "'%s'" % self.hex_from_rgb(*self._get_colours())
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
256 elif scheme["color"].startswith("#"):
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
257 user_color = "'%s'" % self.hex_from_rgb(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
258 *self.rgb_from_hex(scheme["color"][1:])
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
259 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
260 auto_color = "undefined"
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
261 else:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
262 user_color = "undefined"
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
263 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
264
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
265 color_function = self.COLOR_FUNCTION_TEMPLATE_QUAL.format(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
266 **{
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
267 "opacity": self.OPACITY_MATH[algo].format(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
268 **{"max": max_val, "min": min_val}
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
269 ),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
270 "user_spec_color": user_color,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
271 "auto_gen_color": auto_color,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
272 }
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
273 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
274
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
275 trackConfig["style"]["color"] = color_function.replace("\n", "")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
276 return trackConfig
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
277
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
278
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
279 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
280 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
281 return {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
282
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: {} 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
284 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
285 if children:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
286 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
287 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
288 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
289 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
290 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
291 if t.attrib:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
292 d[t.tag].update(("@" + k, v) for k, v in t.attrib.items())
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
293 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
294 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
295 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
296 if text:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
297 d[t.tag]["#text"] = text
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
298 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
299 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
300 return d
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
301
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
302
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
303 # 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
304
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
305 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
306
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
307
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
308 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
309 metadata = {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
310 try:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
311 if len(node.findall("dataset")) != 1:
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
312 # exit early
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
313 return metadata
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
314 except Exception:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
315 return {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
316
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
317 for (key, value) in node.findall("dataset")[0].attrib.items():
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
318 metadata["dataset_%s" % key] = value
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
319
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
320 for (key, value) in node.findall("history")[0].attrib.items():
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
321 metadata["history_%s" % key] = value
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
322
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
323 for (key, value) in node.findall("metadata")[0].attrib.items():
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
324 metadata["metadata_%s" % key] = value
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
325
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
326 for (key, value) in node.findall("tool")[0].attrib.items():
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
327 metadata["tool_%s" % key] = value
13
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 # Additional Mappings applied:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
330 metadata[
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
331 "dataset_edam_format"
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
332 ] = '<a target="_blank" href="http://edamontology.org/{0}">{1}</a>'.format(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
333 metadata["dataset_edam_format"], metadata["dataset_file_ext"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
334 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
335 metadata["history_user_email"] = '<a href="mailto:{0}">{0}</a>'.format(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
336 metadata["history_user_email"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
337 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
338 metadata[
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
339 "history_display_name"
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
340 ] = '<a target="_blank" href="{galaxy}/history/view/{encoded_hist_id}">{hist_name}</a>'.format(
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
341 galaxy=GALAXY_INFRASTRUCTURE_URL,
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
342 encoded_hist_id=metadata["history_id"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
343 hist_name=metadata["history_display_name"],
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
344 )
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
345 metadata[
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
346 "tool_tool"
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
347 ] = '<a target="_blank" href="{galaxy}/datasets/{encoded_id}/show_params">{tool_id}</a>'.format(
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
348 galaxy=GALAXY_INFRASTRUCTURE_URL,
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
349 encoded_id=metadata["dataset_id"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
350 tool_id=metadata["tool_tool_id"],
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
351 # 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
352 )
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
353 return metadata
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
354
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
355
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
356 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
357 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
358 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
359 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
360 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
361 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
362 self.tracksToIndex = []
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
363
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
364 # 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
365 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
366 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
367
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
368 # 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
369 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
370
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
371 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
372
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
373 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
374
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
375 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
376 if output:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
377 log.debug("cd %s && %s > %s", self.outdir, " ".join(command), output)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
378 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
379 else:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
380 log.debug("cd %s && %s", self.outdir, " ".join(command))
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
381 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
382
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
383 def subprocess_popen(self, command):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
384 log.debug("cd %s && %s", self.outdir, command)
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
385 p = subprocess.Popen(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
386 command,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
387 shell=True,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
388 stdin=subprocess.PIPE,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
389 stdout=subprocess.PIPE,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
390 stderr=subprocess.PIPE,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
391 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
392 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
393 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
394 if retcode != 0:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
395 log.error("cd %s && %s", self.outdir, command)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
396 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
397 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
398 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
399
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
400 def subprocess_check_output(self, command):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
401 log.debug("cd %s && %s", self.outdir, " ".join(command))
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
402 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
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 symlink_or_copy(self, src, dest):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
405 if "GALAXY_JBROWSE_SYMLINKS" in os.environ and bool(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
406 os.environ["GALAXY_JBROWSE_SYMLINKS"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
407 ):
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
408 cmd = ["ln", "-s", src, dest]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
409 else:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
410 cmd = ["cp", src, dest]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
411
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
412 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
413
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
414 def symlink_or_copy_load_action(self):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
415 if "GALAXY_JBROWSE_SYMLINKS" in os.environ and bool(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
416 os.environ["GALAXY_JBROWSE_SYMLINKS"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
417 ):
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
418 return "symlink"
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
419 else:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
420 return "copy"
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
421
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
422 def check_existing(self, destination):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
423 existing = os.path.join(destination, "data", "config.json")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
424 if os.path.exists(existing):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
425 with open(existing, "r") as existing_conf:
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
426 conf = json.load(existing_conf)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
427 if "assemblies" in conf:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
428 for assembly in conf["assemblies"]:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
429 if "name" in assembly:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
430 self.assembly_ids[assembly["name"]] = None
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
431
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
432 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
433 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
434 # 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
435 # 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
436 # issues.
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
437 self.add_assembly(genome_node["path"], genome_node["label"])
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
438
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
439 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
440 # 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
441 # (to avoid colision when upgrading an existing instance)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
442 rel_seq_path = os.path.join("data", "assembly")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
443 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
444 fn_try = 1
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
445 while (
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
446 os.path.exists(seq_path + ".fasta")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
447 or os.path.exists(seq_path + ".fasta.gz")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
448 or os.path.exists(seq_path + ".fasta.gz.fai")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
449 or os.path.exists(seq_path + ".fasta.gz.gzi")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
450 ):
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
451 rel_seq_path = os.path.join("data", "assembly%s" % fn_try)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
452 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
453 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
454
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
455 # 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
456 # (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
457 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
458 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
459 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
460 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
461 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
462
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
463 # 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
464 # TODO this may not be necessary in the future, see https://github.com/GMOD/jbrowse-components/issues/2708
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
465 with open(path, "r") as fa_handle:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
466 fa_header = fa_handle.readline()[1:].strip().split(" ")[0]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
467
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
468 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
469 if default:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
470 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
471
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
472 copied_genome = seq_path + ".fasta"
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
473 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
474
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
475 # Compress with bgzip
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
476 cmd = ["bgzip", copied_genome]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
477 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
478
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
479 # FAI Index
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
480 cmd = ["samtools", "faidx", copied_genome + ".gz"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
481 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
482
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
483 self.subprocess_check_call(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
484 [
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
485 "jbrowse",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
486 "add-assembly",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
487 "--load",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
488 "inPlace",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
489 "--name",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
490 uniq_label,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
491 "--type",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
492 "bgzipFasta",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
493 "--target",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
494 os.path.join(self.outdir, "data"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
495 "--skipCheck",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
496 rel_seq_path + ".fasta.gz",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
497 ]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
498 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
499
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
500 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
501
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
502 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
503 # Index tracks
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
504 args = [
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
505 "jbrowse",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
506 "text-index",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
507 "--target",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
508 os.path.join(self.outdir, "data"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
509 "--assemblies",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
510 self.current_assembly_id,
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
511 ]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
512
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
513 tracks = ",".join(self.tracksToIndex)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
514 if tracks:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
515 args += ["--tracks", tracks]
13
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 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
518
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
519 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
520 gff3_unrebased = tempfile.NamedTemporaryFile(delete=False)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
521 cmd = [
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
522 "python",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
523 os.path.join(INSTALLED_TO, "blastxml_to_gapped_gff3.py"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
524 "--trim",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
525 "--trim_end",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
526 "--include_seq",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
527 "--min_gap",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
528 str(min_gap),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
529 xml,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
530 ]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
531 log.debug("cd %s && %s > %s", self.outdir, " ".join(cmd), gff3_unrebased.name)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
532 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
533 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
534 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
535
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
536 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
537
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
538 style_data = {"type": "LinearBasicDisplay"}
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
539
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
540 if "display" in xml_conf["style"]:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
541 style_data["type"] = xml_conf["style"]["display"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
542 del xml_conf["style"]["display"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
543
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
544 style_data["displayId"] = "%s_%s" % (xml_conf["label"], style_data["type"])
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
545
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
546 style_data.update(xml_conf["style"])
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
547
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
548 return {"displays": [style_data]}
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
549
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
550 def add_blastxml(self, data, trackData, blastOpts, **kwargs):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
551 gff3 = self._blastxml_to_gff3(data, min_gap=blastOpts["min_gap"])
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
552
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
553 if "parent" in blastOpts and blastOpts["parent"] != "None":
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
554 gff3_rebased = tempfile.NamedTemporaryFile(delete=False)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
555 cmd = ["python", os.path.join(INSTALLED_TO, "gff3_rebase.py")]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
556 if blastOpts.get("protein", "false") == "true":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
557 cmd.append("--protein2dna")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
558 cmd.extend([os.path.realpath(blastOpts["parent"]), gff3])
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
559 log.debug("cd %s && %s > %s", self.outdir, " ".join(cmd), gff3_rebased.name)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
560 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
561 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
562
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
563 # 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
564 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
565 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
566
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
567 rel_dest = os.path.join("data", trackData["label"] + ".gff")
13
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
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
570 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
571 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
572
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
573 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
574
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
575 self._add_track(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
576 trackData["label"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
577 trackData["key"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
578 trackData["category"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
579 rel_dest + ".gz",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
580 config=style_json,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
581 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
582
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
583 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
584
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
585 rel_dest = os.path.join("data", trackData["label"] + ".bw")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
586 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
587 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
588
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
589 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
590
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
591 self._add_track(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
592 trackData["label"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
593 trackData["key"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
594 trackData["category"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
595 rel_dest,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
596 config=style_json,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
597 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
598
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
599 # 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
600 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
601
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
602 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
603 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
604 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
605
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
606 rel_dest = os.path.join("data", trackData["label"] + ".%s" % ext)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
607 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
608
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
609 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
610
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
611 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
612 # xai most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
613 self.subprocess_check_call(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
614 ["cp", os.path.realpath(index), dest + ".%s" % index_ext]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
615 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
616 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
617 # 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
618 # 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
619 # => 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
620 # this trick allows to skip the bam sorting made by galaxy if already done outside
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
621 if os.path.exists(os.path.realpath(data) + ".%s" % index_ext):
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
622 self.symlink_or_copy(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
623 os.path.realpath(data) + ".%s" % index_ext, dest + ".%s" % index_ext
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
624 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
625 else:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
626 log.warn(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
627 "Could not find a bam index (.%s file) for %s", (index_ext, data)
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
628 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
629
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
630 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
631
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
632 self._add_track(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
633 trackData["label"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
634 trackData["key"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
635 trackData["category"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
636 rel_dest,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
637 config=style_json,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
638 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
639
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
640 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
641
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
642 if zipped:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
643 rel_dest = os.path.join("data", trackData["label"] + ".vcf.gz")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
644 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
645 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
646 else:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
647 rel_dest = os.path.join("data", trackData["label"] + ".vcf")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
648 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
649 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
650
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
651 cmd = ["bgzip", dest]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
652 self.subprocess_check_call(cmd)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
653 cmd = ["tabix", dest + ".gz"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
654 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
655
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
656 rel_dest = os.path.join("data", trackData["label"] + ".vcf.gz")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
657
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
658 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
659
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
660 self._add_track(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
661 trackData["label"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
662 trackData["key"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
663 trackData["category"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
664 rel_dest,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
665 config=style_json,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
666 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
667
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
668 def add_gff(self, data, format, trackData, gffOpts, **kwargs):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
669 rel_dest = os.path.join("data", trackData["label"] + ".gff")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
670 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
671
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
672 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
673
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
674 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
675
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
676 self._add_track(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
677 trackData["label"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
678 trackData["key"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
679 trackData["category"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
680 rel_dest + ".gz",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
681 config=style_json,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
682 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
683
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
684 def add_bed(self, data, format, trackData, gffOpts, **kwargs):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
685 rel_dest = os.path.join("data", trackData["label"] + ".bed")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
686 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
687
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
688 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
689
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
690 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
691
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
692 self._add_track(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
693 trackData["label"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
694 trackData["key"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
695 trackData["category"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
696 rel_dest + ".gz",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
697 config=style_json,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
698 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
699
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
700 def add_paf(self, data, trackData, pafOpts, **kwargs):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
701 rel_dest = os.path.join("data", trackData["label"] + ".paf")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
702 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
703
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
704 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
705
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
706 added_assembly = self.add_assembly(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
707 pafOpts["genome"], pafOpts["genome_label"], default=False
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
708 )
13
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 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
711
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
712 self._add_track(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
713 trackData["label"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
714 trackData["key"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
715 trackData["category"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
716 rel_dest,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
717 assemblies=[self.current_assembly_id, added_assembly],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
718 config=style_json,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
719 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
720
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
721 def add_hic(self, data, trackData, hicOpts, **kwargs):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
722 rel_dest = os.path.join("data", trackData["label"] + ".hic")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
723 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
724
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
725 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
726
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
727 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
728
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
729 self._add_track(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
730 trackData["label"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
731 trackData["key"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
732 trackData["category"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
733 rel_dest,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
734 config=style_json,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
735 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
736
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
737 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
738
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
739 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
740 "type": "FeatureTrack",
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
741 "trackId": id,
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
742 "name": trackData["label"],
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
743 "adapter": {
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
744 "type": "SPARQLAdapter",
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
745 "endpoint": {"uri": url, "locationType": "UriLocation"},
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
746 "queryTemplate": query,
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
747 },
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
748 "category": [trackData["category"]],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
749 "assemblyNames": [self.current_assembly_id],
13
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
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
752 if query_refnames:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
753 json_track_data["adapter"]["refNamesQueryTemplate"]: query_refnames
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
754
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
755 self.subprocess_check_call(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
756 [
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
757 "jbrowse",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
758 "add-track-json",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
759 "--target",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
760 os.path.join(self.outdir, "data"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
761 json_track_data,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
762 ]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
763 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
764
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
765 # 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
766 # 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
767 # '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
768 # '--trackType', 'sparql',
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
769 # '--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
770 # '--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
771 # '--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
772 # '--trackId', id,
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
773 # '--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
774 # url])
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
775
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
776 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
777
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
778 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
779 if assemblies:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
780 assemblies_opt = ",".join(assemblies)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
781
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
782 cmd = [
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
783 "jbrowse",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
784 "add-track",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
785 "--load",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
786 "inPlace",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
787 "--name",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
788 label,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
789 "--category",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
790 category,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
791 "--target",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
792 os.path.join(self.outdir, "data"),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
793 "--trackId",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
794 id,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
795 "--assemblyNames",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
796 assemblies_opt,
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
797 ]
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
798
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
799 if config:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
800 cmd.append("--config")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
801 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
802
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
803 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
804
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
805 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
806
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
807 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
808 # 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
809 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
810 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
811 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
812
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
813 self.subprocess_check_call(["bgzip", "-f", dest])
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
814 self.subprocess_check_call(["tabix", "-f", "-p", "gff", dest + ".gz"])
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
815
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
816 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
817 # 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
818 if not os.path.exists(dest):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
819 cmd = ["sort", "-k1,1", "-k2,2n", data]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
820 with open(dest, "w") as handle:
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
821 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
822
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
823 self.subprocess_check_call(["bgzip", "-f", dest])
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
824 self.subprocess_check_call(["tabix", "-f", "-p", "bed", dest + ".gz"])
13
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 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
827
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
828 category = track["category"].replace("__pd__date__pd__", TODAY)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
829 outputTrackConfig = {
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
830 "category": category,
13
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
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
833 mapped_chars = {
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
834 ">": "__gt__",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
835 "<": "__lt__",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
836 "'": "__sq__",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
837 '"': "__dq__",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
838 "[": "__ob__",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
839 "]": "__cb__",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
840 "{": "__oc__",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
841 "}": "__cc__",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
842 "@": "__at__",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
843 "#": "__pd__",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
844 "": "__cn__",
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
845 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
846
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
847 for i, (
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
848 dataset_path,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
849 dataset_ext,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
850 track_human_label,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
851 extra_metadata,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
852 ) in enumerate(track["trackfiles"]):
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
853 # 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
854 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
855 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
856
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
857 log.info(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
858 "Processing track %s / %s (%s)",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
859 category,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
860 track_human_label,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
861 dataset_ext,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
862 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
863 outputTrackConfig["key"] = track_human_label
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
864 # We add extra data to hash for the case of REST + SPARQL.
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
865 if (
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
866 "conf" in track
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
867 and "options" in track["conf"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
868 and "url" in track["conf"]["options"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
869 ):
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
870 rest_url = track["conf"]["options"]["url"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
871 else:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
872 rest_url = ""
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
873
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
874 # 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
875 # 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
876 # 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
877 # much simpler.
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
878 hashData = [
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
879 str(dataset_path),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
880 track_human_label,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
881 track["category"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
882 rest_url,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
883 self.current_assembly_id,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
884 ]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
885 hashData = "|".join(hashData).encode("utf-8")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
886 outputTrackConfig["label"] = hashlib.md5(hashData).hexdigest() + "_%s" % i
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
887 outputTrackConfig["metadata"] = extra_metadata
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
888
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
889 outputTrackConfig["style"] = track["style"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
890
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
891 if "menus" in track["conf"]["options"]:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
892 menus = self.cs.parse_menus(track["conf"]["options"])
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
893 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
894
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
895 if dataset_ext in ("gff", "gff3"):
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
896 self.add_gff(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
897 dataset_path,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
898 dataset_ext,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
899 outputTrackConfig,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
900 track["conf"]["options"]["gff"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
901 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
902 elif dataset_ext == "bed":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
903 self.add_bed(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
904 dataset_path,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
905 dataset_ext,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
906 outputTrackConfig,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
907 track["conf"]["options"]["gff"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
908 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
909 elif dataset_ext == "bigwig":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
910 self.add_bigwig(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
911 dataset_path, outputTrackConfig, track["conf"]["options"]["wiggle"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
912 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
913 elif dataset_ext == "bam":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
914 real_indexes = track["conf"]["options"]["pileup"]["bam_indices"][
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
915 "bam_index"
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
916 ]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
917 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
918 # <bam_indices>
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
919 # <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
920 # </bam_indices>
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 # 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
923 # 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
924 # 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
925 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
926
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
927 self.add_xam(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
928 dataset_path,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
929 outputTrackConfig,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
930 track["conf"]["options"]["pileup"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
931 index=real_indexes[i],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
932 ext="bam",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
933 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
934 elif dataset_ext == "cram":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
935 real_indexes = track["conf"]["options"]["cram"]["cram_indices"][
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
936 "cram_index"
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
937 ]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
938 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
939 # <bam_indices>
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
940 # <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
941 # </bam_indices>
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
942 #
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
943 # 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
944 # 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
945 # 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
946 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
947
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
948 self.add_xam(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
949 dataset_path,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
950 outputTrackConfig,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
951 track["conf"]["options"]["cram"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
952 index=real_indexes[i],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
953 ext="cram",
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
954 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
955 elif dataset_ext == "blastxml":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
956 self.add_blastxml(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
957 dataset_path, outputTrackConfig, track["conf"]["options"]["blast"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
958 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
959 elif dataset_ext == "vcf":
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
960 self.add_vcf(dataset_path, outputTrackConfig)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
961 elif dataset_ext == "vcf_bgzip":
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
962 self.add_vcf(dataset_path, outputTrackConfig, zipped=True)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
963 elif dataset_ext == "rest":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
964 self.add_rest(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
965 track["conf"]["options"]["rest"]["url"], outputTrackConfig
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
966 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
967 elif dataset_ext == "synteny":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
968 self.add_paf(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
969 dataset_path, outputTrackConfig, track["conf"]["options"]["synteny"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
970 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
971 elif dataset_ext == "hic":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
972 self.add_hic(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
973 dataset_path, outputTrackConfig, track["conf"]["options"]["hic"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
974 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
975 elif dataset_ext == "sparql":
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
976 sparql_query = track["conf"]["options"]["sparql"]["query"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
977 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
978 sparql_query = sparql_query.replace(value, key)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
979 sparql_query_refnames = track["conf"]["options"]["sparql"][
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
980 "query_refnames"
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
981 ]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
982 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
983 sparql_query_refnames = sparql_query_refnames.replace(value, key)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
984 self.add_sparql(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
985 track["conf"]["options"]["sparql"]["url"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
986 sparql_query,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
987 sparql_query_refnames,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
988 outputTrackConfig,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
989 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
990 else:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
991 log.warn("Do not know how to handle %s", dataset_ext)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
992
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
993 # Return non-human label for use in other fields
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
994 yield outputTrackConfig["label"]
13
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 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
997 """
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
998 Add some default session settings: set some assemblies/tracks on/off
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
999 """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1000 tracks_data = []
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1001
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1002 # 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
1003
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1004 # We need to know the track type from the config.json generated just before
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1005 config_path = os.path.join(self.outdir, "data", "config.json")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1006 track_types = {}
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1007 with open(config_path, "r") as config_file:
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1008 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
1009
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1010 for track_conf in config_json["tracks"]:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1011 track_types[track_conf["trackId"]] = track_conf["type"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1012
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1013 for on_track in data["visibility"]["default_on"]:
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1014 # 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
1015 # - 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
1016 # - 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
1017 # - this could be solved by session specs, see https://github.com/GMOD/jbrowse-components/issues/2708
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1018 style_data = {"type": "LinearBasicDisplay", "height": 100}
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1019
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1020 if on_track in data["style"]:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1021 if "display" in data["style"][on_track]:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1022 style_data["type"] = data["style"][on_track]["display"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1023 del data["style"][on_track]["display"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1024
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1025 style_data.update(data["style"][on_track])
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1026
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1027 if on_track in data["style_labels"]:
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1028 # 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
1029 # TODO move this to per track displays?
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1030 style_data["labels"] = data["style_labels"][on_track]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1031
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1032 tracks_data.append(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1033 {
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1034 "type": track_types[on_track],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1035 "configuration": on_track,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1036 "displays": [style_data],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1037 }
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1038 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1039
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1040 # The view for the assembly we're adding
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1041 view_json = {"type": "LinearGenomeView", "tracks": tracks_data}
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1042
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1043 refName = None
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1044 if data.get("defaultLocation", ""):
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1045 loc_match = re.search(r"^(\w+):(\d+)\.+(\d+)$", data["defaultLocation"])
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1046 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
1047 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
1048 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
1049 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
1050 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
1051 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
1052 start = 0
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1053 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
1054
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1055 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
1056 # TODO displayedRegions is not just zooming to the region, it hides the rest of the chromosome
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1057 view_json["displayedRegions"] = [
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1058 {
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1059 "refName": refName,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1060 "start": start,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1061 "end": end,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1062 "reversed": False,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1063 "assemblyName": self.current_assembly_id,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1064 }
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1065 ]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1066
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1067 session_name = data.get("session_name", "New session")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1068 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
1069 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
1070
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1071 # 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
1072 session_json = {}
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1073 if "defaultSession" in config_json:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1074 session_json = config_json["defaultSession"]
13
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 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
1077
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1078 if "views" not in session_json:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1079 session_json["views"] = []
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1080
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1081 session_json["views"].append(view_json)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1082
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1083 config_json["defaultSession"] = session_json
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1084
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1085 with open(config_path, "w") as config_file:
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1086 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
1087
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1088 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
1089 """
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1090 Add some general configuration to the config.json file
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1091 """
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1092
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1093 config_path = os.path.join(self.outdir, "data", "config.json")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1094 with open(config_path, "r") as config_file:
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1095 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
1096
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1097 config_data = {}
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1098
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1099 config_data["disableAnalytics"] = data.get("analytics", "false") == "true"
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1100
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1101 config_data["theme"] = {
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1102 "palette": {
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1103 "primary": {"main": data.get("primary_color", "#0D233F")},
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1104 "secondary": {"main": data.get("secondary_color", "#721E63")},
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1105 "tertiary": {"main": data.get("tertiary_color", "#135560")},
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1106 "quaternary": {"main": data.get("quaternary_color", "#FFB11D")},
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1107 },
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1108 "typography": {"fontSize": int(data.get("font_size", 10))},
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1109 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1110
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1111 config_json["configuration"].update(config_data)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1112
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1113 with open(config_path, "w") as config_file:
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1114 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
1115
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1116 def clone_jbrowse(self, jbrowse_dir, destination):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1117 """Clone a JBrowse directory into a destination directory."""
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1118
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1119 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
1120
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1121 try:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1122 shutil.rmtree(os.path.join(destination, "test_data"))
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1123 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
1124 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
1125
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1126 if not os.path.exists(os.path.join(destination, "data")):
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1127 # It can already exist if upgrading an instance
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1128 os.makedirs(os.path.join(destination, "data"))
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1129 log.info("makedir %s" % (os.path.join(destination, "data")))
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1130
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1131 os.symlink("./data/config.json", os.path.join(destination, "config.json"))
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1132
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1133
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1134 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
1135 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
1136 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
1137 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
1138 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
1139 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
1140 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1141 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
1142
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1143
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1144 def parse_style_conf(item):
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1145 if "type" in item.attrib and item.attrib["type"] in ["boolean", "integer"]:
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1146 if item.attrib["type"] == "boolean":
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1147 return item.text in ("yes", "true", "True")
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1148 elif item.attrib["type"] == "integer":
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1149 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
1150 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1151 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
1152
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1153
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1154 if __name__ == "__main__":
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1155 parser = argparse.ArgumentParser(description="", epilog="")
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1156 parser.add_argument("xml", type=argparse.FileType("r"), help="Track Configuration")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1157
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1158 parser.add_argument("--jbrowse", help="Folder containing a jbrowse release")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1159 parser.add_argument("--outdir", help="Output directory", default="out")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1160 parser.add_argument("--version", "-V", action="version", version="%(prog)s 0.8.0")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1161 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
1162
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1163 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
1164 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
1165
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1166 # This should be done ASAP
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1167 GALAXY_INFRASTRUCTURE_URL = root.find("metadata/galaxyUrl").text
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1168 # Sometimes this comes as `localhost` without a protocol
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1169 if not GALAXY_INFRASTRUCTURE_URL.startswith("http"):
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1170 # 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
1171 # be GET and not POST so it should redirect OK
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1172 GALAXY_INFRASTRUCTURE_URL = "http://" + GALAXY_INFRASTRUCTURE_URL
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1173
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1174 jc = JbrowseConnector(
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1175 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
1176 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
1177 genomes=[
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1178 {
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1179 "path": os.path.realpath(x.attrib["path"]),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1180 "meta": metadata_from_node(x.find("metadata")),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1181 "label": x.attrib["label"],
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1182 }
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1183 for x in root.findall("metadata/genomes/genome")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1184 ],
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1185 )
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1186
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1187 default_session_data = {
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1188 "visibility": {
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1189 "default_on": [],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1190 "default_off": [],
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1191 },
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1192 "style": {},
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1193 "style_labels": {},
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1194 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1195
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1196 # TODO add metadata to tracks
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1197 for track in root.findall("tracks/track"):
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1198 track_conf = {}
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1199 track_conf["trackfiles"] = []
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1200
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1201 trackfiles = track.findall("files/trackFile")
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1202 if trackfiles:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1203 for x in track.findall("files/trackFile"):
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1204 if trackfiles:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1205 metadata = metadata_from_node(x.find("metadata"))
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1206
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1207 track_conf["trackfiles"].append(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1208 (
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1209 os.path.realpath(x.attrib["path"]),
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1210 x.attrib["ext"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1211 x.attrib["label"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1212 metadata,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1213 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1214 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1215 else:
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1216 # For tracks without files (rest, sparql)
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1217 track_conf["trackfiles"].append(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1218 (
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1219 "", # N/A, no path for rest or sparql
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1220 track.attrib["format"],
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1221 track.find("options/label").text,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1222 {},
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1223 )
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1224 )
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1225
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1226 track_conf["category"] = track.attrib["cat"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1227 track_conf["format"] = track.attrib["format"]
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1228 track_conf["style"] = {
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1229 item.tag: parse_style_conf(item) for item in track.find("options/style")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1230 }
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1231
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1232 track_conf["style"] = {
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1233 item.tag: parse_style_conf(item) for item in track.find("options/style")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1234 }
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1235
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1236 track_conf["style_labels"] = {
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1237 item.tag: parse_style_conf(item)
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1238 for item in track.find("options/style_labels")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1239 }
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1240
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1241 track_conf["conf"] = etree_to_dict(track.find("options"))
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1242 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
1243
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1244 for key in keys:
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1245 default_session_data["visibility"][
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1246 track.attrib.get("visibility", "default_off")
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1247 ].append(key)
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1248
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1249 default_session_data["style"][key] = track_conf[
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1250 "style"
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1251 ] # TODO do we need this anymore?
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1252 default_session_data["style_labels"][key] = track_conf["style_labels"]
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1253
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1254 default_session_data["defaultLocation"] = root.find(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1255 "metadata/general/defaultLocation"
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1256 ).text
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1257 default_session_data["session_name"] = root.find(
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1258 "metadata/general/session_name"
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1259 ).text
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1260
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1261 general_data = {
14
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1262 "analytics": root.find("metadata/general/analytics").text,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1263 "primary_color": root.find("metadata/general/primary_color").text,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1264 "secondary_color": root.find("metadata/general/secondary_color").text,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1265 "tertiary_color": root.find("metadata/general/tertiary_color").text,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1266 "quaternary_color": root.find("metadata/general/quaternary_color").text,
7c2e28e144f3 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5d84967148d45684d585d4e12b210dc5e12e4776
fubar
parents: 13
diff changeset
1267 "font_size": root.find("metadata/general/font_size").text,
13
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1268 }
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1269
1d86925dbb4c planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 873a12803692b0a84814a6dc08331d772d0e5492-dirty
fubar
parents:
diff changeset
1270 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
1271 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
1272 jc.text_index()