Mercurial > repos > rmarenco > hubarchivecreator
comparison Psl.py @ 16:3233451a3bd6 draft
planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit fc73ec22a0db3ab09c4ac13dc58f0b54ae37845c
| author | rmarenco |
|---|---|
| date | Sun, 25 Sep 2016 11:25:38 -0400 |
| parents | |
| children | c02720d1afee |
comparison
equal
deleted
inserted
replaced
| 15:2a45cd656e8e | 16:3233451a3bd6 |
|---|---|
| 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 | |
| 21 # Temporary files | |
| 22 unsorted_bed_formatted_psl_file = tempfile.NamedTemporaryFile(suffix='.psl') | |
| 23 sorted_bed_formatted_psl_file = tempfile.NamedTemporaryFile(suffix='psl') | |
| 24 | |
| 25 # Get the bed12+12 with pslToBigPsl | |
| 26 subtools.pslToBigPsl(input_psl_path, unsorted_bed_formatted_psl_file.name) | |
| 27 | |
| 28 # Sort the formatted psl into sorted_bed_formatted_psl_file | |
| 29 subtools.sort(unsorted_bed_formatted_psl_file.name, sorted_bed_formatted_psl_file.name) | |
| 30 | |
| 31 # Get the binary indexed bigPsl with bedToBigBed | |
| 32 trackName = "".join((self.name_psl, ".bb")) | |
| 33 | |
| 34 auto_sql_option = os.path.join(self.tool_directory, 'bigPsl.as') | |
| 35 | |
| 36 my_big_psl_file_path = os.path.join(self.myTrackFolderPath, trackName) | |
| 37 | |
| 38 logging.debug("Hello") | |
| 39 | |
| 40 with open(my_big_psl_file_path, 'w') as big_psl_file: | |
| 41 subtools.bedToBigBed(sorted_bed_formatted_psl_file.name, | |
| 42 self.chromSizesFile.name, | |
| 43 big_psl_file.name, | |
| 44 autoSql=auto_sql_option, | |
| 45 typeOption='bed12+12', | |
| 46 tab=True) | |
| 47 | |
| 48 # Create the Track Object | |
| 49 self.createTrack(file_path=trackName, | |
| 50 track_name=trackName, | |
| 51 long_label=self.name_psl, | |
| 52 track_type='bigPsl', visibility='dense', | |
| 53 priority=self.priority, | |
| 54 track_file=my_big_psl_file_path, | |
| 55 track_color=self.track_color) | |
| 56 | |
| 57 print("- BigPsl %s created" % self.name_psl) |
