comparison Psl.py @ 0:f493979f1408 draft default tip

planemo upload for repository https://github.com/Yating-L/hubarchivecreator-test commit 48b59e91e2dcc2e97735ee35d587960cbfbce932-dirty
author yating-l
date Wed, 21 Dec 2016 12:13:04 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f493979f1408
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)