Repository 'jbrowse'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/jbrowse

Changeset 33:0ae74c70b267 (2019-08-30)
Previous changeset 32:6b774e9d6387 (2019-07-16) Next changeset 34:9de82b4963e6 (2019-09-11)
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit 369a727966d697c56633b27ad2757db40fef0dc3"
modified:
jbrowse.py
jbrowse.xml
macros.xml
b
diff -r 6b774e9d6387 -r 0ae74c70b267 jbrowse.py
--- a/jbrowse.py Tue Jul 16 05:08:10 2019 -0400
+++ b/jbrowse.py Fri Aug 30 03:36:39 2019 -0400
[
b'@@ -331,13 +331,6 @@\n class JbrowseConnector(object):\n \n     def __init__(self, jbrowse, outdir, genomes, standalone=False, gencode=1):\n-        self.TN_TABLE = {\n-            \'gff3\': \'--gff\',\n-            \'gff\': \'--gff\',\n-            \'bed\': \'--bed\',\n-            \'genbank\': \'--gbk\',\n-        }\n-\n         self.cs = ColorScaling()\n         self.jbrowse = jbrowse\n         self.outdir = outdir\n@@ -379,9 +372,13 @@\n         with open(trackList, \'w\') as handle:\n             json.dump(trackListData, handle, indent=2)\n \n-    def subprocess_check_call(self, command):\n-        log.debug(\'cd %s && %s\', self.outdir, \' \'.join(command))\n-        subprocess.check_call(command, cwd=self.outdir)\n+    def subprocess_check_call(self, command, output=None):\n+        if output:\n+            log.debug(\'cd %s && %s >  %s\', self.outdir, \' \'.join(command), output)\n+            subprocess.check_call(command, cwd=self.outdir, stdout=output)\n+        else:\n+            log.debug(\'cd %s && %s\', self.outdir, \' \'.join(command))\n+            subprocess.check_call(command, cwd=self.outdir)\n \n     def subprocess_popen(self, command):\n         log.debug(\'cd %s && %s\', self.outdir, command)\n@@ -558,6 +555,41 @@\n \n         self._add_track_json(trackData)\n \n+    def add_maf(self, data, trackData, mafOpts, **kwargs):\n+        script = os.path.realpath(os.path.join(self.jbrowse, \'plugins\', \'MAFViewer\', \'bin\', \'maf2bed.pl\'))\n+        dest = os.path.join(\'data\', \'raw\', trackData[\'label\'] + \'.txt\')\n+\n+        tmp1 = tempfile.NamedTemporaryFile(delete=False)\n+        tmp1.close()\n+\n+        # Process MAF to bed-like\n+        cmd = [script, data]\n+        self.subprocess_check_call(cmd, output=tmp1.path)\n+\n+        # Sort / Index it\n+        self._sort_bed(tmp1.path, dest)\n+        # Cleanup\n+        try:\n+            os.remove(tmp1.path)\n+        except OSError:\n+            pass\n+\n+        # Construct samples list\n+        # We could get this from galaxy metadata, not sure how easily.\n+        ps = subprocess.Popen([\'grep\', \'^s [^ ]*\', \'-o\', data], stdout=subprocess.PIPE)\n+        output = subprocess.check_output((\'sort\', \'-u\'), stdin=ps.stdout)\n+        ps.wait()\n+        samples = [x[2:] for x in output]\n+\n+        trackData.update({\n+            "storeClass": "MAFViewer/Store/SeqFeature/MAFTabix",\n+            "type": "MAFViewer/View/Track/MAF",\n+            "urlTemplate": trackData[\'label\'] + \'.txt.gz\',\n+            "samples": samples,\n+        })\n+\n+        self._add_track_json(trackData)\n+\n     def add_bam(self, data, trackData, bamOpts, bam_index=None, **kwargs):\n         dest = os.path.join(\'data\', \'raw\', trackData[\'label\'] + \'.bam\')\n         cmd = [\'ln\', \'-s\', os.path.realpath(data), dest]\n@@ -610,19 +642,24 @@\n         self._add_track_json(trackData)\n \n     def _sort_gff(self, data, dest):\n-\n+        # Only index if not already done\n         if not os.path.exists(dest):\n-            # Only index if not already done\n             cmd = "gff3sort.pl --precise \'%s\' | grep -v \\"^$\\" > \'%s\'" % (data, dest)\n             self.subprocess_popen(cmd)\n \n-            cmd = [\'bgzip\', \'-f\', dest]\n-            self.subprocess_popen(\' \'.join(cmd))\n-            cmd = [\'tabix\', \'-f\', \'-p\', \'gff\', dest + \'.gz\']\n-            self.subprocess_popen(\' \'.join(cmd))\n+            self.subprocess_check_call([\'bgzip\', \'-f\', dest])\n+            self.subprocess_check_call([\'tabix\', \'-f\', \'-p\', \'gff\', dest + \'.gz\'])\n \n-    def add_features(self, data, format, trackData, gffOpts, **kwargs):\n+    def _sort_bed(self, data, dest):\n+        # Only index if not already done\n+        if not os.path.exists(dest):\n+            cmd = [\'sort\', \'-k1,1\', \'-k2,2n\', data]\n+            self.subprocess_check_call(cmd, output=dest)\n \n+            self.subprocess_check_call([\'bgzip\', \'-f\', dest])\n+            self.subprocess_check_call([\'tabix\', \'-f\', \'-p\', \'bed\', dest + \'.gz\'])\n+\n+    def add_gff(self, data, format, trackData, gffOpts, **kwargs):\n         dest = os.path.join(self.outdir, \'data\', \'raw\', trac'..b'        trackData[\'topLevelFeatures\'] = gffOpts[\'topLevelFeatures\']\n+\n+        self._add_track_json(trackData)\n+\n+        if gffOpts.get(\'index\', \'false\') == \'true\':\n+            self.tracksToIndex.append("%s" % trackData[\'label\'])\n+\n+    def add_genbank(self, data, format, trackData, gffOpts, **kwargs):\n+        cmd = [\n+            \'perl\', self._jbrowse_bin(\'flatfile-to-json.pl\'),\n+            \'--genbank\', data,\n+            \'--trackLabel\', trackData[\'label\'],\n+            \'--key\', trackData[\'key\']\n+        ]\n+\n+        # className in --clientConfig is ignored, it needs to be set with --className\n+        if \'className\' in trackData[\'style\']:\n+            cmd += [\'--className\', trackData[\'style\'][\'className\']]\n+\n+        config = copy.copy(trackData)\n+        clientConfig = trackData[\'style\']\n+        del config[\'style\']\n+\n+        if \'match\' in gffOpts:\n+            config[\'glyph\'] = \'JBrowse/View/FeatureGlyph/Segments\'\n+            if bool(gffOpts[\'match\']):\n+                # Can be empty for CanvasFeatures = will take all by default\n+                cmd += [\'--type\', gffOpts[\'match\']]\n+\n+        cmd += [\'--clientConfig\', json.dumps(clientConfig)]\n+\n+        trackType = \'JBrowse/View/Track/CanvasFeatures\'\n+        if \'trackType\' in gffOpts:\n+            trackType = gffOpts[\'trackType\']\n+\n+        if trackType == \'JBrowse/View/Track/CanvasFeatures\':\n+            if \'transcriptType\' in gffOpts and gffOpts[\'transcriptType\']:\n+                config[\'transcriptType\'] = gffOpts[\'transcriptType\']\n+            if \'subParts\' in gffOpts and gffOpts[\'subParts\']:\n+                config[\'subParts\'] = gffOpts[\'subParts\']\n+            if \'impliedUTRs\' in gffOpts and gffOpts[\'impliedUTRs\']:\n+                config[\'impliedUTRs\'] = gffOpts[\'impliedUTRs\']\n+        elif trackType == \'JBrowse/View/Track/HTMLFeatures\':\n+            if \'transcriptType\' in gffOpts and gffOpts[\'transcriptType\']:\n+                cmd += [\'--type\', gffOpts[\'transcriptType\']]\n+\n+        cmd += [\n+            \'--trackType\', gffOpts[\'trackType\']\n+        ]\n+\n+        cmd.extend([\'--config\', json.dumps(config)])\n+\n+        self.subprocess_check_call(cmd)\n+\n+        if gffOpts.get(\'index\', \'false\') == \'true\':\n+            self.tracksToIndex.append("%s" % trackData[\'label\'])\n+\n     def add_rest(self, url, trackData):\n         data = {\n             "label": trackData[\'label\'],\n@@ -782,15 +902,24 @@\n \n             # import pprint; pprint.pprint(track)\n             # import sys; sys.exit()\n-            if dataset_ext in (\'gff\', \'gff3\', \'bed\'):\n-                self.add_features(dataset_path, dataset_ext, outputTrackConfig,\n-                                  track[\'conf\'][\'options\'][\'gff\'])\n+            if dataset_ext in (\'gff\', \'gff3\'):\n+                self.add_gff(dataset_path, dataset_ext, outputTrackConfig,\n+                             track[\'conf\'][\'options\'][\'gff\'])\n+            elif dataset_ext in (\'bed\', ):\n+                self.add_bed(dataset_path, dataset_ext, outputTrackConfig,\n+                             track[\'conf\'][\'options\'][\'gff\'])\n+            elif dataset_ext in (\'genbank\', ):\n+                self.add_genbank(dataset_path, dataset_ext, outputTrackConfig,\n+                                 track[\'conf\'][\'options\'][\'gff\'])\n             elif dataset_ext == \'bigwig\':\n                 self.add_bigwig(dataset_path, outputTrackConfig,\n                                 track[\'conf\'][\'options\'][\'wiggle\'])\n             elif dataset_ext == \'bigwig_multiple\':\n                 self.add_bigwig_multiple(dataset_path, outputTrackConfig,\n                                          track[\'conf\'][\'options\'][\'wiggle\'])\n+            elif dataset_ext == \'maf\':\n+                self.add_maf(dataset_path, outputTrackConfig,\n+                             track[\'conf\'][\'options\'][\'maf\'])\n             elif dataset_ext == \'bam\':\n                 real_indexes = track[\'conf\'][\'options\'][\'pileup\'][\'bam_indices\'][\'bam_index\']\n                 if not isinstance(real_indexes, list):\n'
b
diff -r 6b774e9d6387 -r 0ae74c70b267 jbrowse.xml
--- a/jbrowse.xml Tue Jul 16 05:08:10 2019 -0400
+++ b/jbrowse.xml Fri Aug 30 03:36:39 2019 -0400
b
@@ -401,7 +401,7 @@
     <repeat name="data_tracks" title="Annotation Track">
         <conditional name="data_format" label="Track Options">
             <param type="select" label="Track Type" name="data_format_select">
-                <option value="gene_calls">GFF/GFF3/BED/GBK Features</option>
+                <option value="gene_calls">GFF/GFF3/BED Features</option>
                 <option value="pileup">BAM Pileups</option>
                 <option value="blast">Blast XML</option>
                 <option value="wiggle">BigWig XY</option>
@@ -1167,14 +1167,14 @@
 There are a few different types of tracks supported, each with their own
 set of options:
 
-GFF3/BED/GBK
-~~~~~~~~~~~~
+GFF3/BED
+~~~~~~~~
 
 These are your standard feature tracks. They usually highlight genes,
 mRNAs and other features of interest along a genomic region. The
 underlying tool and this help documentation focus primarily on GFF3
 data, and have not been tested extensively with other formats. Automatic
-min/max detection will likely fail under BED and GBK datasets.
+min/max detection will fail under BED datasets.
 
 The data may be of a subclass we call **match/match part** data. This
 consists of top level ``match`` features, with a child ``match_part``
b
diff -r 6b774e9d6387 -r 0ae74c70b267 macros.xml
--- a/macros.xml Tue Jul 16 05:08:10 2019 -0400
+++ b/macros.xml Fri Aug 30 03:36:39 2019 -0400
[
@@ -14,11 +14,11 @@
     </requirements>
   </xml>
   <token name="@DATA_DIR@">\$GALAXY_JBROWSE_SHARED_DIR</token>
-  <token name="@WRAPPER_VERSION@">galaxy3</token>
+  <token name="@WRAPPER_VERSION@">galaxy4</token>
   <token name="@ATTRIBUTION@"><![CDATA[
 **Attribution**
 
-This Galaxy tool relies on the JBrowse, maintained by the GMOD Community. The Galaxy wrapper is developed by Eric Rasche
+This Galaxy tool relies on the JBrowse, maintained by the GMOD Community. The Galaxy wrapper is developed by the IUC
 ]]>
   </token>