Mercurial > repos > yating-l > hubarchivecreator
comparison Bed.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 #!/usr/bin/python | |
2 | |
3 import os | |
4 import tempfile | |
5 | |
6 # Internal dependencies | |
7 from Datatype import Datatype | |
8 from Track import Track | |
9 from TrackDb import TrackDb | |
10 from util import subtools | |
11 | |
12 | |
13 class Bed( Datatype ): | |
14 def __init__( self, inputBedGeneric, data_bed_generic): | |
15 super(Bed, self).__init__() | |
16 | |
17 self.track = None | |
18 | |
19 self.inputBedGeneric = inputBedGeneric | |
20 | |
21 self.sortedBedFile = tempfile.NamedTemporaryFile(suffix=".sortedBed") | |
22 | |
23 self.data_bed_generic = data_bed_generic | |
24 self.name_bed_generic = self.data_bed_generic["name"] | |
25 self.priority = self.data_bed_generic["order_index"] | |
26 self.track_color = self.data_bed_generic["track_color"] | |
27 # TODO: Think about how to avoid repetition of the group_name everywhere | |
28 self.group_name = self.data_bed_generic["group_name"] | |
29 | |
30 | |
31 # Sort processing | |
32 subtools.sort(self.inputBedGeneric, self.sortedBedFile.name) | |
33 | |
34 # bedToBigBed processing | |
35 # TODO: Change the name of the bb, to tool + genome + possible adding if multiple + .bb | |
36 trackName = "".join( ( self.name_bed_generic, ".bb") ) | |
37 | |
38 myBigBedFilePath = os.path.join(self.myTrackFolderPath, trackName) | |
39 with open(myBigBedFilePath, 'w') as self.bigBedFile: | |
40 subtools.bedToBigBed(self.sortedBedFile.name, | |
41 self.chromSizesFile.name, | |
42 self.bigBedFile.name) | |
43 | |
44 # Create the Track Object | |
45 self.createTrack(file_path=trackName, | |
46 track_name=trackName, | |
47 long_label=self.name_bed_generic, track_type='bigBed', visibility='dense', | |
48 priority=self.priority, | |
49 track_file=myBigBedFilePath, | |
50 track_color=self.track_color, | |
51 group_name=self.group_name) | |
52 | |
53 # dataURL = "tracks/%s" % trackName | |
54 # | |
55 # trackDb = TrackDb( | |
56 # trackName=trackName, | |
57 # longLabel=self.name_bed_generic, | |
58 # shortLabel=self.getShortName(self.name_bed_generic), | |
59 # trackDataURL=dataURL, | |
60 # trackType='bigBed', | |
61 # visibility='dense', | |
62 # thickDrawItem='on', | |
63 # priority=self.priority, | |
64 # ) | |
65 # | |
66 # # Return the BigBed track | |
67 # self.track = Track( | |
68 # trackFile=myBigBedFilePath, | |
69 # trackDb=trackDb, | |
70 # ) | |
71 | |
72 print("- Bed %s created" % self.name_bed_generic) | |
73 #print("- %s created in %s" % (trackName, myBigBedFilePath)) |