diff trackHub/tracks_partial.py @ 1:fb5e60d4d18a draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 64cfc08088d11f6818c1b4e5514ef9e67969eaff-dirty
author rmarenco
date Wed, 13 Jul 2016 13:36:37 -0400
parents
children 3233451a3bd6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trackHub/tracks_partial.py	Wed Jul 13 13:36:37 2016 -0400
@@ -0,0 +1,56 @@
+"""
+HubAssembly datatype
+"""
+import logging
+
+from galaxy.datatypes.text import Html
+
+log = logging.getLogger( __name__ )
+
+# !!! README !!! The content of this file should be added in tracks.py, but do it carefully!
+# Don't erase the existing content
+
+
+class UCSCTrackHub( Html ):
+    """
+    derived class for BioC data structures in Galaxy
+    """
+
+    file_ext = 'trackhub'
+    composite_type = 'auto_primary_file'
+
+    def __init__( self, **kwd ):
+        Html.__init__( self, **kwd )
+
+    def generate_primary_file( self, dataset=None ):
+        """
+        This is called only at upload to write the html file
+        cannot rename the datasets here - they come with the default unfortunately
+        """
+        rval = [
+            '<html><head><title>Files for Composite Dataset (%s)</title></head><p/>\
+            This composite dataset is composed of the following files:<p/><ul>' % (
+                self.file_ext)]
+        for composite_name, composite_file in self.get_composite_files(dataset=dataset).iteritems():
+            opt_text = ''
+            if composite_file.optional:
+                opt_text = ' (optional)'
+            rval.append('<li><a href="%s">%s</a>%s' % (composite_name, composite_name, opt_text))
+        rval.append('</ul></html>')
+        return "\n".join(rval)
+
+    def set_peek( self, dataset, is_multi_byte=False ):
+        if not dataset.dataset.purged:
+            dataset.peek = "Track Hub structure: Visualization in UCSC Track Hub"
+        else:
+            dataset.peek = 'file does not exist'
+            dataset.blurb = 'file purged from disk'
+
+    def display_peek( self, dataset ):
+        try:
+            return dataset.peek
+        except:
+            return "Track Hub structure: Visualization in UCSC Track Hub"
+
+    def sniff( self, filename ):
+        return False