diff jbrowse.py @ 10:1a6d882d340d draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse commit ac44b067ee08de23180e8b5030374cf362ac4524
author iuc
date Fri, 02 Dec 2016 17:58:54 -0500
parents ad4b9d7eae6a
children 4cbceec1d6b4
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')