diff Bam.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 3233451a3bd6
line wrap: on
line diff
--- a/Bam.py	Thu Jul 21 05:58:51 2016 -0400
+++ b/Bam.py	Wed Jul 27 10:10:49 2016 -0400
@@ -24,11 +24,15 @@
 
         self.data_bam = data_bam
         # TODO: Check if it already contains the .bam extension / Do a function in Datatype which check the extension
-        self.name_bam = self.data_bam["name"] + ".bam"
+        if ".bam" not in self.data_bam["name"]:
+            self.name_bam = self.data_bam["name"] + ".bam"
+        else:
+            self.name_bam = self.data_bam["name"]
+
         self.priority = self.data_bam["order_index"]
         self.index_bam = self.data_bam["index"]
 
-        print "Creating TrackHub BAM from (falsePath: %s; name: %s)" % ( self.input_bam_false_path, self.name_bam)
+        #print "Creating TrackHub BAM from (falsePath: %s; name: %s)" % ( self.input_bam_false_path, self.name_bam)
 
         # First: Add the bam file
         # Second: Add the bam index file, in the same folder (https://genome.ucsc.edu/goldenpath/help/bam.html)
@@ -42,23 +46,29 @@
         shutil.copyfile(self.index_bam, bam_index_file_path)
 
         # Create the Track Object
-        dataURL = "tracks/%s" % self.name_bam
+        self.createTrack(file_path=self.name_bam,
+                         track_name=self.name_bam,
+                         long_label=self.name_bam, track_type='bam', visibility='pack', priority=self.priority,
+                         track_file=bam_index_file_path)
+        #
+        # dataURL = "tracks/%s" % self.name_bam
+        #
+        # trackDb = TrackDb(
+        #     trackName=self.name_bam,
+        #     longLabel=self.name_bam,
+        #     shortLabel=self.getShortName( self.name_bam ),
+        #     trackDataURL=dataURL,
+        #     trackType='bam',
+        #     visibility='pack',
+        #     priority=self.priority,
+        # )
+        #
+        # # Return the Bam Track Object
+        # self.track = Track(
+        #     trackFile=bam_index_file_path,
+        #     trackDb=trackDb,
+        # )
 
-        trackDb = TrackDb(
-            trackName=self.name_bam,
-            longLabel=self.name_bam,
-            shortLabel=self.getShortName( self.name_bam ),
-            trackDataURL=dataURL,
-            trackType='bam',
-            visibility='pack',
-            priority=self.priority,
-        )
-
-        # Return the Bam Track Object
-        self.track = Track(
-            trackFile=bam_index_file_path,
-            trackDb=trackDb,
-        )
-
-        print("- %s created in %s" % (self.name_bam, bam_file_path))
-        print("- %s created in %s" % (self.index_bam, bam_index_file_path))
+        print("- Bam %s created" % self.name_bam)
+        #print("- %s created in %s" % (self.name_bam, bam_file_path))
+        #print("- %s created in %s" % (self.index_bam, bam_index_file_path))