annotate BedSpliceJunctions.py @ 52:c66803bff0cc draft

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