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