changeset 10:1a6d882d340d draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
author iuc
date Fri, 02 Dec 2016 17:58:54 -0500
parents f422ba2e9aa5
children 4cbceec1d6b4
files jbrowse.py jbrowse.xml macros.xml readme.rst test-data/track_config/test.xml
diffstat 5 files changed, 152 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/jbrowse.py	Tue Nov 29 12:31:56 2016 -0500
+++ b/jbrowse.py	Fri Dec 02 17:58:54 2016 -0500
@@ -264,11 +264,11 @@
     if children:
         dd = defaultdict(list)
         for dc in map(etree_to_dict, children):
-            for k, v in dc.iteritems():
+            for k, v in dc.items():
                 dd[k].append(v)
-        d = {t.tag: {k: v[0] if len(v) == 1 else v for k, v in dd.iteritems()}}
+        d = {t.tag: {k: v[0] if len(v) == 1 else v for k, v in dd.items()}}
     if t.attrib:
-        d[t.tag].update(('@' + k, v) for k, v in t.attrib.iteritems())
+        d[t.tag].update(('@' + k, v) for k, v in t.attrib.items())
     if t.text:
         text = t.text.strip()
         if children or t.attrib:
@@ -370,7 +370,7 @@
         self.subprocess_check_call(cmd)
 
     def _add_track_json(self, json_data):
-        if len(json_data.keys()) == 0:
+        if len(json_data) == 0:
             return
 
         tmp = tempfile.NamedTemporaryFile(delete=False)
@@ -499,7 +499,6 @@
             self.TN_TABLE.get(format, 'gff'),
             data,
             '--trackLabel', trackData['label'],
-            # '--trackType', 'JBrowse/View/Track/CanvasFeatures',
             '--key', trackData['key']
         ]
 
@@ -514,14 +513,21 @@
         cmd += ['--clientConfig', json.dumps(clientConfig),
                 ]
 
+        trackType = 'JBrowse/View/Track/CanvasFeatures'
         if 'trackType' in gffOpts:
-            cmd += [
-                '--trackType', gffOpts['trackType']
-            ]
-        else:
-            cmd += [
-                '--trackType', 'JBrowse/View/Track/CanvasFeatures'
-            ]
+            trackType = gffOpts['trackType']
+
+        if trackType == 'JBrowse/View/Track/CanvasFeatures':
+            if 'transcriptType' in gffOpts and gffOpts['transcriptType']:
+                config['transcriptType'] = gffOpts['transcriptType']
+            if 'subParts' in gffOpts and gffOpts['subParts']:
+                config['subParts'] = gffOpts['subParts']
+            if 'impliedUTRs' in gffOpts and gffOpts['impliedUTRs']:
+                config['impliedUTRs'] = gffOpts['impliedUTRs']
+
+        cmd += [
+            '--trackType', gffOpts['trackType']
+        ]
 
         cmd.extend(['--config', json.dumps(config)])
 
@@ -544,7 +550,7 @@
             log.info('Processing %s / %s', track['category'], track_human_label)
             outputTrackConfig['key'] = track_human_label
             hashData = [dataset_path, track_human_label, track['category']]
-            outputTrackConfig['label'] = hashlib.md5('|'.join(hashData)).hexdigest() + '_%s' % i
+            outputTrackConfig['label'] = hashlib.md5('|'.join(hashData).encode('utf-8')).hexdigest() + '_%s' % i
 
             # Colour parsing is complex due to different track types having
             # different colour options.
@@ -640,7 +646,7 @@
 
 if __name__ == '__main__':
     parser = argparse.ArgumentParser(description="", epilog="")
-    parser.add_argument('xml', type=file, help='Track Configuration')
+    parser.add_argument('xml', type=argparse.FileType('r'), help='Track Configuration')
 
     parser.add_argument('--jbrowse', help='Folder containing a jbrowse release')
     parser.add_argument('--outdir', help='Output directory', default='out')
--- a/jbrowse.xml	Tue Nov 29 12:31:56 2016 -0500
+++ b/jbrowse.xml	Fri Dec 02 17:58:54 2016 -0500
@@ -216,7 +216,18 @@
                 </blast>
             #else if str($track.data_format.data_format_select) == "gene_calls":
                 <gff>
-                    <trackType>${track.data_format.track_class}</trackType>
+                    <trackType>${track.data_format.track_config.track_class}</trackType>
+                  #if $track.data_format.track_config.track_class == 'JBrowse/View/Track/CanvasFeatures':
+                    #if str($track.data_format.track_config.canvas_options.transcriptType) != "":
+                    <transcriptType>${track.data_format.track_config.canvas_options.transcriptType}</transcriptType>
+                    #end if
+                    #if str($track.data_format.track_config.canvas_options.subParts) != "":
+                    <subParts>${track.data_format.track_config.canvas_options.subParts}</subParts>
+                    #end if
+                    #if str($track.data_format.track_config.canvas_options.impliedUTRs) != "false":
+                    <impliedUTRs>${track.data_format.track_config.canvas_options.impliedUTRs}</impliedUTRs>
+                    #end if
+                  #end if
                   #if $track.data_format.match_part.match_part_select:
                     <match>${track.data_format.match_part.name}</match>
                   #end if
@@ -381,10 +392,36 @@
 
                 <param label="Index this track" name="index" type="boolean" checked="false" truevalue="true" falsevalue="false" />
 
-                <param type="select" label="JBrowse Track Type [Advanced]" name="track_class">
-                  <option value="JBrowse/View/Track/HTMLFeatures">HTML Features</option>
-                  <option value="JBrowse/View/Track/CanvasFeatures" selected="true">Canvas Features</option>
-                </param>
+                <conditional name="track_config">
+                    <param type="select" label="JBrowse Track Type [Advanced]" name="track_class">
+                        <option value="JBrowse/View/Track/HTMLFeatures">HTML Features</option>
+                        <option value="JBrowse/View/Track/CanvasFeatures" selected="true">Canvas Features</option>
+                    </param>
+                    <when value="JBrowse/View/Track/CanvasFeatures">
+                        <section name="canvas_options" title="CanvasFeatures Options [Advanced]" expanded="false">
+                            <param label="Transcript type"
+                                   name="transcriptType"
+                                   type="text"
+                                   value=""
+                                   help="If your input files represents transcripts with features not named 'mRNA', give the alternate name here (e.g. 'transcript')"
+                                   optional="True"/>
+                            <param label="Subfeatures type"
+                                   name="subParts"
+                                   type="text"
+                                   value=""
+                                   help="If you have 'exons' but no corresponding 'CDS' features, specify here the subfeatures that should be displayed (e.g. 'exon')"
+                                   optional="True"/>
+                            <param label="Implied UTRs"
+                                   name="impliedUTRs"
+                                   type="boolean"
+                                   checked="false"
+                                   truevalue="true"
+                                   falsevalue="false"
+                                   help="Check this your input files does not contain UTR features, but the UTR can be 'implied' from the difference between the exon and CDS boundaries"/>
+                       </section>
+                   </when>
+                   <when value="JBrowse/View/Track/HTMLFeatures" />
+                </conditional>
                 <expand macro="track_styling" />
                 <expand macro="color_selection" />
                 <expand macro="track_menu" />
@@ -729,6 +766,43 @@
         <param name="uglyTestingHack" value="enabled" />
         <output name="output" file="menus/test.xml" lines_diff="6"/>
     </test>
+    <test>
+        <param name="reference_genome|genome_type_select" value="history"/>
+        <param name="reference_genome|genomes" value="merlin.fa"/>
+        <param name="gencode" value="11" />
+        <param name="standalone" value="Data Directory" />
+
+        <repeat name="track_groups">
+            <param name="category" value="With canvas config" />
+            <repeat name="data_tracks">
+                <conditional name="data_format">
+                    <param name="data_format_select" value="gene_calls"/>
+                    <param name="annotation" value="gff3/1.gff"/>
+                    <conditional name="match_part">
+                        <param name="match_part_select" value="false"/>
+                    </conditional>
+                    <conditional name="track_config">
+                        <section name="canvas_options">
+                            <param name="transcriptType" value="transcript"/>
+                            <param name="subParts" value="exon"/>
+                            <param name="impliedUTRs" value="true"/>
+                        </section>
+                    </conditional>
+                    <section name="jbcolor_scale">
+                        <conditional name="color_score">
+                            <param name="color_score_select" value="none"/>
+                        </conditional>
+                        <conditional name="color">
+                            <param name="color_select" value="automatic"/>
+                        </conditional>
+                    </section>
+                </conditional>
+            </repeat>
+        </repeat>
+
+        <param name="uglyTestingHack" value="enabled" />
+        <output name="output" file="track_config/test.xml" lines_diff="6"/>
+    </test>
   </tests>
   <help><![CDATA[
 JBrowse-in-Galaxy
--- a/macros.xml	Tue Nov 29 12:31:56 2016 -0500
+++ b/macros.xml	Fri Dec 02 17:58:54 2016 -0500
@@ -12,7 +12,7 @@
     </requirements>
   </xml>
   <token name="@DATA_DIR@">\$GALAXY_JBROWSE_SHARED_DIR</token>
-  <token name="@WRAPPER_VERSION@">0.5.1</token>
+  <token name="@WRAPPER_VERSION@">0.5.2</token>
   <xml name="stdio">
     <stdio>
       <exit_code range="1:"/>
@@ -265,7 +265,7 @@
           <param label="Menu title"
                  type="text"
                  name="menu_title"
-                 help="Will be displayed in the popup title bar if displayed ({name}, {id}, {type}, {start}, {end}, {strand} variables will be interpreted)">
+                 help="Will be displayed in the popup title bar if displayed ({id}, {type}, {start}, {end}, {strand} variables will be interpreted)">
            <expand macro="menu_sanitize" />
           </param>
           <param label="Menu url"
--- a/readme.rst	Tue Nov 29 12:31:56 2016 -0500
+++ b/readme.rst	Fri Dec 02 17:58:54 2016 -0500
@@ -25,6 +25,7 @@
 History
 =======
 
+-  0.5.2 Support for CanvasFeatures options.
 -  0.5.1 Support for contextual menus. Conda tests.
 -  0.5 Update existing instances on disk. Index names. Support HTML tracks
    instead of Canvas. Support default tracks. General JBrowse optinos
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/track_config/test.xml	Fri Dec 02 17:58:54 2016 -0500
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<root>
+    <metadata>
+        <gencode>11</gencode>
+        <genomes>
+                  <genome>/tmp/tmplFZ5li/files/000/dataset_14.dat</genome>
+        </genomes>
+        <general>
+            <defaultLocation></defaultLocation>
+            <trackPadding>20</trackPadding>
+
+            <shareLink>true</shareLink>
+            <aboutDescription></aboutDescription>
+            <show_tracklist>true</show_tracklist>
+            <show_nav>true</show_nav>
+            <show_overview>true</show_overview>
+            <show_menu>true</show_menu>
+            <hideGenomeOptions>false</hideGenomeOptions>
+        </general>
+    </metadata>
+    <tracks>
+        <track cat="With canvas config" format="gene_calls" visibility="default_off">
+            <files>
+              <trackFile path="/tmp/tmplFZ5li/files/000/dataset_15.dat" ext="gff3" label="1.gff" />
+            </files>
+
+            <options>
+                <style>
+                    <className>feature</className>
+                    <description>note,description</description>
+                    <label>name,id</label>
+                    <height>100px</height>
+                </style>
+                <scaling>
+                        <method>ignore</method>
+                        <scheme>
+                            <color>__auto__</color>
+                        </scheme>
+                </scaling>
+                <menus>
+                </menus>
+
+                <gff>
+                    <trackType>JBrowse/View/Track/CanvasFeatures</trackType>
+                    <index>false</index>
+                </gff>
+            </options>
+        </track>
+    </tracks>
+</root>