Mercurial > repos > rmarenco > hubarchivecreator
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 10:acc233161f50 | 11:d05236b15f81 |
|---|---|
| 22 | 22 |
| 23 self.input_bam_false_path = input_bam_false_path | 23 self.input_bam_false_path = input_bam_false_path |
| 24 | 24 |
| 25 self.data_bam = data_bam | 25 self.data_bam = data_bam |
| 26 # TODO: Check if it already contains the .bam extension / Do a function in Datatype which check the extension | 26 # TODO: Check if it already contains the .bam extension / Do a function in Datatype which check the extension |
| 27 self.name_bam = self.data_bam["name"] + ".bam" | 27 if ".bam" not in self.data_bam["name"]: |
| 28 self.name_bam = self.data_bam["name"] + ".bam" | |
| 29 else: | |
| 30 self.name_bam = self.data_bam["name"] | |
| 31 | |
| 28 self.priority = self.data_bam["order_index"] | 32 self.priority = self.data_bam["order_index"] |
| 29 self.index_bam = self.data_bam["index"] | 33 self.index_bam = self.data_bam["index"] |
| 30 | 34 |
| 31 print "Creating TrackHub BAM from (falsePath: %s; name: %s)" % ( self.input_bam_false_path, self.name_bam) | 35 #print "Creating TrackHub BAM from (falsePath: %s; name: %s)" % ( self.input_bam_false_path, self.name_bam) |
| 32 | 36 |
| 33 # First: Add the bam file | 37 # First: Add the bam file |
| 34 # Second: Add the bam index file, in the same folder (https://genome.ucsc.edu/goldenpath/help/bam.html) | 38 # Second: Add the bam index file, in the same folder (https://genome.ucsc.edu/goldenpath/help/bam.html) |
| 35 | 39 |
| 36 bam_file_path = os.path.join(self.myTrackFolderPath, self.name_bam) | 40 bam_file_path = os.path.join(self.myTrackFolderPath, self.name_bam) |
| 40 name_index_bam = self.name_bam + ".bai" | 44 name_index_bam = self.name_bam + ".bai" |
| 41 bam_index_file_path = os.path.join(self.myTrackFolderPath, name_index_bam) | 45 bam_index_file_path = os.path.join(self.myTrackFolderPath, name_index_bam) |
| 42 shutil.copyfile(self.index_bam, bam_index_file_path) | 46 shutil.copyfile(self.index_bam, bam_index_file_path) |
| 43 | 47 |
| 44 # Create the Track Object | 48 # Create the Track Object |
| 45 dataURL = "tracks/%s" % self.name_bam | 49 self.createTrack(file_path=self.name_bam, |
| 50 track_name=self.name_bam, | |
| 51 long_label=self.name_bam, track_type='bam', visibility='pack', priority=self.priority, | |
| 52 track_file=bam_index_file_path) | |
| 53 # | |
| 54 # dataURL = "tracks/%s" % self.name_bam | |
| 55 # | |
| 56 # trackDb = TrackDb( | |
| 57 # trackName=self.name_bam, | |
| 58 # longLabel=self.name_bam, | |
| 59 # shortLabel=self.getShortName( self.name_bam ), | |
| 60 # trackDataURL=dataURL, | |
| 61 # trackType='bam', | |
| 62 # visibility='pack', | |
| 63 # priority=self.priority, | |
| 64 # ) | |
| 65 # | |
| 66 # # Return the Bam Track Object | |
| 67 # self.track = Track( | |
| 68 # trackFile=bam_index_file_path, | |
| 69 # trackDb=trackDb, | |
| 70 # ) | |
| 46 | 71 |
| 47 trackDb = TrackDb( | 72 print("- Bam %s created" % self.name_bam) |
| 48 trackName=self.name_bam, | 73 #print("- %s created in %s" % (self.name_bam, bam_file_path)) |
| 49 longLabel=self.name_bam, | 74 #print("- %s created in %s" % (self.index_bam, bam_index_file_path)) |
| 50 shortLabel=self.getShortName( self.name_bam ), | |
| 51 trackDataURL=dataURL, | |
| 52 trackType='bam', | |
| 53 visibility='pack', | |
| 54 priority=self.priority, | |
| 55 ) | |
| 56 | |
| 57 # Return the Bam Track Object | |
| 58 self.track = Track( | |
| 59 trackFile=bam_index_file_path, | |
| 60 trackDb=trackDb, | |
| 61 ) | |
| 62 | |
| 63 print("- %s created in %s" % (self.name_bam, bam_file_path)) | |
| 64 print("- %s created in %s" % (self.index_bam, bam_index_file_path)) |
