annotate Bed.py @ 0:abcfd662b679 draft default tip

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