Mercurial > repos > yating-l > hubarchivecreator
comparison Psl.py @ 0:3e0c61b52a06 draft
planemo upload for repository https://github.com/Yating-L/hub-archive-creator commit a77635b40ebd29baafb3bea57f8cbfb3f252e3b0-dirty
| author | yating-l |
|---|---|
| date | Mon, 31 Oct 2016 16:36:25 -0400 |
| parents | |
| children | c66803bff0cc |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:3e0c61b52a06 |
|---|---|
| 1 import logging | |
| 2 import os | |
| 3 import tempfile | |
| 4 | |
| 5 # Internal dependencies | |
| 6 from Datatype import Datatype | |
| 7 from util import subtools | |
| 8 | |
| 9 | |
| 10 class Psl(Datatype): | |
| 11 def __init__(self, input_psl_path, data_psl): | |
| 12 super(Psl, self).__init__() | |
| 13 | |
| 14 self.track = None | |
| 15 | |
| 16 self.input_psl_path = input_psl_path | |
| 17 self.name_psl = data_psl["name"] | |
| 18 self.priority = data_psl["order_index"] | |
| 19 self.track_color = data_psl["track_color"] | |
| 20 # TODO: Think about how to avoid repetition of the group_name everywhere | |
| 21 self.group_name = data_psl["group_name"] | |
| 22 | |
| 23 # Temporary files | |
| 24 unsorted_bed_formatted_psl_file = tempfile.NamedTemporaryFile(suffix='.psl') | |
| 25 sorted_bed_formatted_psl_file = tempfile.NamedTemporaryFile(suffix='psl') | |
| 26 | |
| 27 # Get the bed12+12 with pslToBigPsl | |
| 28 subtools.pslToBigPsl(input_psl_path, unsorted_bed_formatted_psl_file.name) | |
| 29 | |
| 30 # Sort the formatted psl into sorted_bed_formatted_psl_file | |
| 31 subtools.sort(unsorted_bed_formatted_psl_file.name, sorted_bed_formatted_psl_file.name) | |
| 32 | |
| 33 # Get the binary indexed bigPsl with bedToBigBed | |
| 34 trackName = "".join((self.name_psl, ".bb")) | |
| 35 | |
| 36 auto_sql_option = os.path.join(self.tool_directory, 'bigPsl.as') | |
| 37 | |
| 38 my_big_psl_file_path = os.path.join(self.myTrackFolderPath, trackName) | |
| 39 | |
| 40 logging.debug("Hello") | |
| 41 | |
| 42 with open(my_big_psl_file_path, 'w') as big_psl_file: | |
| 43 subtools.bedToBigBed(sorted_bed_formatted_psl_file.name, | |
| 44 self.chromSizesFile.name, | |
| 45 big_psl_file.name, | |
| 46 autoSql=auto_sql_option, | |
| 47 typeOption='bed12+12', | |
| 48 tab=True) | |
| 49 | |
| 50 # Create the Track Object | |
| 51 self.createTrack(file_path=trackName, | |
| 52 track_name=trackName, | |
| 53 long_label=self.name_psl, | |
| 54 track_type='bigPsl', visibility='dense', | |
| 55 priority=self.priority, | |
| 56 track_file=my_big_psl_file_path, | |
| 57 track_color=self.track_color, | |
| 58 group_name=self.group_name) | |
| 59 | |
| 60 print("- BigPsl %s created" % self.name_psl) |
