comparison BedSpliceJunctions.py @ 20:40469b265ddb draft

planemo upload for repository https://github.com/goeckslab/hub-archive-creator commit 3af31e043f5b82636015c18e013d2f22ce6c9077-dirty
author yating-l
date Fri, 20 Jan 2017 17:12:03 -0500
parents
children 2677f1899aa8
comparison
equal deleted inserted replaced
19:0152500d9acd 20:40469b265ddb
1 #!/usr/bin/python
2
3 import os
4 import tempfile
5
6 from Datatype import Datatype
7 from Track import Track
8 from TrackDb import TrackDb
9 from util import subtools
10
11
12 class BedSpliceJunctions( Datatype ):
13 def __init__(self, input_bed_splice_junctions_false_path, data_bed_splice_junctions):
14
15 super(BedSpliceJunctions, self).__init__()
16
17 self.input_bed_splice_junctions_false_path = input_bed_splice_junctions_false_path
18 self.name_bed_splice_junctions = data_bed_splice_junctions["name"]
19 self.priority = data_bed_splice_junctions["order_index"]
20 self.track_color = data_bed_splice_junctions["track_color"]
21 # TODO: Think about how to avoid repetition of the group_name everywhere
22 self.group_name = data_bed_splice_junctions["group_name"]
23
24 sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed")
25
26 # Sort processing
27 subtools.sort(self.input_bed_splice_junctions_false_path, sortedBedFile.name)
28
29 # bedToBigBed processing
30 # TODO: Change the name of the bb, to tool + genome + .bb
31 trackName = "".join( ( self.name_bed_splice_junctions, '.bb' ) )
32 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName)
33
34 auto_sql_option = os.path.join(self.tool_directory, 'spliceJunctions.as')
35
36 with open(myBigBedFilePath, 'w') as bigBedFile:
37 subtools.bedToBigBed(sortedBedFile.name,
38 self.chromSizesFile.name,
39 bigBedFile.name,
40 typeOption='bed12+1',
41 autoSql=auto_sql_option)
42
43 # Create the Track Object
44 self.createTrack(file_path=trackName,
45 track_name=trackName,
46 long_label=self.name_bed_splice_junctions, track_type='bigBed 12 +', visibility='dense',
47 priority=self.priority,
48 track_file=myBigBedFilePath,
49 track_color=self.track_color,
50 group_name=self.group_name)
51
52 # dataURL = "tracks/%s" % trackName
53 #
54 # trackDb = TrackDb(
55 # trackName=trackName,
56 # longLabel=self.name_bed_simple_repeats,
57 # shortLabel=self.getShortName( self.name_bed_simple_repeats ),
58 # trackDataURL=dataURL,
59 # trackType='bigBed 4 +',
60 # visibility='dense',
61 # priority=self.priority,
62 # )
63 #
64 # self.track = Track(
65 # trackFile=myBigBedFilePath,
66 # trackDb=trackDb,
67 # )
68
69 print("- Bed splice junctions %s created" % self.name_bed_splice_junctions)
70 #print("- %s created in %s" % (trackName, myBigBedFilePath))