diff Datatype.py @ 11:d05236b15f81 draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 3760d0c8353b924ecf994131a5c2eb381aa81fb2
author rmarenco
date Wed, 27 Jul 2016 10:10:49 -0400
parents acc233161f50
children 25809f699cb3
line wrap: on
line diff
--- a/Datatype.py	Thu Jul 21 05:58:51 2016 -0400
+++ b/Datatype.py	Wed Jul 27 10:10:49 2016 -0400
@@ -9,6 +9,8 @@
 import tempfile
 
 from util import subtools
+from Track import Track
+from TrackDb import TrackDb
 
 
 class Datatype(object):
@@ -25,6 +27,8 @@
     twoBitFile = None
     chromSizesFile = None
 
+    track = None
+
     def __init__(self):
 
         not_init_message = "The {0} is not initialized." \
@@ -37,6 +41,7 @@
             raise TypeError(not_init_message.format('tool directory'))
 
 
+
     @staticmethod
     def pre_init(reference_genome, two_bit_path, chrom_sizes_file,
                  extra_files_path, tool_directory, specie_folder, tracks_folder):
@@ -66,3 +71,39 @@
         short_label_slice = slice(0, 15)
 
         return name_to_shortify[short_label_slice]
+
+    # TODO: Better handle parameters, use heritance mecanism
+    # TODO: Use default parameters for some, like visibility
+    def createTrack(self,
+                    file_path=None,
+                    track_name=None, long_label=None, thick_draw_item='off',
+                    short_label=None, track_type=None, visibility=None, priority=None,
+                    track_file=None):
+
+        # TODO: Remove the hardcoded "tracks" by the value used as variable from myTrackFolderPath
+        data_url = "tracks/%s" % file_path
+
+        if not short_label:
+            short_label = self.getShortName(long_label)
+
+        # Replace '_' by ' ', to invert the sanitization mecanism
+        # TODO: Find a better way to manage the sanitization of file path
+        long_label = long_label.replace("_", " ")
+        short_label = short_label.replace("_", " ")
+
+        track_db = TrackDb(
+                trackName=track_name,
+                longLabel=long_label,
+                shortLabel=short_label,
+                trackDataURL=data_url,
+                trackType=track_type,
+                visibility=visibility,
+                thickDrawItem=thick_draw_item,
+                priority=priority,
+        )
+
+        # Return the Bam Track Object
+        self.track = Track(
+                trackFile=track_file,
+                trackDb=track_db,
+        )