changeset 18:f23321937d46 draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit c778f8ee85e9acc924c5c0a30042ac90c8e7a70d-dirty
author yating-l
date Thu, 29 Dec 2016 10:34:28 -0500
parents 40d002406884
children e4dac614ce56
files trackHub/README.md trackHub/datatypes_conf.xml trackHub/trackhub.xml trackHub/tracks_partial.py
diffstat 4 files changed, 108 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trackHub/README.md	Thu Dec 29 10:34:28 2016 -0500
@@ -0,0 +1,12 @@
+This folder exists to configure Galaxy to handle the files generated by HubArchiveCreator tool
+
+* The **content** of datatypes_conf.xml should go inside config/datatypes_conf.xml, under \<registration\> (Copy config/datatypes_conf.xml.sample to config/datatypes_conf.xml if it does not exist yet)
+* The content of tracks_partial.py should go inside `lib/galaxy/datatypes/tracks.py`
+* trackhub.xml should go inside display_application/ucsc/
+
+
+TODO:
+
+- [x] Create a script to copy all these files directly into galaxy => Done but not usable now I have changed the datatype to match Galaxy IUC
+- [ ] Need to modify the script `util/add_datatype.py` to match the changes introduced in https://github.com/galaxyproject/galaxy/pull/2348
+- [x] Create a package in ToolShed that install directly this when installing HubArchiveCreator => Not recommended by Galaxy IUC and team
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trackHub/datatypes_conf.xml	Thu Dec 29 10:34:28 2016 -0500
@@ -0,0 +1,3 @@
+<datatype extension="trackhub" type="galaxy.datatypes.tracks:UCSCTrackHub" display_in_upload="true">
+    <display file="ucsc/trackhub.xml" />
+</datatype>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trackHub/trackhub.xml	Thu Dec 29 10:34:28 2016 -0500
@@ -0,0 +1,6 @@
+<display id="ucsc_trackhub" version="1.0.0" name="display at Track Hub UCSC">
+    <link id="main" name="main">
+        <url>https://genome.ucsc.edu/cgi-bin/hgHubConnect?hubUrl=${qp($hub_file.url + '/myHub/hub.txt')}&amp;hgHub_do_firstDb=on&amp;hgHub_do_redirect=on&amp;hgHubConnect.remakeTrackHub=on</url>
+        <param type="data" name="hub_file" url="galaxy_${DATASET_HASH}" allow_extra_files_access="True" />
+    </link>
+</display>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trackHub/tracks_partial.py	Thu Dec 29 10:34:28 2016 -0500
@@ -0,0 +1,87 @@
+"""
+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)]
+
+        def create_tree(path, tree):
+            if path[0] in tree:
+                create_tree(path[1:], tree[path[0]])
+            else:
+                tree[path[0]] = {}
+                if len(path) == 1:
+                    return
+                else:
+                    create_tree(path[1:], tree[path[0]])
+
+        def print_tree(tree, level):
+            if len(tree) == 0:
+                return
+
+            for vertex in tree:
+                    composite_name = vertex
+                    bullet_point = '<li><a href="{0}>{0}</a></li>'.format(composite_name)
+                    rval.append(bullet_point)
+                    # Parent, so need to create a sub <ul>
+                    if len(tree[vertex]) > 0:
+                        rval.append('<ul>')
+                        print_tree(tree[vertex], level+1)
+                        rval.append('</ul>')
+
+        walkable_tree = {}
+
+        for composite_name_full_path, composite_file in self.get_composite_files(dataset=dataset).iteritems():
+            paths = composite_name_full_path.split('/')
+            # Prepare the tree from to perform a Depth First Search
+            create_tree(paths, walkable_tree)
+
+        # Perform a Depth First Search to print all the directory and files properly
+        print_tree(walkable_tree, 0)
+
+        # 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