annotate BedSpliceJunctions.py @ 26:df42241d3731 draft

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